Skip to content

Commit

Permalink
Ignore NotFound errors when deleting the passwords secret in the reco…
Browse files Browse the repository at this point in the history
…ncile loop (#229)
  • Loading branch information
eberlep authored Jun 17, 2021
1 parent f4dfbb8 commit 3f63a4f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion controllers/postgres_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,12 @@ func (r *PostgresReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
r.recorder.Eventf(instance, "Warning", "Error", "failed to uninstall operator: %v", err)
return ctrl.Result{}, fmt.Errorf("error while uninstalling operator: %w", err)
}
log.Info("corresponding operator deleted")

if err := r.deleteUserPasswordsSecret(ctx, instance); err != nil {
return ctrl.Result{}, err
}
log.Info("corresponding passwords secret deleted")

instance.RemoveFinalizer(pg.PostgresFinalizerName)
if err := r.CtrlClient.Update(ctx, instance); err != nil {
Expand Down Expand Up @@ -241,7 +243,7 @@ func (r *PostgresReconciler) deleteUserPasswordsSecret(ctx context.Context, inst
secret := &corev1.Secret{}
secret.Namespace = instance.Namespace
secret.Name = instance.ToUserPasswordsSecretName()
if err := r.CtrlClient.Delete(ctx, secret); err != nil {
if err := r.CtrlClient.Delete(ctx, secret); client.IgnoreNotFound(err) != nil {
msgWithFormat := "failed to delete user passwords secret: %w"
r.recorder.Eventf(instance, "Warning", "Error", msgWithFormat, err)
return fmt.Errorf(msgWithFormat, err)
Expand Down
2 changes: 1 addition & 1 deletion controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (
const (
// duration = time.Second * 10
interval = time.Second * 2
timeout = time.Second * 30
timeout = time.Second * 60
)

var (
Expand Down

0 comments on commit 3f63a4f

Please sign in to comment.