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

builder: implement PullParent option with buildkit #37613

Merged
merged 1 commit into from
Aug 17, 2018

Conversation

tiborvass
Copy link
Contributor

Signed-off-by: Tibor Vass tibor@docker.com

This allows to run docker build --pull ... when buildkit is enabled.

@codecov
Copy link

codecov bot commented Aug 14, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@b6242da). Click here to learn what that means.
The diff coverage is n/a.

@@            Coverage Diff            @@
##             master   #37613   +/-   ##
=========================================
  Coverage          ?   35.85%           
=========================================
  Files             ?      606           
  Lines             ?    44704           
  Branches          ?        0           
=========================================
  Hits              ?    16029           
  Misses            ?    26466           
  Partials          ?     2209

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

LGTM 🐯

Copy link
Member

@thaJeztah thaJeztah left a 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 {
Copy link
Member

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)

if preferLocal {
dt, err := p.is.resolveLocal(p.src.Reference.String())
if err == nil {
p.config = dt
}
}

@tiborvass tiborvass force-pushed the buildkit-pull branch 2 times, most recently from 85b7c63 to cfa31c9 Compare August 17, 2018 08:25
@tiborvass
Copy link
Contributor Author

@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 --pull is the same between legacy and buildkit builders.

Copy link
Member

@vdemeester vdemeester left a 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>
@tiborvass
Copy link
Contributor Author

Just removed preferLocal constant.

Copy link
Member

@thaJeztah thaJeztah left a 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
Copy link
Member

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)

Copy link
Contributor Author

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"
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

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) 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants