-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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 PatchStatus to update node status in kubelet. #37871
Use PatchStatus to update node status in kubelet. #37871
Conversation
c82f2fa
to
6a8624c
Compare
@Random-Liu PATCH doesn't work for MERGING list of primitives, such as finalizers. Merging list should specify
The 2 you mentioned above are using replace patchStrategy. I believe PATCH should work for them by replacing the whole list. |
@ymqytw Thanks for confirmation! :) |
Jenkins kops AWS e2e failed for commit 6a8624c714090df7dd17c1d348a77e7cc17a2026. Full PR test history. The magic incantation to run this job again is |
Will update the PR to fix the unit test. |
6a8624c
to
6e53fff
Compare
Jenkins GCI GCE e2e failed for commit 6e53fffb69c30750d1579800a54c55cd2c4cc5f0. Full PR test history. The magic incantation to run this job again is |
Jenkins GCE e2e failed for commit 6e53fffb69c30750d1579800a54c55cd2c4cc5f0. Full PR test history. The magic incantation to run this job again is |
Jenkins CRI GCE Node e2e failed for commit 6e53fffb69c30750d1579800a54c55cd2c4cc5f0. Full PR test history. The magic incantation to run this job again is |
Jenkins GKE smoke e2e failed for commit 6e53fffb69c30750d1579800a54c55cd2c4cc5f0. Full PR test history. The magic incantation to run this job again is |
Jenkins GCE Node e2e failed for commit 6e53fffb69c30750d1579800a54c55cd2c4cc5f0. Full PR test history. The magic incantation to run this job again is |
Jenkins GCI GKE smoke e2e failed for commit 6e53fffb69c30750d1579800a54c55cd2c4cc5f0. Full PR test history. The magic incantation to run this job again is |
Jenkins Kubemark GCE e2e failed for commit 6e53fffb69c30750d1579800a54c55cd2c4cc5f0. Full PR test history. The magic incantation to run this job again is |
6e53fff
to
999af9e
Compare
@yujuhong Fixed the unit test. Please take a look. :) |
Jenkins verification failed for commit 999af9eea87fcd87e82f477c791e2fd22eea782b. Full PR test history. The magic incantation to run this job again is |
999af9e
to
f518abb
Compare
@k8s-bot gci gce e2e test this (job was accidentally deleted) |
@caesarxuchao, could you review the status update operation? Thanks! |
@@ -153,3 +154,27 @@ func SetNodeCondition(c clientset.Interface, node types.NodeName, condition v1.N | |||
_, err = c.Core().Nodes().PatchStatus(string(node), patch) | |||
return err | |||
} | |||
|
|||
// UpdateNodeStatus updates node status with PatchStatus. | |||
func UpdateNodeStatus(c clientset.Interface, nodeName types.NodeName, oldNode *v1.Node, newNode *v1.Node) (*v1.Node, error) { |
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.
Could you reset the NodeSpec and ObjectMeta before generating the patch? I have two concerns:
- objectMeta is updatable via the /status subresource. I don't know if Node has alpha status fields recorded in the annotation, if not, we'd better prevent updating ObjectMeta in this function
- Generating patch for unnecessary fields might lead to unnecessary conflicts, though the chance is low.
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.
What do you mean by reset
?
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.
Ha, I see. Just set the old one to new one. I see.
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.
Done
return nil, fmt.Errorf("failed to create patch for node %q: %v", nodeName, err) | ||
} | ||
|
||
updatedNode, err := c.Core().Nodes().PatchStatus(string(nodeName), patchBytes) |
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.
Could you switch to use the regular Patch() method? It supports specifying subresources now. We should deprecate the special PatchStatus() method.
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.
So now Patch
can update status, too?
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.
Yeah, you need to set the subreources
.
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.Node, err error)
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!
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.
Done
f518abb
to
05d0bfe
Compare
Jenkins unit/integration failed for commit 05d0bfe6754bcb0b0bd6fbe61dee3033628b0dab. Full PR test history. The magic incantation to run this job again is |
The unit test We could:
@caesarxuchao Which do you prefer? |
Offline discussed with @caesarxuchao, only reset
|
05d0bfe
to
309b66f
Compare
@caesarxuchao @yujuhong Addressed comments. Let's merge this PR after #38375 to avoid conflict during cherry-pick. |
Jenkins GCE etcd3 e2e failed for commit 309b66f16d107894680b7b7013481cb0d10bb1d7. Full PR test history. The magic incantation to run this job again is |
@k8s-bot gce etcd3 e2e test this |
309b66f
to
beba1eb
Compare
@caesarxuchao PR ready to go. |
/lgtm |
Automatic merge from submit-queue (batch tested with PRs 36692, 37871) |
Fixes #37771.
This PR changes kubelet to update node status with
PatchStatus
.@caesarxuchao @ymqytw told me that there is a limitation of current
CreateTwoWayMergePatch
, it doesn't support primitive type slice which uses strategic merge.ContainerImage.Names
VolumesInUse
CreateStrategicMergePath
to generate node status update patch, and till now everything is fine.@yujuhong @dchen1107
/cc @kubernetes/sig-node
This change is