-
Notifications
You must be signed in to change notification settings - Fork 38.6k
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
Conversation
pkg/controller/deployment/sync.go
Outdated
@@ -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)) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
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? |
Yes, I will include node & scheduler guys in. |
@Random-Liu @wojtek-t Could you please help review if Is this update is safe from your side? |
pkg/kubelet/container/helpers.go
Outdated
@@ -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() |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
LGTM |
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() |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks!
/lgtm |
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. |
ping @lavalamp @timothysc any time to approve this fix? |
@Kargakis can you approve this one, it appears this issue is one of the bot-victims. |
I am not in any of the OWNERS files from where approval is required for this one. Maybe test the bot? /approve |
/approve |
[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 |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue (batch tested with PRs 40297, 41285, 41211, 41243, 39735) |
@resouer: The following test(s) failed:
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. |
Ref: #40140
Benchmark results: #39527
NOTE: I leave
GetPodTemplateSpecHash
as it is since we have unit test to test its un-normal behaviour.