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

Improve channel updates #7133

Conversation

granular-ryanbonham
Copy link
Contributor

Improve channel updates to use hash of manifests to ensure we always update.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 11, 2019
@mikesplain
Copy link
Contributor

Cleanup of #6829

@granular-ryanbonham
Copy link
Contributor Author

/assign @justinsb

}

name := b.cluster.ObjectMeta.Name + "-addons-bootstrap"
// manifestURL, err := a.GetManifestFullUrl()
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to leave the commented out section here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, good catch. I cleaned that up.

manifestHash, err := utils.HashString(&rawManifest)
klog.V(4).Infof("hash %s", manifestHash)
if err != nil {
manifestHash = ""
Copy link
Member

Choose a reason for hiding this comment

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

Typically a good idea to warn if there's any error we're ignoring. I'd probably return error here, as we should always be able to hash a string!

// HashString Takes String and returns a sha1 hash represented as a string
func HashString(s *string) (string, error) {
h := sha1.New()
ts := strings.TrimSpace(*s)
Copy link
Member

Choose a reason for hiding this comment

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

Trimming the string probably belongs in the caller, not a generic HashString function

)

// HashString Takes String and returns a sha1 hash represented as a string
func HashString(s *string) (string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

We probably shouldn't take a string pointer - it's a ref type anyway, and we can't pass nil

if err != nil {
return "", err
}
sha := h.Sum(nil) // "sha" is uint8 type, encoded in base16
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I think the type is [20]byte, actually

@justinsb
Copy link
Member

Looks great - thanks @granular-ryanbonham !

/approve
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 19, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: granular-ryanbonham, justinsb

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 19, 2019
@justinsb
Copy link
Member

I'm going to create a target to fix the golden output, as now we have hashes the golden output is going to change even more often!

@justinsb
Copy link
Member

Needs a rebase and a run of the new streamlined script in #7291

(It's a one-liner, so you can also just run it!)

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 19, 2019
@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@justinsb justinsb force-pushed the squash_improve_channel_updates branch from 48773a1 to 438a651 Compare July 22, 2019 14:30
The update-hash script didn't update gobindata; will fix that separately.
@justinsb justinsb force-pushed the squash_improve_channel_updates branch from 438a651 to cd0075d Compare July 22, 2019 16:59
@justinsb justinsb added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 22, 2019
@k8s-ci-robot k8s-ci-robot merged commit d961f98 into kubernetes:master Jul 22, 2019
k8s-ci-robot added a commit that referenced this pull request Jul 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants