From 3962eecc2517f4d8666162572f0bd7b42e69cc0c Mon Sep 17 00:00:00 2001 From: Nick Ethier Date: Fri, 10 Jul 2020 10:59:51 -0400 Subject: [PATCH] nomad: recanonicalize network after connect hook (#8407) * nomad: recanonicalize network after connect hook --- nomad/job_endpoint_hook_connect.go | 3 +++ nomad/job_endpoint_hook_connect_test.go | 1 + 2 files changed, 4 insertions(+) diff --git a/nomad/job_endpoint_hook_connect.go b/nomad/job_endpoint_hook_connect.go index a6a941f71bcb..b25601d65042 100644 --- a/nomad/job_endpoint_hook_connect.go +++ b/nomad/job_endpoint_hook_connect.go @@ -178,6 +178,9 @@ func groupConnectHook(job *structs.Job, g *structs.TaskGroup) error { } } } + + // re-canonicalize group network since this hook runs after canonicalizaton + g.Networks[0].Canonicalize() return nil } diff --git a/nomad/job_endpoint_hook_connect_test.go b/nomad/job_endpoint_hook_connect_test.go index 87bc2218e55f..cb9ca321f182 100644 --- a/nomad/job_endpoint_hook_connect_test.go +++ b/nomad/job_endpoint_hook_connect_test.go @@ -100,6 +100,7 @@ func TestJobEndpointConnect_groupConnectHook(t *testing.T) { To: -1, }, } + tgOut.Networks[0].Canonicalize() require.NoError(t, groupConnectHook(job, job.TaskGroups[0])) require.Exactly(t, tgOut, job.TaskGroups[0])