Skip to content

Commit

Permalink
Propagate ENVIRONMENT and NNF_NODE_NAME to user containers (#423)
Browse files Browse the repository at this point in the history
Signed-off-by: Dean Roehrich <[email protected]>
  • Loading branch information
roehrich-hpe authored Nov 26, 2024
1 parent 0271123 commit 595b723
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions internal/controller/nnf_workflow_controller_container_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package controller
import (
"context"
"fmt"
"os"
"strconv"
"strings"

Expand Down Expand Up @@ -566,7 +567,7 @@ func (c *nnfUserContainer) addEnvVars(spec *corev1.PodSpec, mpi bool) {
subdomain = worker

hosts = append(hosts, launcher)
for i, _ := range c.nnfNodes {
for i := range c.nnfNodes {
hosts = append(hosts, fmt.Sprintf("%s-%d", worker, i))
}
} else {
Expand All @@ -577,6 +578,16 @@ func (c *nnfUserContainer) addEnvVars(spec *corev1.PodSpec, mpi bool) {
container.Env = append(container.Env,
corev1.EnvVar{Name: "NNF_CONTAINER_SUBDOMAIN", Value: subdomain},
corev1.EnvVar{Name: "NNF_CONTAINER_DOMAIN", Value: domain},
corev1.EnvVar{Name: "NNF_CONTAINER_HOSTNAMES", Value: strings.Join(hosts, " ")})
corev1.EnvVar{Name: "NNF_CONTAINER_HOSTNAMES", Value: strings.Join(hosts, " ")},
corev1.EnvVar{Name: "ENVIRONMENT", Value: os.Getenv("ENVIRONMENT")},
corev1.EnvVar{
Name: "NNF_NODE_NAME",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
APIVersion: "v1",
FieldPath: "spec.nodeName",
},
},
})
}
}

0 comments on commit 595b723

Please sign in to comment.