Skip to content

Commit c0d6c4e

Browse files
openshift-merge-bot[bot]hjensas
authored andcommitted
Merge pull request openstack-k8s-operators#570 from mumesan/get_secrets_to_hash_OSPRH-10696
Get secrets to hash for api and conductor pods <JIRA: OSPRH-10696>
1 parent 9a8386e commit c0d6c4e

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

controllers/ironicapi_controller.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,37 @@ func (r *IronicAPIReconciler) reconcileNormal(ctx context.Context, instance *iro
659659
// ConfigMap
660660
configMapVars := make(map[string]env.Setter)
661661

662+
// Get secrets by Namespace and Label that we need to hash
663+
labelSelectorMap := map[string]string{}
664+
lbl := labels.GetOwnerNameLabelSelector(labels.GetGroupLabel(ironic.ServiceName))
665+
labelSelectorMap[lbl] = ironicv1.GetOwningIronicName(instance)
666+
secrets, err := secret.GetSecrets(ctx, helper, instance.Namespace, labelSelectorMap)
667+
if err != nil {
668+
Log.Info(fmt.Sprintf("No secrets with label %s found", lbl))
669+
} else {
670+
for _, s := range secrets.Items {
671+
hash, err := secret.Hash(&s)
672+
if err != nil {
673+
if k8s_errors.IsNotFound(err) {
674+
Log.Info(fmt.Sprintf("OpenStack secret %s not found", instance.Spec.Secret))
675+
instance.Status.Conditions.Set(condition.FalseCondition(
676+
condition.InputReadyCondition,
677+
condition.RequestedReason,
678+
condition.SeverityInfo,
679+
condition.InputReadyWaitingMessage))
680+
return ctrl.Result{RequeueAfter: time.Second * 10}, nil
681+
}
682+
instance.Status.Conditions.Set(condition.FalseCondition(
683+
condition.InputReadyCondition,
684+
condition.ErrorReason,
685+
condition.SeverityWarning,
686+
condition.InputReadyErrorMessage,
687+
err.Error()))
688+
return ctrl.Result{}, err
689+
}
690+
configMapVars[s.Name] = env.SetValue(hash)
691+
}
692+
}
662693
//
663694
// check for required OpenStack secret holding passwords for service/admin user and add hash to the vars map
664695
//

controllers/ironicconductor_controller.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,37 @@ func (r *IronicConductorReconciler) reconcileNormal(ctx context.Context, instanc
497497
// ConfigMap
498498
configMapVars := make(map[string]env.Setter)
499499

500+
// Get secrets by Namespace and Label that we need to hash
501+
labelSelectorMap := map[string]string{}
502+
lbl := labels.GetOwnerNameLabelSelector(labels.GetGroupLabel(ironic.ServiceName))
503+
labelSelectorMap[lbl] = ironicv1.GetOwningIronicName(instance)
504+
secrets, err := secret.GetSecrets(ctx, helper, instance.Namespace, labelSelectorMap)
505+
if err != nil {
506+
Log.Info(fmt.Sprintf("No secrets with label %s found", lbl))
507+
} else {
508+
for _, s := range secrets.Items {
509+
hash, err := secret.Hash(&s)
510+
if err != nil {
511+
if k8s_errors.IsNotFound(err) {
512+
Log.Info(fmt.Sprintf("OpenStack secret %s not found", instance.Spec.Secret))
513+
instance.Status.Conditions.Set(condition.FalseCondition(
514+
condition.InputReadyCondition,
515+
condition.RequestedReason,
516+
condition.SeverityInfo,
517+
condition.InputReadyWaitingMessage))
518+
return ctrl.Result{RequeueAfter: time.Second * 10}, nil
519+
}
520+
instance.Status.Conditions.Set(condition.FalseCondition(
521+
condition.InputReadyCondition,
522+
condition.ErrorReason,
523+
condition.SeverityWarning,
524+
condition.InputReadyErrorMessage,
525+
err.Error()))
526+
return ctrl.Result{}, err
527+
}
528+
configMapVars[s.Name] = env.SetValue(hash)
529+
}
530+
}
500531
//
501532
// check for required OpenStack secret holding passwords for service/admin user and add hash to the vars map
502533
//

0 commit comments

Comments
 (0)