From 0ec5aac1cb8c64060e097f5536270314d44f6c15 Mon Sep 17 00:00:00 2001 From: Seth Hoenig Date: Mon, 1 May 2023 15:28:22 +0000 Subject: [PATCH] connect: do not restrict auto envoy version to docker task driver This PR updates the envoy_bootstrap_hook to no longer disable itself if the task driver in use is not docker. In other words, make it work for podman and other image based task drivers. The hook now only checks that 1. the task is a connect sidecar 2. the task.config block contains an "image" field --- .changelog/17041.txt | 3 +++ client/allocrunner/taskrunner/envoy_version_hook.go | 6 ++++-- client/allocrunner/taskrunner/envoy_version_hook_test.go | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changelog/17041.txt diff --git a/.changelog/17041.txt b/.changelog/17041.txt new file mode 100644 index 00000000000..a770937d5dd --- /dev/null +++ b/.changelog/17041.txt @@ -0,0 +1,3 @@ +```release-note:improvement +connect: do not restrict automatic envoy versioning to docker driver +``` diff --git a/client/allocrunner/taskrunner/envoy_version_hook.go b/client/allocrunner/taskrunner/envoy_version_hook.go index 9438d6c8e44..eb168608abc 100644 --- a/client/allocrunner/taskrunner/envoy_version_hook.go +++ b/client/allocrunner/taskrunner/envoy_version_hook.go @@ -122,8 +122,6 @@ func (_ *envoyVersionHook) interpolateImage(task *structs.Task, env *taskenv.Tas // its envoy proxy version resolved automatically. func (h *envoyVersionHook) skip(request *ifs.TaskPrestartRequest) bool { switch { - case request.Task.Driver != "docker": - return true case !request.Task.UsesConnectSidecar(): return true case !h.needsVersion(request.Task.Config): @@ -158,6 +156,10 @@ func (h *envoyVersionHook) needsVersion(config map[string]interface{}) bool { return false } + if _, exists := config["image"]; !exists { + return false + } + image := h.taskImage(config) return strings.Contains(image, envoy.VersionVar) diff --git a/client/allocrunner/taskrunner/envoy_version_hook_test.go b/client/allocrunner/taskrunner/envoy_version_hook_test.go index a2dd3be58ea..ca20d7c309e 100644 --- a/client/allocrunner/taskrunner/envoy_version_hook_test.go +++ b/client/allocrunner/taskrunner/envoy_version_hook_test.go @@ -272,6 +272,7 @@ func TestTaskRunner_EnvoyVersionHook_Prestart_custom(t *testing.T) { // Setup an Allocation alloc := mock.ConnectAlloc() alloc.Job.TaskGroups[0].Tasks[0] = mock.ConnectSidecarTask() + alloc.Job.TaskGroups[0].Tasks[0].Driver = "podman" alloc.Job.TaskGroups[0].Tasks[0].Config["image"] = "custom-${NOMAD_envoy_version}:latest" allocDir, cleanupDir := allocdir.TestAllocDir(t, logger, "EnvoyVersionHook", alloc.ID) defer cleanupDir()