@@ -557,8 +557,9 @@ func buildLlamaStackEnvVars(h *common_helper.Helper, ctx context.Context, instan
557557 }
558558 }
559559
560- // Postgres password for ${env.POSTGRES_PASSWORD} substitution in llama-stack config
561- envVars = append (envVars , buildPostgresPasswordEnvVar ())
560+ // Postgres credentials for ${env.POSTGRESQL_PASSWORD} and ${env.POSTGRESQL_USER}
561+ // substitution in llama-stack config
562+ envVars = append (envVars , buildPostgresCredsEnvVars ()... )
562563
563564 // PostgreSQL SSL configuration for OGX (llama-stack).
564565 // OGX's PostgresSqlStoreConfig does not support ssl_mode/ca_cert_path fields yet
@@ -597,16 +598,30 @@ func buildLlamaStackEnvVars(h *common_helper.Helper, ctx context.Context, instan
597598 return envVars , nil
598599}
599600
600- // buildPostgresPasswordEnvVar returns the POSTGRES_PASSWORD env var sourced from the postgres secret.
601- func buildPostgresPasswordEnvVar () corev1.EnvVar {
602- return corev1.EnvVar {
603- Name : "POSTGRES_PASSWORD" ,
604- ValueFrom : & corev1.EnvVarSource {
605- SecretKeyRef : & corev1.SecretKeySelector {
606- LocalObjectReference : corev1.LocalObjectReference {
607- Name : PostgresSecretName ,
601+ // buildPostgresCredsEnvVars returns the POSTGRESQL_PASSWORD and POSTGRESQL_USER env var sourced from
602+ // the postgres secret generated by the operator.
603+ func buildPostgresCredsEnvVars () []corev1.EnvVar {
604+ return []corev1.EnvVar {
605+ {
606+ Name : "POSTGRESQL_PASSWORD" ,
607+ ValueFrom : & corev1.EnvVarSource {
608+ SecretKeyRef : & corev1.SecretKeySelector {
609+ LocalObjectReference : corev1.LocalObjectReference {
610+ Name : PostgresSecretName ,
611+ },
612+ Key : OpenStackLightspeedComponentPasswordFileName ,
613+ },
614+ },
615+ },
616+ {
617+ Name : "POSTGRESQL_USER" ,
618+ ValueFrom : & corev1.EnvVarSource {
619+ SecretKeyRef : & corev1.SecretKeySelector {
620+ LocalObjectReference : corev1.LocalObjectReference {
621+ Name : PostgresSecretName ,
622+ },
623+ Key : PostgresUsernameSecretKey ,
608624 },
609- Key : OpenStackLightspeedComponentPasswordFileName ,
610625 },
611626 },
612627 }
@@ -619,12 +634,12 @@ func buildLightspeedStackEnvVars(instance *apiv1beta1.OpenStackLightspeed) []cor
619634 Name : "LIGHTSPEED_STACK_LOG_LEVEL" ,
620635 Value : instance .Spec .Logging .LightspeedStackLogLevel ,
621636 },
622- buildPostgresPasswordEnvVar (),
623637 }
624638 envVars = append (envVars , corev1.EnvVar {
625639 Name : "RH_SERVER_OKP" ,
626640 Value : fmt .Sprintf ("http://%s.%s.svc:%d" , OKPServiceName , instance .GetNamespace (), OKPServicePort ),
627641 })
642+ envVars = append (envVars , buildPostgresCredsEnvVars ()... )
628643 return envVars
629644}
630645
@@ -736,5 +751,14 @@ func buildConfigMapAnnotations(h *common_helper.Helper, ctx context.Context) (ma
736751 annotations [CABundleConfigMapVersionAnnotation ] = caBundleVersion
737752 }
738753
754+ postgresSecretVersion , err := getSecretResourceVersion (ctx , h , PostgresSecretName , h .GetBeforeObject ().GetNamespace ())
755+ if err != nil {
756+ if ! errors .IsNotFound (err ) {
757+ return nil , fmt .Errorf ("failed to get postgres secret resource version: %w" , err )
758+ }
759+ } else {
760+ annotations [PostgresSecretResourceVersionAnnotation ] = postgresSecretVersion
761+ }
762+
739763 return annotations , nil
740764}
0 commit comments