Skip to content

Commit 3f63a4f

Browse files
authored
Ignore NotFound errors when deleting the passwords secret in the reconcile loop (#229)
1 parent f4dfbb8 commit 3f63a4f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

controllers/postgres_controller.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,12 @@ func (r *PostgresReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
119119
r.recorder.Eventf(instance, "Warning", "Error", "failed to uninstall operator: %v", err)
120120
return ctrl.Result{}, fmt.Errorf("error while uninstalling operator: %w", err)
121121
}
122+
log.Info("corresponding operator deleted")
122123

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

127129
instance.RemoveFinalizer(pg.PostgresFinalizerName)
128130
if err := r.CtrlClient.Update(ctx, instance); err != nil {
@@ -241,7 +243,7 @@ func (r *PostgresReconciler) deleteUserPasswordsSecret(ctx context.Context, inst
241243
secret := &corev1.Secret{}
242244
secret.Namespace = instance.Namespace
243245
secret.Name = instance.ToUserPasswordsSecretName()
244-
if err := r.CtrlClient.Delete(ctx, secret); err != nil {
246+
if err := r.CtrlClient.Delete(ctx, secret); client.IgnoreNotFound(err) != nil {
245247
msgWithFormat := "failed to delete user passwords secret: %w"
246248
r.recorder.Eventf(instance, "Warning", "Error", msgWithFormat, err)
247249
return fmt.Errorf(msgWithFormat, err)

controllers/suite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import (
4242
const (
4343
// duration = time.Second * 10
4444
interval = time.Second * 2
45-
timeout = time.Second * 30
45+
timeout = time.Second * 60
4646
)
4747

4848
var (

0 commit comments

Comments
 (0)