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

Use fnv.New32a() in hash instead adler32 #40297

Merged
merged 1 commit into from
Feb 15, 2017

Conversation

resouer
Copy link
Contributor

@resouer resouer commented Jan 23, 2017

Ref: #40140

Benchmark results: #39527

NOTE: I leave GetPodTemplateSpecHash as it is since we have unit test to test its un-normal behaviour.

@resouer resouer changed the title Fix hash Use fnv.New32a() in hash instead adler32 Jan 23, 2017
@k8s-reviewable
Copy link

This change is Reviewable

@k8s-github-robot k8s-github-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. release-note-label-needed labels Jan 23, 2017
@@ -315,7 +315,7 @@ func (dc *DeploymentController) getNewReplicaSet(deployment *extensions.Deployme

// new ReplicaSet does not exist, create one.
namespace := deployment.Namespace
podTemplateSpecHash := fmt.Sprintf("%d", deploymentutil.GetPodTemplateSpecHash(deployment.Spec.Template))
podTemplateSpecHash := fmt.Sprintf("%d", deploymentutil.GetPodTemplateSpecHashFnv(deployment.Spec.Template))
Copy link
Contributor

Choose a reason for hiding this comment

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

We can't make this change for Deployments without providing a way to migrate old replica sets. I have a WIP open for managing hash migration for Deployments: #38714

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack, I just left pkg/controller/deployment as it is and only update other files.

@@ -144,7 +144,7 @@ func BenchmarkAdler(b *testing.B) {
json.Unmarshal([]byte(podSpec), &spec)

for i := 0; i < b.N; i++ {
GetPodTemplateSpecHash(spec)
GetPodTemplateSpecHashFnv(spec)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is benchmarking adler so it should stay as is.

@resouer resouer assigned 0xmichalis and unassigned bprashanth Jan 24, 2017
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 24, 2017
@resouer resouer added release-note-none Denotes a PR that doesn't merit a release note. and removed release-note-label-needed labels Jan 24, 2017
@k8s-github-robot k8s-github-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 24, 2017
@0xmichalis
Copy link
Contributor

I am not sure if there are any backwards compatibility concerns for the changes in kubelet and the scheduler. @resouer can you assign the right people to review these changes?

@resouer
Copy link
Contributor Author

resouer commented Jan 25, 2017

Yes, I will include node & scheduler guys in.

@resouer
Copy link
Contributor Author

resouer commented Jan 25, 2017

@Random-Liu @wojtek-t Could you please help review if Is this update is safe from your side?

@@ -91,7 +91,7 @@ func ShouldContainerBeRestarted(container *v1.Container, pod *v1.Pod, podStatus
// HashContainer returns the hash of the container. It is used to compare
// the running container with its desired spec.
func HashContainer(container *v1.Container) uint64 {
hash := adler32.New()
hash := fnv.New32a()
Copy link
Member

Choose a reason for hiding this comment

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

IIUC, all containers will be restarted after kubelet live upgrade because of this, I'm not sure whether this is acceptable. At least we should document this.

Luckily we are going to rollout CRI this release, which also requires restarting container. :p

@yujuhong /cc @kubernetes/sig-node-pr-reviews

Copy link
Contributor

Choose a reason for hiding this comment

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

Users can opt-out CRI for this release, but they can't turn this off though. We should use the new hash for CRI, but the old adler for dockertools. This way, users who don't want to upgrade won't be affected, and new CRI users will get it anyway.

Copy link
Member

Choose a reason for hiding this comment

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

Agree. We can rollout the hash change with CRI, and keep the old users not being affected.

Copy link
Contributor

Choose a reason for hiding this comment

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

@resouer can you leave out the changes to files in pkg/kubelet. We'll handle it in a separate PR. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

Created a new PR for this: #40495

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank. I just updated this patch and left pkg/kubelet as is

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 26, 2017
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 28, 2017
@resouer
Copy link
Contributor Author

resouer commented Jan 28, 2017

@Kargakis sig-node has worked out #40495 for pkg/kubelet. And for scheduler part, I am sure this update does not break anything since equivalence cache is still WIP, see #36238

@0xmichalis
Copy link
Contributor

LGTM

@resouer
Copy link
Contributor Author

resouer commented Jan 30, 2017

Unit tests needs update, will push a new commit.

@@ -282,7 +282,7 @@ func readProcMounts(mountFilePath string, out *[]MountPoint) (uint32, error) {
}

func readProcMountsFrom(file io.Reader, out *[]MountPoint) (uint32, error) {
hash := adler32.New()
hash := fnv.New32a()
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess kubelet is using this utility. Mind explaining what's the impact of this change?

Copy link
Contributor Author

@resouer resouer Feb 6, 2017

Choose a reason for hiding this comment

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

This method is used in kubelet to make sure /proc/mounts is steady.

It reads contents of /proc/mounts for multiple times and hash all results to see if any difference happens. There's no cached value of this hash result and it will only be used to compare with the hash result from same method. So I assume it is safe to make this change.

See: https://github.com/kubernetes/kubernetes/blob/master/pkg/util/mount/mount_linux.go#L252-L271

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, thanks!

@timothysc timothysc removed their assignment Feb 1, 2017
@0xmichalis
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 6, 2017
@0xmichalis
Copy link
Contributor

0xmichalis commented Feb 6, 2017

Btw I have updated the "fixes #issue" in the starting post to a simple reference because that issue is not fixed once this PR merges.

@resouer
Copy link
Contributor Author

resouer commented Feb 14, 2017

ping @lavalamp @timothysc any time to approve this fix?

@timothysc
Copy link
Member

@Kargakis can you approve this one, it appears this issue is one of the bot-victims.

@0xmichalis
Copy link
Contributor

I am not in any of the OWNERS files from where approval is required for this one. Maybe test the bot?

/approve

@smarterclayton
Copy link
Contributor

/approve

@k8s-github-robot k8s-github-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Feb 14, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

The following people have approved this PR: kargakis, resouer, smarterclayton

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Feb 15, 2017
@resouer resouer added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 15, 2017
@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 40297, 41285, 41211, 41243, 39735)

@k8s-github-robot k8s-github-robot merged commit 438054f into kubernetes:master Feb 15, 2017
@resouer resouer deleted the fix-hash branch February 15, 2017 12:25
@k8s-ci-robot
Copy link
Contributor

@resouer: The following test(s) failed:

Test name Commit Details Rerun command
Jenkins verification 3bdc3f2 link @k8s-bot verify test this

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

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. release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet