Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check nil worker ref in llbBridgeForwarder. #3169

Merged
merged 1 commit into from
Oct 19, 2022

Conversation

sipsma
Copy link
Collaborator

@sipsma sipsma commented Oct 13, 2022

Without this, the included test case will result in buildkitd panicking.

Signed-off-by: Erik Sipsma erik@sipsma.dev

Diagnosed here: dagger/dagger#3330 (comment)

Also possibly related to #3134 (unless that one was already fixed)

Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems logical for the getImmutableRef to return nil in this case, even if that makes the patch longer. Otherwise maybe the name should be must*

ref, err := res.SingleRef()
require.NoError(t, err)

// verify that this returns an error, but doesn't panic buildkitd
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the ref also be nil in this case. Or at least there should be some saner way to check for nil ref from the client side.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree but it seems tricky to deal with the case where evaluate isn't true. You won't know the actual result is nil until its evaluated, but you have to return something to represent it until then.

I guess it would be possible to only return nil only when evaluate is true, but then you still have to deal with the case where something is "lazily nil" when evaluate is false, so I don't know if that actually simplifies anything overall.

Without this, the included test case will result in buildkitd panicking.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
@sipsma
Copy link
Collaborator Author

sipsma commented Oct 14, 2022

It seems logical for the getImmutableRef to return nil in this case, even if that makes the patch longer. Otherwise maybe the name should be must*

Yeah makes sense. I realized that all the methods in llbBridgeForwarder use cacheutil, which actually handles nil mountables perfectly already. So I updated to just passthrough to that without trying to use the nil and it all seems to work. ReadDir, ReadFile, etc. all have logical behavior (basically just treat a nil mountable as an empty mount). Think this makes a lot of sense, let me know if you agree.

@tonistiigi tonistiigi merged commit a3b8594 into moby:master Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants