Skip to content

Commit 9b127e6

Browse files
committed
Check DbRootPassword exist using VerifySecret()
Verification of the password secret should also check for the expected key (DbRootPassword) to exist. This changes this by using the secret.VerifySecret() func. Signed-off-by: Martin Schuppert <[email protected]>
1 parent 8c6251d commit 9b127e6

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

controllers/galera_controller.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,18 +539,32 @@ func (r *GaleraReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res
539539
clusterPropertiesEnv := make(map[string]env.Setter)
540540

541541
// Check and hash inputs
542-
secretName := instance.Spec.Secret
543542
// NOTE do not hash the db root password, as its change requires
544543
// more orchestration than a simple rolling restart
545-
_, _, err = secret.GetSecret(ctx, helper, secretName, instance.Namespace)
544+
_, res, err := secret.VerifySecret(
545+
ctx,
546+
types.NamespacedName{Namespace: instance.Namespace, Name: instance.Spec.Secret},
547+
[]string{
548+
"DbRootPassword",
549+
},
550+
helper.GetClient(),
551+
time.Duration(5)*time.Second)
546552
if err != nil {
553+
if k8s_errors.IsNotFound(err) {
554+
instance.Status.Conditions.Set(condition.FalseCondition(
555+
condition.InputReadyCondition,
556+
condition.RequestedReason,
557+
condition.SeverityInfo,
558+
condition.InputReadyWaitingMessage))
559+
return res, fmt.Errorf("OpenStack secret %s not found", instance.Spec.Secret)
560+
}
547561
instance.Status.Conditions.Set(condition.FalseCondition(
548562
condition.InputReadyCondition,
549563
condition.ErrorReason,
550564
condition.SeverityWarning,
551565
condition.InputReadyErrorMessage,
552566
err.Error()))
553-
return ctrl.Result{}, fmt.Errorf("error calculating input hash: %w", err)
567+
return ctrl.Result{}, err
554568
}
555569
instance.Status.Conditions.MarkTrue(condition.InputReadyCondition, condition.InputReadyMessage)
556570

0 commit comments

Comments
 (0)