Skip to content

Commit e6b65ae

Browse files
committed
chore(agent): Bring back REDIS_PASSWORD distribution via envvar
Agent is not ready yet. Ref.: https://issues.redhat.com/browse/GITOPS-9070 Signed-off-by: Oliver Gondža <ogondza@gmail.com>
1 parent 46bbaa9 commit e6b65ae

6 files changed

Lines changed: 43 additions & 8 deletions

File tree

controllers/argocdagent/agent/deployment.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,18 @@ func buildAgentContainerEnv(cr *argoproj.ArgoCD) []corev1.EnvVar {
329329
{
330330
Name: EnvArgoCDAgentEnableResourceProxy,
331331
Value: "true",
332+
}, {
333+
// TODO: Convert to volume mount once possible: https://issues.redhat.com/browse/GITOPS-9070
334+
Name: "REDIS_PASSWORD",
335+
ValueFrom: &corev1.EnvVarSource{
336+
SecretKeyRef: &corev1.SecretKeySelector{
337+
Key: "admin.password",
338+
LocalObjectReference: corev1.LocalObjectReference{
339+
Name: fmt.Sprintf("%s-%s", cr.Name, "redis-initial-password"),
340+
},
341+
Optional: ptr.To(true),
342+
},
343+
},
332344
},
333345
}
334346

controllers/argocdagent/agent/deployment_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,11 @@ func TestReconcileAgentDeployment_VerifyDeploymentSpec(t *testing.T) {
346346
// Verify some expected environment variables are present
347347
envNames := make(map[string]bool)
348348
for _, env := range container.Env {
349+
// TODO: Convert to volume mount once possible: https://issues.redhat.com/browse/GITOPS-9070
350+
if env.Name == "REDIS_PASSWORD" {
351+
continue
352+
}
353+
349354
envNames[env.Name] = true
350355
// All environment variables should have direct values, not references
351356
assert.Nil(t, env.ValueFrom, "Environment variable %s should have direct value, not reference", env.Name)

controllers/argocdagent/deployment.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,18 @@ func buildPrincipalContainerEnv(cr *argoproj.ArgoCD) []corev1.EnvVar {
371371
}, {
372372
Name: EnvArgoCDPrincipalJwtSecretName,
373373
Value: getPrincipalJWTSecretName(cr),
374+
}, {
375+
// TODO: Convert to volume mount once possible: https://issues.redhat.com/browse/GITOPS-9070
376+
Name: "REDIS_PASSWORD",
377+
ValueFrom: &corev1.EnvVarSource{
378+
SecretKeyRef: &corev1.SecretKeySelector{
379+
Key: "admin.password",
380+
LocalObjectReference: corev1.LocalObjectReference{
381+
Name: fmt.Sprintf("%s-%s", cr.Name, "redis-initial-password"),
382+
},
383+
Optional: ptr.To(true),
384+
},
385+
},
374386
},
375387
}
376388

controllers/argocdagent/deployment_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,14 +383,18 @@ func TestReconcilePrincipalDeployment_VerifyDeploymentSpec(t *testing.T) {
383383
// Verify some expected environment variables are present
384384
envNames := make(map[string]bool)
385385
for _, env := range container.Env {
386-
envNames[env.Name] = true
387-
// Most environment variables should have direct values, except for secrets like Redis password
386+
// TODO: Convert to volume mount once possible: https://issues.redhat.com/browse/GITOPS-9070
387+
if env.Name == "REDIS_PASSWORD" {
388+
continue
389+
}
388390

391+
envNames[env.Name] = true
389392
// All environment variables should have direct values, not references
390393
assert.Nil(t, env.ValueFrom, "Environment variable %s should have direct value, not reference", env.Name)
391394
}
392395
// Check for some environment variables
393396
assert.True(t, envNames["ARGOCD_PRINCIPAL_NAMESPACE"], "ARGOCD_PRINCIPAL_NAMESPACE should be set")
397+
// TODO: Convert to volume mount once possible: https://issues.redhat.com/browse/GITOPS-9070
394398
assert.False(t, envNames["REDIS_PASSWORD"], "REDIS_PASSWORD should not be set")
395399

396400
// Verify volume mounts

tests/ginkgo/sequential/1-051_validate_argocd_agent_principal_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,10 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
371371
Expect(container.Env).To(ContainElement(corev1.EnvVar{Name: key, Value: value}), "Environment variable %s should be set to %s", key, value)
372372
}
373373

374-
Expect(container.Env).NotTo(ContainElement(
375-
HaveField("Name", "REDIS_PASSWORD"),
376-
), "REDIS_PASSWORD should not be set")
374+
// TODO: Convert to volume mount once possible: https://issues.redhat.com/browse/GITOPS-9070
375+
//Expect(container.Env).NotTo(ContainElement(
376+
// HaveField("Name", "REDIS_PASSWORD"),
377+
//), "REDIS_PASSWORD should not be set")
377378

378379
By("Disable principal")
379380

tests/ginkgo/sequential/1-052_validate_argocd_agent_agent_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,10 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
344344
Expect(container.Env).To(ContainElement(corev1.EnvVar{Name: key, Value: value}), "Environment variable %s should be set to %s", key, value)
345345
}
346346

347-
Expect(container.Env).NotTo(ContainElement(
348-
HaveField("Name", "REDIS_PASSWORD"),
349-
), "REDIS_PASSWORD should not be set")
347+
// TODO: Convert to volume mount once possible: https://issues.redhat.com/browse/GITOPS-9070
348+
//Expect(container.Env).NotTo(ContainElement(
349+
// HaveField("Name", "REDIS_PASSWORD"),
350+
//), "REDIS_PASSWORD should not be set")
350351

351352
By("Verify custom environment variable is present")
352353

0 commit comments

Comments
 (0)