Skip to content

Commit 470504a

Browse files
committed
refactor(kubeclient): clarify patchable node fields
Name and document the projection as an explicit allowlist for Node patch generation. Signed-off-by: Ajay Mishra <ajmishra@nvidia.com>
1 parent e0485c4 commit 470504a

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

commons/pkg/kubeclient/nodepatch.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ func isRetryableNodePatchError(err error) bool {
168168
// Taints are emitted only when the caller changed them. A projected Node whose Spec
169169
// is empty on both sides therefore cannot erase taints from the real object.
170170
func NodeMergePatch(original, modified *v1.Node) ([]byte, error) {
171-
originalProjection := nodePatchProjection(original)
172-
modifiedProjection := nodePatchProjection(modified)
171+
originalProjection := projectNodePatchableFields(original)
172+
modifiedProjection := projectNodePatchableFields(modified)
173173

174174
specChanged := !reflect.DeepEqual(original.Spec.Taints, modified.Spec.Taints) ||
175175
original.Spec.Unschedulable != modified.Spec.Unschedulable
@@ -201,7 +201,9 @@ func NodeMergePatch(original, modified *v1.Node) ([]byte, error) {
201201
return patch, nil
202202
}
203203

204-
func nodePatchProjection(node *v1.Node) *v1.Node {
204+
// projectNodePatchableFields restricts patch generation to the Node fields this
205+
// helper intentionally supports, preventing callbacks from patching unrelated fields.
206+
func projectNodePatchableFields(node *v1.Node) *v1.Node {
205207
return &v1.Node{
206208
ObjectMeta: metav1.ObjectMeta{
207209
Labels: node.Labels,

0 commit comments

Comments
 (0)