Skip to content

Commit

Permalink
fix panic in service mirror controller (linkerd#12406)
Browse files Browse the repository at this point in the history
If the service mirror controller encounters an error listing mirror services during endpoints repair, this error is logged but processing continues.  This causes a nil pointer dereference which results in a panic.

Instead, we abort the endpoints repair with a retryable error so that the repair endpoints event is re-enqueued and the panic is avoided.

Signed-off-by: Alex Leong <alex@buoyant.io>
Signed-off-by: Mark S <the@wondersmith.dev>
  • Loading branch information
adleong authored and the-wondersmith committed Apr 24, 2024
1 parent 33af94b commit 6ff550b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion multicluster/service-mirror/cluster_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ func (rcsw *RemoteClusterServiceWatcher) repairEndpoints(ctx context.Context) er
// Repair mirror service endpoints.
mirrorServices, err := rcsw.getMirrorServices()
if err != nil {
rcsw.log.Errorf("Failed to list mirror services: %s", err)
return RetryableError{[]error{fmt.Errorf("Failed to list mirror services: %w", err)}}
}
for _, svc := range mirrorServices.Items {
svc := svc
Expand All @@ -1057,6 +1057,7 @@ func (rcsw *RemoteClusterServiceWatcher) repairEndpoints(ctx context.Context) er
endpoints, err = rcsw.localAPIClient.Client.CoreV1().Endpoints(svc.Namespace).Get(ctx, svc.Name, metav1.GetOptions{})
if err != nil {
rcsw.log.Errorf("Failed to get local endpoints %s/%s: %s", svc.Namespace, svc.Name, err)
continue
}
}
updatedEndpoints := endpoints.DeepCopy()
Expand Down

0 comments on commit 6ff550b

Please sign in to comment.