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

Store built image digest in the build status #12407

Merged
merged 1 commit into from
Jan 20, 2017

Conversation

mmilata
Copy link
Contributor

@mmilata mmilata commented Jan 6, 2017

Trello card: https://trello.com/c/SAvLJLLl/1036-5-provide-the-built-image-reference-as-part-of-the-build-status-builds

@legionus @miminar I'm extracting the digest from the stream of jsons docker client generates during pushing, is this approach fine with you guys? I've asked Docker if they consider it part of the API: moby/moby#29865.

@bparees PTAL

@mmilata
Copy link
Contributor Author

mmilata commented Jan 6, 2017

[test][testextended][extended:core(builds)]

@bparees
Copy link
Contributor

bparees commented Jan 6, 2017

lgtm, @openshift/api-review please approve the new digest field.

@bparees bparees self-assigned this Jan 6, 2017
// outputDockerImageDigest is the digest of the built Docker image. The
// digest uniquely identifies the image in the registry to which it was
// pushed.
OutputDockerImageDigest string
Copy link
Contributor

Choose a reason for hiding this comment

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

Put this in a struct that parallels spec output - probably status.output.to.imageDigest where output is a struct, to is a pointer to a struct, and to is only set when an image was output.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've changed the structs as requested, PTAL if it's what you wanted.

@smarterclayton
Copy link
Contributor

smarterclayton commented Jan 6, 2017 via email

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 12, 2017
@mmilata
Copy link
Contributor Author

mmilata commented Jan 12, 2017

Rebased, though there's still a bug in the digest extraction code that makes the tests fail that I'm working on.

@mmilata mmilata changed the title Store built image digest in the build status [do not merge] Store built image digest in the build status Jan 12, 2017
@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 12, 2017
@mmilata mmilata force-pushed the store-digest branch 3 times, most recently from 46a6c41 to 3078317 Compare January 17, 2017 16:02
@mmilata mmilata changed the title [do not merge] Store built image digest in the build status Store built image digest in the build status Jan 17, 2017
message BuildStatusOutputTo {
// imageDigest is the digest of the built Docker image. The digest uniquely
// identifies the image in the registry to which it was pushed. Please note
// that this field may not always set even if the push completes
Copy link

Choose a reason for hiding this comment

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

missing be

Copy link

Choose a reason for hiding this comment

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

What causes the digest not to be set?

Copy link

@miminar miminar left a comment

Choose a reason for hiding this comment

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

Few remarks. LGTM overall.

message BuildStatusOutputTo {
// imageDigest is the digest of the built Docker image. The digest uniquely
// identifies the image in the registry to which it was pushed. Please note
// that this field may not always set even if the push completes
Copy link

Choose a reason for hiding this comment

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

What causes the digest not to be set?

return reportPushFailure(err, authPresent, pushAuthConfig)
}
if digest != "" {
Copy link

Choose a reason for hiding this comment

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

len(digest) > 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just curious, is it a matter of consistency or is there a practical difference?

Copy link

Choose a reason for hiding this comment

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

I'd say it's just about consistency.

Copy link

Choose a reason for hiding this comment

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

bump :-)

@@ -73,28 +77,33 @@ func pullImage(client DockerClient, name string, authConfig docker.AuthConfigura
// - Docker registry is down temporarily or permanently
// - other image is being pushed to the registry
// If any other scenario the push will fail, without retries.
Copy link

Choose a reason for hiding this comment

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

Document the newly added return value.

for {
// save the not yet parsed input so we can restore it in case it
// contains part of valid JSON
savedBuf, err := ioutil.ReadAll(dec.Buffered())
Copy link

Choose a reason for hiding this comment

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

If the err is ignored intentionally, use _.

}
}

// simpleProgressWriter is an io.Writer which consumes a stream of json
Copy link

Choose a reason for hiding this comment

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

s/simpleProgressWriter/newSimpleWriter/

// with RawJSONStream=false.
func newSimpleWriter(output io.Writer) io.Writer {
return newPushWriter(func(line progressLine) error {
if line.Stream != "" {
Copy link

Choose a reason for hiding this comment

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

len(line.Stream) > 0 and the same below

decoded := []progressLine{}
w := newPushWriter(func(line progressLine) error {
decoded = append(decoded, line)
if line.Error != "" {
Copy link

Choose a reason for hiding this comment

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

len(line.Error) > 0 and the same below

br, err := exutil.StartBuildAndWait(oc, "test")

g.By("checking that the resulting image has a digest")
o.Expect(br.Build.Status.Output.To.ImageDigest).To(o.HavePrefix("sha256:"))
Copy link

Choose a reason for hiding this comment

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

Can you also fetch the created image object by istag and match its name against the digest?

})

g.Describe("started with log level >5", func() {
g.It(fmt.Sprintf("should save the image digest when finished"), func() {
Copy link

Choose a reason for hiding this comment

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

All the It blocks differ in just few values. Could you make it a top-level parametrised function and call it from each sub-Describe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Huh, I even searched the ginkgo docs to see if it supports parametrized tests, missing the obvious solution completely /facepalm.

@mmilata mmilata force-pushed the store-digest branch 3 times, most recently from 339508e to 2630ae2 Compare January 18, 2017 15:06
@mmilata
Copy link
Contributor Author

mmilata commented Jan 18, 2017

@miminar thank you for the review. I've addressed the issues you found and pushed updated branch.

@bparees
Copy link
Contributor

bparees commented Jan 18, 2017

@openshift/api-review needs api approval to land for 3.5.

@mmilata
Copy link
Contributor Author

mmilata commented Jan 18, 2017

Flake #12341, #12479.

Copy link

@miminar miminar left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! Few amendments to string comparisons would make it perfect.

return reportPushFailure(err, authPresent, pushAuthConfig)
}
if digest != "" {
Copy link

Choose a reason for hiding this comment

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

bump :-)

return reportPushFailure(err, authPresent, pushAuthConfig)
}
if digest != "" {
Copy link

Choose a reason for hiding this comment

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

len()

Copy link
Contributor Author

@mmilata mmilata Jan 19, 2017

Choose a reason for hiding this comment

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

Fixed, thanks:)

git show | grep -c '^[+].*[!=]= ""'      
0

@mmilata
Copy link
Contributor Author

mmilata commented Jan 19, 2017

Flake #12479. [testextended][extended:core(builds)]

@smarterclayton
Copy link
Contributor

API approved.

@bparees
Copy link
Contributor

bparees commented Jan 19, 2017

extended test failure is a known flake but it's also in an area of code related to what's being changed here, so i'd like to see a clean run.

[testextended][extended:core(failure reason)]

@bparees
Copy link
Contributor

bparees commented Jan 19, 2017

seems like a consistent failure that needs to be investigated.

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 20, 2017
@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 0ea756b

@openshift-bot
Copy link
Contributor

Evaluated for origin testextended up to 0ea756b

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/13078/) (Base Commit: 1e269a3)

@mmilata
Copy link
Contributor Author

mmilata commented Jan 20, 2017

Flake #9414. Trying to reproduce the failing extended tests locally.

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/testextended SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin_extended/1006/) (Base Commit: 1e269a3) (Extended Tests: core(failure reason), core(builds))

@bparees
Copy link
Contributor

bparees commented Jan 20, 2017

flake #9414
[merge]

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 0ea756b

@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 20, 2017
@openshift-bot
Copy link
Contributor

openshift-bot commented Jan 20, 2017

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/13096/) (Base Commit: 8146e11) (Image: devenv-rhel7_5736)

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