Skip to content

build: custom build can support deterministic tags (rather than generating temp tag to check against) [ch1909]#1343

Merged
maiamcc merged 8 commits into
masterfrom
maiamcc/custom-build-deterministic-tag
Mar 22, 2019
Merged

build: custom build can support deterministic tags (rather than generating temp tag to check against) [ch1909]#1343
maiamcc merged 8 commits into
masterfrom
maiamcc/custom-build-deterministic-tag

Conversation

@maiamcc

@maiamcc maiamcc commented Mar 21, 2019

Copy link
Copy Markdown
Contributor

in Tiltfile, user can pass an optional tag arg to custom_build. If this arg is set, we exec CustomBuild.command and check that it produced user-image:customBuild.Tag; otherwise, we generate our own temp tag, exec the command, and check that it produced user-image:tmpTag.

@maiamcc maiamcc changed the title build: custom build can support deterministic tags (rather than generating temp tag to check again) build: custom build can support deterministic tags (rather than generating temp tag to check against) [ch1909] Mar 21, 2019
@maiamcc
maiamcc requested review from jazzdan and nicks March 21, 2019 16:21
Comment thread internal/container/selector.go Outdated

type RefSelector struct {
ref reference.Named
Ref reference.Named

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i'm confident that this shouldn't be a public field. it's not something that an API user would want or be able to use correctly. as a proof of point, the only place you did use this field is wrong and a bug.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not a bug, it was desired behavior -- the idea was to pass in the ref as specified in Tiltfile (rather than as stripped down for deployment) so we knew whether user gave it a tag or not. But I'm redoing this PR on advice from DB, so it's moot.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hmmm...can you point me to the spec that describes the expected behavior and how it's supposed to interact with substitute_repo?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(my understanding from previous conversations is we expected custom_build to push to a remote repo in some cases)

@maiamcc maiamcc Mar 21, 2019

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

that behavior has been removed, so i'm not sure your question still applies...?

ps.StartPipelineStep(ctx, "Building Dockerfile: [%s]", userFacingRefName)
defer ps.EndPipelineStep(ctx)
ref, err := icb.custb.Build(ctx, refToBuild, bd.Command)
ref, err := icb.custb.Build(ctx, iTarget.ConfigurationRef.Ref, bd.Command)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

shouldn't this be the DeploymentRef? see other places where we do builds, e.g. https://github.com/windmilleng/tilt/blob/master/internal/engine/image_and_cache_builder.go#L37

@maiamcc

maiamcc commented Mar 21, 2019

Copy link
Copy Markdown
Contributor Author

This is how it looks in action: https://github.com/windmilleng/servantes/tree/bazel-tag-param

@maiamcc
maiamcc requested a review from nicks March 21, 2019 19:25
}

if strings.Contains(f.k8s.Yaml, sidecar.SyncletImageName) {
t.Errorf("Should not deploy the synclet for a custom build: %s", f.k8s.Yaml)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hmmm...this behavior is surprising to me? is there something i can read that explains why custom_build would affect synclet behavior?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Huhhh idk, I copied this from another test 🤷‍♀️ i think it's relevant b/c it's a custom build W/O fast build? (See this test. It's not relevant to this test case tho, I'll take it out.

t.Errorf("Expected 0 docker build, actual: %d", f.docker.BuildCount)
}

if f.docker.PushCount != 1 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hmmm...afaict, this test would pass fine if the functionality in this pr was totally broken...right? please also add an assertion about the image that was pushed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

nope, it fails without the rest of the functionality in this PR. if CustomBuild.Tag isn't set, we generate our own temporary tag and set an env variable $TAG=imagename:temptag; we then check that the expected image and expected tag were built.

if i remove the changes to CustomBuilder.Build, test fails with:

Custom Build: Injecting Environment Variables
TAG=gcr.io/some-project-162817/sancho:tilt-build-1551202573
Running custom build cmd "true"

ERROR: fake docker client error: object not found (fakeClient.Images key: gcr.io/some-project-162817/sancho:tilt-build-1551202573)

(i.e. we spoof that the custom build command built gcr.io/.../sancho:deterministic-tag; but Build goes looking for sancho:tilt-build-1551202573, cant find it, thinks something has gone wrong.)

@jazzdan jazzdan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Thanks for taking care of this :)

@nicks nicks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great, thx for the explanations!

@maiamcc
maiamcc merged commit 5d12677 into master Mar 22, 2019
@maiamcc
maiamcc deleted the maiamcc/custom-build-deterministic-tag branch March 22, 2019 15:00
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.

3 participants