Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continuation pr145 #164

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions controllers/barbicankeystonelistener_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,31 +178,32 @@ func (r *BarbicanKeystoneListenerReconciler) getSecret(
h *helper.Helper,
instance *barbicanv1beta1.BarbicanKeystoneListener,
secretName string,
expectedFields []string,
envVars *map[string]env.Setter,
) (ctrl.Result, error) {
secret, hash, err := secret.GetSecret(ctx, h, secretName, instance.Namespace)
Log := r.GetLogger(ctx)
hash, result, err := secret.VerifySecret(ctx, types.NamespacedName{Name: secretName, Namespace: instance.Namespace}, expectedFields, h.GetClient(), time.Second*10)
if err != nil {
if k8s_errors.IsNotFound(err) {
h.GetLogger().Info(fmt.Sprintf("secret %s not found", secretName))
instance.Status.Conditions.Set(condition.FalseCondition(
condition.InputReadyCondition,
condition.RequestedReason,
condition.SeverityInfo,
condition.InputReadyWaitingMessage))
return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil
}
instance.Status.Conditions.Set(condition.FalseCondition(
condition.InputReadyCondition,
condition.ErrorReason,
condition.SeverityWarning,
condition.InputReadyErrorMessage,
err.Error()))
return ctrl.Result{}, err
} else if (result != ctrl.Result{}) {
Log.Info(fmt.Sprintf("OpenStack secret %s not found", secretName))
instance.Status.Conditions.Set(condition.FalseCondition(
condition.InputReadyCondition,
condition.RequestedReason,
condition.SeverityInfo,
condition.InputReadyWaitingMessage))
return result, nil
}

// Add a prefix to the var name to avoid accidental collision with other non-secret
// vars. The secret names themselves will be unique.
(*envVars)["secret-"+secret.Name] = env.SetValue(hash)
(*envVars)["secret-"+secretName] = env.SetValue(hash)
// env[secret-osp-secret] = hash?

return ctrl.Result{}, nil
Expand Down Expand Up @@ -369,8 +370,8 @@ func (r *BarbicanKeystoneListenerReconciler) reconcileNormal(ctx context.Context
//
// check for required OpenStack secret holding passwords for service/admin user and add hash to the vars map
//
Log.Info(fmt.Sprintf("[KeystoneListener] Get secret 1 '%s'", instance.Name))
ctrlResult, err := r.getSecret(ctx, helper, instance, instance.Spec.Secret, &configVars)
Log.Info(fmt.Sprintf("[KeystoneListener] Get secret 1 '%s'", instance.Spec.Secret))
ctrlResult, err := r.getSecret(ctx, helper, instance, instance.Spec.Secret, []string{instance.Spec.PasswordSelectors.Service}, &configVars)
if err != nil {
return ctrlResult, err
}
Expand All @@ -379,7 +380,7 @@ func (r *BarbicanKeystoneListenerReconciler) reconcileNormal(ctx context.Context
// check for required TransportURL secret holding transport URL string
//
Log.Info(fmt.Sprintf("[KeystoneListener] Get secret 2 '%s'", instance.Spec.TransportURLSecret))
ctrlResult, err = r.getSecret(ctx, helper, instance, instance.Spec.TransportURLSecret, &configVars)
ctrlResult, err = r.getSecret(ctx, helper, instance, instance.Spec.TransportURLSecret, []string{TransportURL}, &configVars)
if err != nil {
return ctrlResult, err
}
Expand Down
29 changes: 15 additions & 14 deletions controllers/barbicanworker_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,31 +167,32 @@ func (r *BarbicanWorkerReconciler) getSecret(
h *helper.Helper,
instance *barbicanv1beta1.BarbicanWorker,
secretName string,
expectedFields []string,
envVars *map[string]env.Setter,
) (ctrl.Result, error) {
secret, hash, err := secret.GetSecret(ctx, h, secretName, instance.Namespace)
Log := r.GetLogger(ctx)
hash, result, err := secret.VerifySecret(ctx, types.NamespacedName{Name: secretName, Namespace: instance.Namespace}, expectedFields, h.GetClient(), time.Second*10)
if err != nil {
if k8s_errors.IsNotFound(err) {
h.GetLogger().Info(fmt.Sprintf("secret %s not found", secretName))
instance.Status.Conditions.Set(condition.FalseCondition(
condition.InputReadyCondition,
condition.RequestedReason,
condition.SeverityInfo,
condition.InputReadyWaitingMessage))
return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil
}
instance.Status.Conditions.Set(condition.FalseCondition(
condition.InputReadyCondition,
condition.ErrorReason,
condition.SeverityWarning,
condition.InputReadyErrorMessage,
err.Error()))
return ctrl.Result{}, err
} else if (result != ctrl.Result{}) {
Log.Info(fmt.Sprintf("OpenStack secret %s not found", secretName))
instance.Status.Conditions.Set(condition.FalseCondition(
condition.InputReadyCondition,
condition.RequestedReason,
condition.SeverityInfo,
condition.InputReadyWaitingMessage))
return result, nil
}

// Add a prefix to the var name to avoid accidental collision with other non-secret
// vars. The secret names themselves will be unique.
(*envVars)["secret-"+secret.Name] = env.SetValue(hash)
(*envVars)["secret-"+secretName] = env.SetValue(hash)
// env[secret-osp-secret] = hash?

return ctrl.Result{}, nil
Expand Down Expand Up @@ -331,8 +332,8 @@ func (r *BarbicanWorkerReconciler) reconcileNormal(ctx context.Context, instance
//
// check for required OpenStack secret holding passwords for service/admin user and add hash to the vars map
//
Log.Info(fmt.Sprintf("[Worker] Get secret 1 '%s'", instance.Name))
ctrlResult, err := r.getSecret(ctx, helper, instance, instance.Spec.Secret, &configVars)
Log.Info(fmt.Sprintf("[API] Get secret 1 '%s'", instance.Spec.Secret))
ctrlResult, err := r.getSecret(ctx, helper, instance, instance.Spec.Secret, []string{instance.Spec.PasswordSelectors.Service}, &configVars)
if err != nil {
return ctrlResult, err
}
Expand All @@ -341,7 +342,7 @@ func (r *BarbicanWorkerReconciler) reconcileNormal(ctx context.Context, instance
// check for required TransportURL secret holding transport URL string
//
Log.Info(fmt.Sprintf("[Worker] Get secret 2 '%s'", instance.Spec.TransportURLSecret))
ctrlResult, err = r.getSecret(ctx, helper, instance, instance.Spec.TransportURLSecret, &configVars)
ctrlResult, err = r.getSecret(ctx, helper, instance, instance.Spec.TransportURLSecret, []string{TransportURL}, &configVars)
if err != nil {
return ctrlResult, err
}
Expand Down
Loading