Skip to content

Conversation

@cgwalters
Copy link
Member

This is a lowering of
openshift/machine-config-operator#463
to pivot. We need it for the case of doing an early pivot
before the MCD comes up.

@openshift-ci-robot openshift-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 8, 2019
@cgwalters
Copy link
Member Author

This is failing for me with:

F0308 12:54:37.000370   12936 root.go:136] parsing current osImageURL: parsing reference: "exampleregistry/redhat-coreos/maipo@sha256:c09f455cc09673a1a13ae7b54cc4348cda0411e06dfa79ecd0130b35d62e8670": unsupported digest algorithm

Which um...what? This must be something with github.com/opencontainers/go-digest...it looks like the algorithms are package-scoped variables. But why is it failing?

@jlebon
Copy link
Member

jlebon commented Mar 8, 2019

This looks good overall! Would be nice to also directly edit the origin so the custom string points to the new image. Basically reframe this not as a special case, but just following through with the operation and being smart about not rebooting like we currently do. Not essential right now though if we're going for a tactical fix.

if previousPivot == imgid {
targetMatched, err := compareOSImageURL(previousPivot, imgid)
if err != nil {
glog.Fatalf("%v", err)
Copy link
Member

Choose a reason for hiding this comment

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

Minor: we pretty liberally use glog.Fatalf everywhere in this codebase. And since we're not actually adding any context here, I'd say just drop error-handling and Fatalf directly in getRefDigest().

Copy link
Member Author

Choose a reason for hiding this comment

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

It feels easier to keep the code looking similar to the MCD code - why change it unnecessarily, plus while I get the policy of using Fatalf where it's convenient, why change working code to stop using "proper" error handling?

Copy link
Member

Choose a reason for hiding this comment

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

why change working code to stop using "proper" error handling?

To keep it consistent with the rest of the whole codebase. Not strongly opposed though, just seems out of place. Keeping in sync with the MCD version is a good point though. Maybe add a comment about that?

@cgwalters cgwalters force-pushed the no-pivot-identical branch 2 times, most recently from ca0909a to cc36276 Compare March 8, 2019 15:44
@cgwalters
Copy link
Member Author

Added a test, now banging my head against:

$ go test ./cmd/...
/tmp/go-build756046464/b001/cmd.test flag redefined: log_dir
panic: /tmp/go-build756046464/b001/cmd.test flag redefined: log_dir

goroutine 1 [running]:
flag.(*FlagSet).Var(0xc00006a180, 0x670f20, 0xc000056660, 0x639cb8, 0x7, 0x644aa5, 0x2f)
        /usr/lib/golang/src/flag/flag.go:805 +0x529
flag.(*FlagSet).StringVar(0xc00006a180, 0xc000056660, 0x639cb8, 0x7, 0x0, 0x0, 0x644aa5, 0x2f)
        /usr/lib/golang/src/flag/flag.go:708 +0x8a
flag.(*FlagSet).String(0xc00006a180, 0x639cb8, 0x7, 0x0, 0x0, 0x644aa5, 0x2f, 0xc000056650)
        /usr/lib/golang/src/flag/flag.go:721 +0x8b
flag.String(0x639cb8, 0x7, 0x0, 0x0, 0x644aa5, 0x2f, 0xc00007e210)
        /usr/lib/golang/src/flag/flag.go:728 +0x69
FAIL    github/openshift/pivot/cmd      0.005s

@cgwalters
Copy link
Member Author

https://stackoverflow.com/questions/37284423/glog-flag-redefined-error apparently...man Golang vendor/ stuff is a huge mess in comparison to Cargo.

@jlebon
Copy link
Member

jlebon commented Mar 8, 2019

Hmm, go test working OK here (though seems like one of the tests is failing):

$ go test ./cmd/...
--- FAIL: TestCompareOSImageURL (0.00s)
    root_test.go:17: Expected refA = refB
FAIL
FAIL    github.com/openshift/pivot/cmd  0.006s

@cgwalters cgwalters force-pushed the no-pivot-identical branch from cc36276 to f91621d Compare March 8, 2019 16:20
@jlebon
Copy link
Member

jlebon commented Mar 8, 2019

Is your setup similar to this:

$ echo $GOPATH
/code/go
$ pwd
/code/go/src/github.com/openshift/pivot

(Similar -> pwd is $GOPATH + src/github.com/openshift/pivot)

@cgwalters
Copy link
Member Author

OK yeah, no idea what was going on before. I just pushed a tweak so that we display errors, now I get:

$ go test -v ./cmd/...
=== RUN   TestCompareOSImageURL
--- FAIL: TestCompareOSImageURL (0.00s)
    root_test.go:10: parsing current osImageURL: parsing reference: "registry.example.com/foo/bar@sha256:0743a3cc3bcf3b4aabb814500c2739f84cb085ff4e7ec7996aef7977c4c19c7f": unsupported digest algorithm
FAIL
FAIL    github/openshift/pivot/cmd      0.005s

@cgwalters
Copy link
Member Author

OK so apparently
https://golang.org/pkg/crypto/#Hash.Available is returning false for crypto.SHA256...

@cgwalters cgwalters force-pushed the no-pivot-identical branch from 3bd36df to b26b9e1 Compare March 8, 2019 19:19
@cgwalters
Copy link
Member Author

https://golang.org/pkg/crypto/#Hash.Available is returning false for crypto.SHA256...

And import ("crypto/sha256") fixes this...then to avoid unused imports errors I had to add a dummy sha256 usage. If this (or a better way to do it) is documented at all anywhere I can't find it.

@cgwalters cgwalters force-pushed the no-pivot-identical branch from b26b9e1 to 4a065e8 Compare March 8, 2019 19:48
@ashcrow
Copy link
Member

ashcrow commented Mar 8, 2019

man Golang vendor/ stuff is a huge mess in comparison to Cargo.

Yeah, it really is.

@cgwalters cgwalters force-pushed the no-pivot-identical branch from 4a065e8 to e0e0317 Compare March 11, 2019 16:23
@cgwalters cgwalters changed the title WIP: Don't pivot if identical sha256 Don't pivot if identical sha256 Mar 11, 2019
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 11, 2019
This is a lowering of
openshift/machine-config-operator#463
to pivot.  We need it for the case of doing an early pivot
before the MCD comes up.
@cgwalters cgwalters force-pushed the no-pivot-identical branch from e0e0317 to 71d6d77 Compare March 11, 2019 17:17
@cgwalters
Copy link
Member Author

Rebased, though one open discussion.

@cgwalters
Copy link
Member Author

Let's get this shipped please?

@ashcrow
Copy link
Member

ashcrow commented Mar 11, 2019

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 11, 2019
@ashcrow ashcrow merged commit 297a0ec into openshift:master Mar 11, 2019
@ashcrow
Copy link
Member

ashcrow commented Mar 11, 2019

/cc @yuqi-zhang for syncing over

@openshift-ci-robot
Copy link

@ashcrow: GitHub didn't allow me to request PR reviews from the following users: syncing, over, for.

Note that only openshift members and repo collaborators can review this PR, and authors cannot review their own PRs.

Details

In response to this:

/cc @yuqi-zhang for syncing over

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

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

Labels

lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants