From c7349b2455670c9e446729e06ffd2097ea1a57bc Mon Sep 17 00:00:00 2001 From: Jorge Marey Date: Thu, 12 May 2022 08:46:06 +0200 Subject: [PATCH 1/2] Add nomad env to envoy bootstrap --- .../taskrunner/envoy_bootstrap_hook.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/client/allocrunner/taskrunner/envoy_bootstrap_hook.go b/client/allocrunner/taskrunner/envoy_bootstrap_hook.go index 144a4a1607e..c3ab9393fea 100644 --- a/client/allocrunner/taskrunner/envoy_bootstrap_hook.go +++ b/client/allocrunner/taskrunner/envoy_bootstrap_hook.go @@ -292,6 +292,8 @@ func (h *envoyBootstrapHook) Prestart(ctx context.Context, req *ifs.TaskPrestart // Create environment bootstrapEnv := bootstrap.env(os.Environ()) + // append nomad environment variables to the bootstrap environment + bootstrapEnv = append(bootstrapEnv, h.groupEnv()...) // Write env to file for debugging envFile, err := os.Create(bootstrapEnvPath) @@ -377,6 +379,19 @@ func (h *envoyBootstrapHook) Prestart(ctx context.Context, req *ifs.TaskPrestart return nil } +func (h *envoyBootstrapHook) groupEnv() []string { + return []string{ + fmt.Sprintf("%s=%s", taskenv.AllocID, h.alloc.ID), + fmt.Sprintf("%s=%s", taskenv.ShortAllocID, h.alloc.ID[:8]), + fmt.Sprintf("%s=%s", taskenv.AllocName, h.alloc.Name), + fmt.Sprintf("%s=%s", taskenv.GroupName, h.alloc.TaskGroup), + fmt.Sprintf("%s=%s", taskenv.JobName, h.alloc.Job.Name), + fmt.Sprintf("%s=%s", taskenv.JobID, h.alloc.Job.ID), + fmt.Sprintf("%s=%s", taskenv.Namespace, h.alloc.Namespace), + fmt.Sprintf("%s=%s", taskenv.Region, h.alloc.Job.Region), + } +} + // buildEnvoyAdminBind determines a unique port for use by the envoy admin listener. // // This listener will be bound to 127.0.0.2. From 30072449fa17bb63db70b6e05bd708e5e1dfde28 Mon Sep 17 00:00:00 2001 From: Jorge Marey Date: Thu, 12 May 2022 08:51:48 +0200 Subject: [PATCH 2/2] Add changelog file --- .changelog/12959.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/12959.txt diff --git a/.changelog/12959.txt b/.changelog/12959.txt new file mode 100644 index 00000000000..71a7fedc440 --- /dev/null +++ b/.changelog/12959.txt @@ -0,0 +1,3 @@ +```release-note:improvement +connect: add nomad environment variables to envoy bootstrap +```