Skip to content

Commit

Permalink
use subreconciler method to return error
Browse files Browse the repository at this point in the history
  • Loading branch information
sinamna committed Dec 12, 2023
1 parent 71c9964 commit 7186084
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions internal/controller/basic_authenticator/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (r *BasicAuthenticatorReconciler) Cleanup(ctx context.Context, req ctrl.Req
func (r *BasicAuthenticatorReconciler) setDeletionStatus(ctx context.Context, req ctrl.Request) (*ctrl.Result, error) {
basicAuthenticator := &v1alpha1.BasicAuthenticator{}
if r, err := r.getLatestBasicAuthenticator(ctx, req, basicAuthenticator); subreconciler.ShouldHaltOrRequeue(r, err) {
return r, err
return subreconciler.RequeueWithError(err)
}
basicAuthenticator.Status.State = StatusDeleting

Expand All @@ -46,7 +46,7 @@ func (r *BasicAuthenticatorReconciler) removeInjectedContainers(ctx context.Cont
basicAuthenticator := &v1alpha1.BasicAuthenticator{}

if r, err := r.getLatestBasicAuthenticator(ctx, req, basicAuthenticator); subreconciler.ShouldHaltOrRequeue(r, err) {
return r, err
return subreconciler.RequeueWithError(err)
}

if basicAuthenticator.Spec.Type != "sidecar" {
Expand Down Expand Up @@ -88,7 +88,7 @@ func (r *BasicAuthenticatorReconciler) removeInjectedContainers(ctx context.Cont
func (r *BasicAuthenticatorReconciler) removeCleanupFinalizer(ctx context.Context, req ctrl.Request) (*ctrl.Result, error) {
basicAuthenticator := &v1alpha1.BasicAuthenticator{}
if r, err := r.getLatestBasicAuthenticator(ctx, req, basicAuthenticator); subreconciler.ShouldHaltOrRequeue(r, err) {
return r, err
return subreconciler.RequeueWithError(err)
}
if controllerutil.ContainsFinalizer(basicAuthenticator, basicAuthenticatorFinalizer) {
if ok := controllerutil.RemoveFinalizer(basicAuthenticator, basicAuthenticatorFinalizer); !ok {
Expand Down
14 changes: 7 additions & 7 deletions internal/controller/basic_authenticator/provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (r *BasicAuthenticatorReconciler) setReconcilingStatus(ctx context.Context,
basicAuthenticator := &v1alpha1.BasicAuthenticator{}

if r, err := r.getLatestBasicAuthenticator(ctx, req, basicAuthenticator); subreconciler.ShouldHaltOrRequeue(r, err) {
return r, err
return subreconciler.RequeueWithError(err)
}

basicAuthenticator.Status.State = StatusReconciling
Expand All @@ -56,7 +56,7 @@ func (r *BasicAuthenticatorReconciler) addCleanupFinalizer(ctx context.Context,
basicAuthenticator := &v1alpha1.BasicAuthenticator{}

if r, err := r.getLatestBasicAuthenticator(ctx, req, basicAuthenticator); subreconciler.ShouldHaltOrRequeue(r, err) {
return r, err
return subreconciler.RequeueWithError(err)
}
if !controllerutil.ContainsFinalizer(basicAuthenticator, basicAuthenticatorFinalizer) {
if objUpdated := controllerutil.AddFinalizer(basicAuthenticator, basicAuthenticatorFinalizer); objUpdated {
Expand Down Expand Up @@ -86,7 +86,7 @@ func (r *BasicAuthenticatorReconciler) ensureSecret(ctx context.Context, req ctr
basicAuthenticator := &v1alpha1.BasicAuthenticator{}

if r, err := r.getLatestBasicAuthenticator(ctx, req, basicAuthenticator); subreconciler.ShouldHaltOrRequeue(r, err) {
return r, err
return subreconciler.RequeueWithError(err)
}
r.credentialName = basicAuthenticator.Spec.CredentialsSecretRef
var credentialSecret corev1.Secret
Expand Down Expand Up @@ -153,7 +153,7 @@ func (r *BasicAuthenticatorReconciler) ensureConfigmap(ctx context.Context, req
basicAuthenticator := &v1alpha1.BasicAuthenticator{}

if r, err := r.getLatestBasicAuthenticator(ctx, req, basicAuthenticator); subreconciler.ShouldHaltOrRequeue(r, err) {
return r, err
return subreconciler.RequeueWithError(err)
}

authenticatorConfig := createNginxConfigmap(basicAuthenticator)
Expand Down Expand Up @@ -195,7 +195,7 @@ func (r *BasicAuthenticatorReconciler) ensureDeployment(ctx context.Context, req
basicAuthenticator := &v1alpha1.BasicAuthenticator{}

if r, err := r.getLatestBasicAuthenticator(ctx, req, basicAuthenticator); subreconciler.ShouldHaltOrRequeue(r, err) {
return r, err
return subreconciler.RequeueWithError(err)
}

if r.configMapName == "" {
Expand All @@ -217,7 +217,7 @@ func (r *BasicAuthenticatorReconciler) ensureService(ctx context.Context, req ct
basicAuthenticator := &v1alpha1.BasicAuthenticator{}

if r, err := r.getLatestBasicAuthenticator(ctx, req, basicAuthenticator); subreconciler.ShouldHaltOrRequeue(r, err) {
return r, err
return subreconciler.RequeueWithError(err)
}
if r.deploymentLabel == nil {
return subreconciler.ContinueReconciling()
Expand Down Expand Up @@ -257,7 +257,7 @@ func (r *BasicAuthenticatorReconciler) setAvailableStatus(ctx context.Context, r
basicAuthenticator := &v1alpha1.BasicAuthenticator{}

if r, err := r.getLatestBasicAuthenticator(ctx, req, basicAuthenticator); subreconciler.ShouldHaltOrRequeue(r, err) {
return r, err
return subreconciler.RequeueWithError(err)
}

basicAuthenticator.Status.State = StatusAvailable
Expand Down

0 comments on commit 7186084

Please sign in to comment.