-
Notifications
You must be signed in to change notification settings - Fork 18.6k
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
builder: implement PullParent option with buildkit #37613
Conversation
Codecov Report
@@ Coverage Diff @@
## master #37613 +/- ##
=========================================
Coverage ? 35.85%
=========================================
Files ? 606
Lines ? 44704
Branches ? 0
=========================================
Hits ? 16029
Misses ? 26466
Partials ? 2209 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🐯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM
ping @tonistiigi PTAL
@@ -115,11 +115,17 @@ func (is *imageSource) resolveLocal(refStr string) ([]byte, error) { | |||
} | |||
|
|||
func (is *imageSource) ResolveImageConfig(ctx context.Context, ref string, opt gw.ResolveImageConfigOpt) (digest.Digest, []byte, error) { | |||
if preferLocal { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noticed that puller.resolveLocal()
still uses this constant; looking at where that's called that seems to be only used to determine if an image is in the cache, which likely isn't done until after this function (ResolveImageConfig()
) has been called? Just wondering if that part of the code will also be configurable, or will be the only behavior (in which case we can remove the preferLocal
constant)
moby/builder/builder-next/adapters/containerimage/pull.go
Lines 216 to 221 in 4122eb1
if preferLocal { | |
dt, err := p.is.resolveLocal(p.src.Reference.String()) | |
if err == nil { | |
p.config = dt | |
} | |
} |
85b7c63
to
cfa31c9
Compare
@vdemeester @thaJeztah I updated this. I fixed an issue whereby "local" would error out if local was not found, when in fact it just means "prefer" local, but still fallback to remote if cannot find. Ideally I'd like "pull" to also fallback to local (like when you're on the plane and don't have network). Essentially there is no difference between "default" and "local", other than I use "default" so that in the future we may improve on the UX if we want to. Either way, right now, the behavior of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still LGTM 😉
Signed-off-by: Tibor Vass <tibor@docker.com>
cfa31c9
to
7c1c8f1
Compare
Just removed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
triggered CI to do another run
dgst, dt, err := is.resolveRemote(ctx, ref, opt.Platform) | ||
// TODO: pull should fallback to local in case of failure to allow offline behavior | ||
// the fallback doesn't work currently | ||
return dgst, dt, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit; could be
return is.resolveRemote(ctx, ref, opt.Platform)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thaJeztah true, this was because the original (desired) code is the one commented out below in which case the assignments do make sense.
@@ -209,6 +209,12 @@ func (b *Builder) Build(ctx context.Context, opt backend.BuildConfig) (*builder. | |||
frontendAttrs["no-cache"] = "" | |||
} | |||
|
|||
if opt.Options.PullParent { | |||
frontendAttrs["image-resolve-mode"] = "pull" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking if it would be good to use the values that are / will be defined in source.ResolveMode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thaJeztah actually, could do it in a follow up once buildkit has a String() method on it. I don't want to rely on llb package at this level of abstraction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup; definitely not a blocker (same for my other comment) 👍
Signed-off-by: Tibor Vass tibor@docker.com
This allows to run
docker build --pull ...
when buildkit is enabled.