diff --git a/pkg/resource/node_resource_manager.go b/pkg/resource/node_resource_manager.go index a60dcc4cc..130b3a5cb 100644 --- a/pkg/resource/node_resource_manager.go +++ b/pkg/resource/node_resource_manager.go @@ -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" @@ -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 }