Skip to content

Commit

Permalink
Merge pull request #1681 from FabianKramm/main
Browse files Browse the repository at this point in the history
fix: unhandled error in endpoints sync
  • Loading branch information
FabianKramm authored Apr 15, 2024
2 parents bcbfa01 + a6cfd8b commit 1971568
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions pkg/controllers/k8sdefaultendpoint/k8sdefaultendpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,9 @@ func (e *EndpointController) SetupWithManager(mgr ctrl.Manager) error {
WithOptions(controller.Options{
CacheSyncTimeout: constants.DefaultCacheSyncTimeout,
}).
For(&corev1.Endpoints{},
builder.WithPredicates(pfuncs, predicate.ResourceVersionChangedPredicate{})).
WatchesRawSource(source.Kind(e.VirtualManagerCache, &corev1.Endpoints{}),
&handler.EnqueueRequestForObject{}, builder.WithPredicates(vfuncs)).
WatchesRawSource(source.Kind(e.VirtualManagerCache, e.provider.createClientObject()),
&handler.EnqueueRequestForObject{}, builder.WithPredicates(vfuncs)).
For(&corev1.Endpoints{}, builder.WithPredicates(pfuncs)).
WatchesRawSource(source.Kind(e.VirtualManagerCache, &corev1.Endpoints{}), &handler.EnqueueRequestForObject{}, builder.WithPredicates(vfuncs)).
WatchesRawSource(source.Kind(e.VirtualManagerCache, e.provider.createClientObject()), &handler.EnqueueRequestForObject{}, builder.WithPredicates(vfuncs)).
Complete(e)
}

Expand All @@ -128,7 +125,6 @@ func (e *EndpointController) syncKubernetesServiceEndpoints(ctx context.Context,
Name: "kubernetes",
},
}

result, err := controllerutil.CreateOrPatch(ctx, virtualClient, vEndpoints, func() error {
if vEndpoints.Labels == nil {
vEndpoints.Labels = map[string]string{}
Expand Down Expand Up @@ -173,14 +169,14 @@ func (e *EndpointController) syncKubernetesServiceEndpoints(ctx context.Context,
return nil
})
if err != nil {
return nil
return fmt.Errorf("error patching endpoints: %w", err)
}

if result == controllerutil.OperationResultCreated || result == controllerutil.OperationResultUpdated {
return e.provider.createOrPatch(ctx, virtualClient, vEndpoints)
}

return err
return nil
}

// allAddressesIPv6 returns true if all provided addresses are IPv6.
Expand Down

0 comments on commit 1971568

Please sign in to comment.