Skip to content

Commit 752b7b2

Browse files
kyrtapzjcaamano
authored andcommitted
Check GetNADs length
There is a small chance that a network will not have any NADs. Ensure that this is covered. Signed-off-by: Patryk Diak <[email protected]>
1 parent 059e3c6 commit 752b7b2

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

go-controller/pkg/clustermanager/endpointslicemirror/endpointslice_mirror_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ func (c *Controller) mirrorEndpointSlice(mirroredEndpointSlice, defaultEndpointS
434434
}
435435
for i, endpoint := range defaultEndpointSlice.Endpoints {
436436
if endpoint.TargetRef != nil && endpoint.TargetRef.Kind == "Pod" {
437-
podIP, err := c.getPodIP(endpoint.TargetRef.Name, endpoint.TargetRef.Namespace, network.GetNADs()[0], isIPv6)
437+
podIP, err := c.getPodIP(endpoint.TargetRef.Name, endpoint.TargetRef.Namespace, nadList[0], isIPv6)
438438
if err != nil {
439439
return nil, fmt.Errorf("failed to determine the Pod IP of: %s/%s: %v", endpoint.TargetRef.Namespace, endpoint.TargetRef.Name, err)
440440
}

go-controller/pkg/clustermanager/routeadvertisements/controller.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,10 @@ func (c *Controller) ReconcileNetwork(_ string, old, new util.NetInfo) {
222222
}
223223
if new != nil && !newNamespaces.Equal(oldNamespaces) {
224224
// we use one of the NADs of the network to reconcile it
225-
c.nadController.Reconcile(new.GetNADs()[0])
225+
nads := new.GetNADs()
226+
if len(nads) > 0 {
227+
c.nadController.Reconcile(nads[0])
228+
}
226229
// if the namespaces served by a network changed, it is possible that
227230
// those namespaces are served or no longer served by the default
228231
// network, so reconcile it as well

0 commit comments

Comments
 (0)