From 167e7b88101c3a5018babe4b4529810cdfa00861 Mon Sep 17 00:00:00 2001 From: gfsuse Date: Tue, 17 Dec 2024 16:15:52 -0500 Subject: [PATCH] NVSHAS-9216:redistribute network policy when host id is changed --- controller/cache/object.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/controller/cache/object.go b/controller/cache/object.go index eac47919..b275cec2 100644 --- a/controller/cache/object.go +++ b/controller/cache/object.go @@ -420,7 +420,7 @@ func getWorkloadDisplayName(wl *share.CLUSWorkload, parent string) (string, stri // With cachMutex held func addrHostAdd(id string, param interface{}) { host := param.(*hostCache).host - + hostchg := false // Update Host_ip-to-Host map for _, addrs := range host.Ifaces { for _, addr := range addrs { @@ -433,6 +433,7 @@ func addrHostAdd(id string, param interface{}) { hp.hostID = host.ID hp.ipnet = addr.IPNet hp.managed = true + hostchg = true } else { ipHostMap[key] = &hostDigest{hostID: host.ID, ipnet: addr.IPNet, managed: true} } @@ -463,6 +464,9 @@ func addrHostAdd(id string, param interface{}) { updateInternalIPNet(&ipnet, share.CLUSIPAddrScopeGlobal, false) } } + if hostchg { + scheduleIPPolicyCalculation(true) + } } // With cachMutex held @@ -1397,10 +1401,11 @@ func workloadUpdate(nType cluster.ClusterNotifyType, key string, value []byte) { oldSvc := wlCache.workload.Service if !reflect.DeepEqual(wlCache.workload.Ifaces, wl.Ifaces) || - !reflect.DeepEqual(wlCache.workload.Ports, wl.Ports) { + !reflect.DeepEqual(wlCache.workload.Ports, wl.Ports) || + wlCache.workload.HostID != wl.HostID { log.WithFields(log.Fields{ "workload": container.ShortContainerId(wl.ID), - }).Debug("intf/ports changed") + }).Debug("intf/ports/host changed") defer scheduleIPPolicyCalculation(true) }