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 67c9af8 commit 26224c5
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 @@ -70,14 +70,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 26224c5

Please sign in to comment.