Skip to content

Commit

Permalink
connect: do not restrict auto envoy version to docker task driver (#1…
Browse files Browse the repository at this point in the history
…7041)

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
  • Loading branch information
shoenig authored May 1, 2023
1 parent 61f4d66 commit 0b3bd45
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/17041.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
connect: do not restrict automatic envoy versioning to docker driver
```
6 changes: 4 additions & 2 deletions client/allocrunner/taskrunner/envoy_version_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions client/allocrunner/taskrunner/envoy_version_hook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 0b3bd45

Please sign in to comment.