From e587dc506a7207fe7eb4e333cf614a0b901a6e37 Mon Sep 17 00:00:00 2001 From: Chethan Venkatesh Date: Wed, 29 Jan 2020 15:22:12 -0800 Subject: [PATCH] Invoke node Update only for providerID changes --- pkg/csi/service/cns/nodes.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pkg/csi/service/cns/nodes.go b/pkg/csi/service/cns/nodes.go index abcc16da75..78ceead0c9 100644 --- a/pkg/csi/service/cns/nodes.go +++ b/pkg/csi/service/cns/nodes.go @@ -58,7 +58,20 @@ func (nodes *Nodes) nodeAdd(obj interface{}) { } func (nodes *Nodes) nodeUpdate(oldObj interface{}, newObj interface{}) { - nodes.nodeRegister(newObj) + newNode, ok := newObj.(*v1.Node) + if !ok { + klog.Warningf("nodeUpdate: unrecognized object newObj %[1]T%+[1]v", newObj) + return + } + oldNode, ok := oldObj.(*v1.Node) + if !ok { + klog.Warningf("nodeUpdate: unrecognized object oldObj %[1]T%+[1]v", oldObj) + return + } + if oldNode.Spec.ProviderID != newNode.Spec.ProviderID { + klog.V(2).Infof("nodeUpdate: Observed ProviderID change from %q to %q for the node: %q", oldNode.Spec.ProviderID, newNode.Spec.ProviderID, newNode.Name) + nodes.nodeRegister(newObj) + } } func (nodes *Nodes) nodeRegister(obj interface{}) {