Skip to content

Commit

Permalink
fix(controller/subnet): controller crashes on subnets if gateway is u…
Browse files Browse the repository at this point in the history
…nspecified and netpol are disabled (#4848)

Signed-off-by: SkalaNetworks <[email protected]>
  • Loading branch information
SkalaNetworks authored and oilbeater committed Dec 24, 2024
1 parent 2cc515e commit 7bc30db
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions pkg/controller/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,16 @@ func (c *Controller) enqueueUpdateSubnet(oldObj, newObj interface{}) {
return
}

if newSubnet.Spec.Gateway != oldSubnet.Spec.Gateway ||
newSubnet.Status.U2OInterconnectionIP != oldSubnet.Status.U2OInterconnectionIP {
policies, err := c.npsLister.List(labels.Everything())
if err != nil {
klog.Errorf("failed to list network policies: %v", err)
} else {
for _, np := range policies {
c.enqueueAddNp(np)
// Trigger network policy refresh only if they are enabled, otherwise the lister will be nil
if c.npsLister != nil {
if newSubnet.Spec.Gateway != oldSubnet.Spec.Gateway || newSubnet.Status.U2OInterconnectionIP != oldSubnet.Status.U2OInterconnectionIP {
policies, err := c.npsLister.List(labels.Everything())
if err != nil {
klog.Errorf("failed to list network policies: %v", err)
} else {
for _, np := range policies {
c.enqueueAddNp(np)
}
}
}
}
Expand Down

0 comments on commit 7bc30db

Please sign in to comment.