Skip to content

Commit

Permalink
Merge pull request #869 from michaelcheungdk/main
Browse files Browse the repository at this point in the history
fix: strategic merge patch extend-resource for node status
  • Loading branch information
qmhu authored Oct 24, 2023
2 parents 726f91f + 2b35531 commit 34ad4a4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/resource/node_resource_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/json"
coreinformers "k8s.io/client-go/informers/core/v1"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes/scheme"
Expand Down Expand Up @@ -153,9 +153,13 @@ func (o *NodeResourceManager) UpdateNodeResource() {

resourcesFrom := o.BuildNodeStatus(nodeCopy)
if !equality.Semantic.DeepEqual(&node.Status, &nodeCopy.Status) {
// Update Node status extend-resource info
// TODO fix: strategic merge patch kubernetes
if _, err := o.client.CoreV1().Nodes().UpdateStatus(context.TODO(), nodeCopy, metav1.UpdateOptions{}); err != nil {
nodeCopyBytes, err := json.Marshal(nodeCopy)
if err != nil {
klog.Errorf("Failed to marshal node %s extended resource, %v", nodeCopy.Name, err)
return
}

if _, err = o.client.CoreV1().Nodes().PatchStatus(context.TODO(), node.Name, nodeCopyBytes); err != nil {
klog.Errorf("Failed to update node %s extended resource, %v", nodeCopy.Name, err)
return
}
Expand Down

0 comments on commit 34ad4a4

Please sign in to comment.