Skip to content

Commit

Permalink
NVSHAS-9216:redistribute network policy when host id is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
gfsuse committed Dec 18, 2024
1 parent 7a10195 commit 167e7b8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions controller/cache/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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}
}
Expand Down Expand Up @@ -463,6 +464,9 @@ func addrHostAdd(id string, param interface{}) {
updateInternalIPNet(&ipnet, share.CLUSIPAddrScopeGlobal, false)
}
}
if hostchg {
scheduleIPPolicyCalculation(true)
}
}

// With cachMutex held
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit 167e7b8

Please sign in to comment.