Skip to content

Commit

Permalink
Merge pull request #210 from gthiemonge/heartbeat_key
Browse files Browse the repository at this point in the history
Configure heartbeat_key from the osp-secrets
  • Loading branch information
openshift-merge-bot[bot] authored Dec 15, 2023
2 parents 8101bbe + c8a79c9 commit b68aa05
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
26 changes: 25 additions & 1 deletion controllers/amphoracontroller_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,27 @@ func (r *OctaviaAmphoraControllerReconciler) reconcileNormal(ctx context.Context

// Handle config map
configMapVars := make(map[string]env.Setter)

ospSecret, hash, err := oko_secret.GetSecret(ctx, helper, instance.Spec.Secret, instance.Namespace)
if err != nil {
if k8s_errors.IsNotFound(err) {
instance.Status.Conditions.Set(condition.FalseCondition(
condition.InputReadyCondition,
condition.RequestedReason,
condition.SeverityInfo,
condition.InputReadyWaitingMessage))
return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, fmt.Errorf("OpenStack secret %s not found", instance.Spec.Secret)
}
instance.Status.Conditions.Set(condition.FalseCondition(
condition.InputReadyCondition,
condition.ErrorReason,
condition.SeverityWarning,
condition.InputReadyErrorMessage,
err.Error()))
return ctrl.Result{}, err
}
configMapVars[ospSecret.Name] = env.SetValue(hash)

transportURLSecret, hash, err := oko_secret.GetSecret(ctx, helper, instance.Spec.TransportURLSecret, instance.Namespace)
if err != nil {
if k8s_errors.IsNotFound(err) {
Expand Down Expand Up @@ -242,7 +263,7 @@ func (r *OctaviaAmphoraControllerReconciler) reconcileNormal(ctx context.Context
AmphoraDefaultFlavorID: defaultFlavorID,
}

err = r.generateServiceConfigMaps(ctx, instance, helper, &configMapVars, templateVars)
err = r.generateServiceConfigMaps(ctx, instance, helper, &configMapVars, templateVars, ospSecret)
if err != nil {
instance.Status.Conditions.Set(condition.FalseCondition(
condition.ServiceConfigReadyCondition,
Expand Down Expand Up @@ -403,6 +424,7 @@ func (r *OctaviaAmphoraControllerReconciler) generateServiceConfigMaps(
helper *helper.Helper,
envVars *map[string]env.Setter,
templateVars OctaviaTemplateVars,
ospSecret *corev1.Secret,
) error {
r.Log.Info(fmt.Sprintf("generating service config map for %s (%s)", instance.Name, instance.Kind))
cmLabels := labels.GetLabels(instance, labels.GetGroupLabel(instance.ObjectMeta.Name), map[string]string{})
Expand Down Expand Up @@ -443,6 +465,8 @@ func (r *OctaviaAmphoraControllerReconciler) generateServiceConfigMaps(
// Can't do string(nil)
templateParameters["ServerCAKeyPassphrase"] = ""
}
// TODO(gthiemonge) store keys/passwords/passphrases in a specific config file stored in a secret
templateParameters["HeartbeatKey"] = string(ospSecret.Data["OctaviaHeartbeatKey"])

// TODO(beagles): populate the template parameters
cms := []util.Template{
Expand Down
2 changes: 1 addition & 1 deletion templates/octaviaamphoracontroller/config/octavia.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ rpc_response_timeout=60
[api_settings]
[database]
[health_manager]
heartbeat_key=tobeconfigured
heartbeat_key={{ .HeartbeatKey }}
health_update_threads=4
stats_update_threads=4
# heartbeat_key=FIXMEkey1
Expand Down

0 comments on commit b68aa05

Please sign in to comment.