From 8f36e6bda4bccb04c6ffdeaa03b5dc604afa64ec Mon Sep 17 00:00:00 2001 From: hc-github-team-nomad-core <82989552+hc-github-team-nomad-core@users.noreply.github.com> Date: Mon, 12 Feb 2024 14:48:01 -0600 Subject: [PATCH] Backport of CNI: fix deprecation warnings into release/1.6.x (#19956) Co-authored-by: Tim Gross --- client/allocrunner/networking_cni.go | 6 +++--- client/allocrunner/networking_cni_test.go | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/client/allocrunner/networking_cni.go b/client/allocrunner/networking_cni.go index c9f1f87aa663..654e7349dc03 100644 --- a/client/allocrunner/networking_cni.go +++ b/client/allocrunner/networking_cni.go @@ -99,7 +99,7 @@ func (c *cniNetworkConfigurator) Setup(ctx context.Context, alloc *structs.Alloc // in one of them to fail. This rety attempts to overcome those erroneous failures. const retry = 3 var firstError error - var res *cni.CNIResult + var res *cni.Result for attempt := 1; ; attempt++ { var err error if res, err = c.cni.Setup(ctx, alloc.ID, spec.Path, cni.WithCapabilityPortMap(getPortMapping(alloc, c.ignorePortMappingHostIP))); err != nil { @@ -127,10 +127,10 @@ func (c *cniNetworkConfigurator) Setup(ctx context.Context, alloc *structs.Alloc } -// cniToAllocNet converts a CNIResult to an AllocNetworkStatus or returns an +// cniToAllocNet converts a cni.Result to an AllocNetworkStatus or returns an // error. The first interface and IP with a sandbox and address set are // preferred. Failing that the first interface with an IP is selected. -func (c *cniNetworkConfigurator) cniToAllocNet(res *cni.CNIResult) (*structs.AllocNetworkStatus, error) { +func (c *cniNetworkConfigurator) cniToAllocNet(res *cni.Result) (*structs.AllocNetworkStatus, error) { if len(res.Interfaces) == 0 { return nil, fmt.Errorf("failed to configure network: no interfaces found") } diff --git a/client/allocrunner/networking_cni_test.go b/client/allocrunner/networking_cni_test.go index 001bfdab80fc..5c25725b2972 100644 --- a/client/allocrunner/networking_cni_test.go +++ b/client/allocrunner/networking_cni_test.go @@ -127,12 +127,12 @@ func TestCNI_forceCleanup(t *testing.T) { }) } -// TestCNI_cniToAllocNet_NoInterfaces asserts an error is returned if CNIResult +// TestCNI_cniToAllocNet_NoInterfaces asserts an error is returned if cni.Result // contains no interfaces. func TestCNI_cniToAllocNet_NoInterfaces(t *testing.T) { ci.Parallel(t) - cniResult := &cni.CNIResult{} + cniResult := &cni.Result{} // Only need a logger c := &cniNetworkConfigurator{ @@ -150,7 +150,7 @@ func TestCNI_cniToAllocNet_Fallback(t *testing.T) { // Calico's CNI plugin v3.12.3 has been observed to return the // following: - cniResult := &cni.CNIResult{ + cniResult := &cni.Result{ Interfaces: map[string]*cni.Config{ "cali39179aa3-74": {}, "eth0": { @@ -181,7 +181,7 @@ func TestCNI_cniToAllocNet_Fallback(t *testing.T) { func TestCNI_cniToAllocNet_Invalid(t *testing.T) { ci.Parallel(t) - cniResult := &cni.CNIResult{ + cniResult := &cni.Result{ Interfaces: map[string]*cni.Config{ "eth0": {}, "veth1": {