Skip to content

Commit efdfc04

Browse files
authored
Merge pull request #595 from dougbtv/node-slice-controller-fix-missing-ranges
node slice controller should only process valid whereabouts configs
2 parents a18f177 + c903949 commit efdfc04

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

pkg/node-controller/controller.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package node_controller
22

33
import (
44
"context"
5+
nativeerrors "errors"
56
"fmt"
67
"sort"
78
"time"
@@ -271,6 +272,10 @@ func (c *Controller) processNextWorkItem(ctx context.Context) bool {
271272
// Foo resource to be synced.
272273
if err := c.syncHandler(ctx, key); err != nil {
273274
// Put the item back on the workqueue to handle any transient errors.
275+
if nativeerrors.Is(err, types.ErrNoIPRanges) {
276+
logger.Info(fmt.Sprintf("Ignoring net-attach-def with no IP ranges '%s': %s", key, err.Error()))
277+
return nil // Don't requeue
278+
}
274279
c.workqueue.AddRateLimited(key)
275280
return fmt.Errorf("error syncing '%s': %s, requeuing", key, err.Error())
276281
}
@@ -505,6 +510,11 @@ func (c *Controller) checkForMultiNadMismatch(name, namespace string) error {
505510
return err
506511
}
507512

513+
// We need a valid IPAM configuration for comparison.
514+
if len(ipamConf.IPRanges) == 0 {
515+
return fmt.Errorf("%w: %s/%s", types.ErrNoIPRanges, namespace, name)
516+
}
517+
508518
nadList, err := c.nadLister.List(labels.Everything())
509519
if err != nil {
510520
return err
@@ -514,6 +524,11 @@ func (c *Controller) checkForMultiNadMismatch(name, namespace string) error {
514524
if err != nil {
515525
return err
516526
}
527+
528+
if len(additionalIpamConf.IPRanges) == 0 {
529+
continue // skip this net-attach-def, it has no ranges
530+
}
531+
517532
if !checkIpamConfMatch(ipamConf, additionalIpamConf) {
518533
return fmt.Errorf("found IPAM conf mismatch for network-attachment-definitions with same network name")
519534
}

pkg/types/types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package types
22

33
import (
44
"encoding/json"
5+
"errors"
56
"fmt"
67
"net"
78
"time"
@@ -205,3 +206,5 @@ const (
205206
// Deallocate operation identifier
206207
Deallocate = 1
207208
)
209+
210+
var ErrNoIPRanges = errors.New("no IP ranges in whereabouts config")

0 commit comments

Comments
 (0)