From 9d700ebc5259bd3f68a36245c6f653d990e06784 Mon Sep 17 00:00:00 2001 From: Luiz Aoqui Date: Tue, 18 Apr 2023 13:18:15 -0700 Subject: [PATCH] add test case for network manager panic --- .changelog/16921.txt | 2 +- .../allocrunner/network_manager_linux_test.go | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/.changelog/16921.txt b/.changelog/16921.txt index c0500f94710..d3793771148 100644 --- a/.changelog/16921.txt +++ b/.changelog/16921.txt @@ -1,3 +1,3 @@ ```release-note:bug -client: Prevent a panic when starting jobs without task group network +client: Prevent a panic when an allocation has a legacy task-level bridge network and uses a driver that does not create a network namespace ``` diff --git a/client/allocrunner/network_manager_linux_test.go b/client/allocrunner/network_manager_linux_test.go index 56beba8d421..c7a565cbc5b 100644 --- a/client/allocrunner/network_manager_linux_test.go +++ b/client/allocrunner/network_manager_linux_test.go @@ -256,6 +256,32 @@ func TestNewNetworkManager(t *testing.T) { err: true, errContains: "hostname is not currently supported on driver group1", }, + { + name: "legacy task network using exec and bridge", + alloc: &structs.Allocation{ + TaskGroup: "group", + Job: &structs.Job{ + TaskGroups: []*structs.TaskGroup{ + { + Name: "group", + Tasks: []*structs.Task{ + { + Name: "task1", + Driver: "group1", + Resources: &structs.Resources{ + Networks: []*structs.NetworkResource{ + {Mode: "bridge"}, + }, + }, + }, + }, + }, + }, + }, + }, + mustInit: false, + err: false, + }, } { t.Run(tc.name, func(t *testing.T) { require := require.New(t)