Skip to content

Commit

Permalink
refactor: fix unhandled error
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianKramm committed Apr 15, 2024
1 parent bcbfa01 commit 775b93d
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 775b93d

Please sign in to comment.