@@ -338,38 +338,32 @@ func (r *OctaviaReconciler) reconcileInit(
338338 //
339339 // check for required OpenStack secret holding passwords for service/admin user and add hash to the vars map
340340 //
341- ospSecretHash , result , err := oko_secret .VerifySecret (
341+ // Associate to PasswordSelectors.Service field a password validator to
342+ // ensure pwd invalid detected patterns are rejected.
343+ validateFields := map [string ]oko_secret.Validator {
344+ instance .Spec .PasswordSelectors .Service : oko_secret.PasswordValidator {},
345+ }
346+ ospSecretHash , result , err := oko_secret .VerifySecretFields (
342347 ctx ,
343- types.NamespacedName {Namespace : instance .Namespace , Name : instance .Spec .Secret },
344- []string {instance .Spec .PasswordSelectors .Service },
348+ types.NamespacedName {
349+ Namespace : instance .Namespace ,
350+ Name : instance .Spec .Secret ,
351+ },
352+ validateFields ,
345353 helper .GetClient (),
346354 time .Duration (10 )* time .Second ,
347355 )
348-
349356 if err != nil {
350- if k8s_errors .IsNotFound (err ) {
351- // Since the OpenStack secret should have been manually created by the user and referenced in the spec,
352- // we treat this as a warning because it means that the service will not be able to start.
353- Log .Info (fmt .Sprintf ("OpenStack secret %s not found" , instance .Spec .Secret ))
354- instance .Status .Conditions .Set (condition .FalseCondition (
355- condition .InputReadyCondition ,
356- condition .ErrorReason ,
357- condition .SeverityWarning ,
358- condition .InputReadyWaitingMessage ))
359- return ctrl.Result {RequeueAfter : time .Second * 10 }, nil
360- }
361357 instance .Status .Conditions .Set (condition .FalseCondition (
362358 condition .InputReadyCondition ,
363359 condition .ErrorReason ,
364360 condition .SeverityWarning ,
365361 condition .InputReadyErrorMessage ,
366362 err .Error ()))
367- return ctrl. Result {} , err
363+ return result , err
368364 } else if (result != ctrl.Result {}) {
369- // We can only get here if the secret is not found, thus we treat this the same
370- // as we do above if there was an actual "not found" error returned.
371- // See https://github.com/openstack-k8s-operators/lib-common/blob/4c240245107747327c5f67256f8d9d76cdd25c7a/modules/common/secret/secret.go#L423-L428
372- // for further details.
365+ // Since the OpenStack secret should have been manually created by the user and referenced in the spec,
366+ // we treat this as a warning because it means that the service will not be able to start.
373367 instance .Status .Conditions .Set (condition .FalseCondition (
374368 condition .InputReadyCondition ,
375369 condition .ErrorReason ,
@@ -379,10 +373,16 @@ func (r *OctaviaReconciler) reconcileInit(
379373 }
380374 secretsVars [instance .Spec .Secret ] = env .SetValue (ospSecretHash )
381375
382- transportURLSecretHash , result , err := oko_secret .VerifySecret (
376+ // transportURLFields are not pure password fields. We do not associate a
377+ // password validator and we only verify that the entry exists in the
378+ // secret
379+ transportValidateFields := map [string ]oko_secret.Validator {
380+ "transport_url" : oko_secret.NoOpValidator {},
381+ }
382+ transportURLSecretHash , result , err := oko_secret .VerifySecretFields (
383383 ctx ,
384384 types.NamespacedName {Namespace : instance .Namespace , Name : instance .Status .TransportURLSecret },
385- [] string { "transport_url" } ,
385+ transportValidateFields ,
386386 helper .GetClient (),
387387 time .Duration (10 )* time .Second ,
388388 )
0 commit comments