Skip to content

Commit

Permalink
Update containernetworking/cni dependency to v1.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ohsoo committed May 19, 2023
1 parent 75c5d33 commit 1eb0a87
Show file tree
Hide file tree
Showing 33 changed files with 1,145 additions and 452 deletions.
6 changes: 3 additions & 3 deletions agent/ecscni/mocks/ecscni_mocks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions agent/ecscni/mocks/namespace_helper_mocks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions agent/ecscni/namespace_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ package ecscni
import (
"context"

"github.com/aws/amazon-ecs-agent/agent/dockerclient/dockerapi"
apieni "github.com/aws/amazon-ecs-agent/ecs-agent/api/eni"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"

"github.com/aws/amazon-ecs-agent/agent/dockerclient/dockerapi"
)

// NamespaceHelper defines the methods for performing additional actions to setup/clean the task namespace.
Expand Down
2 changes: 1 addition & 1 deletion agent/ecscni/namespace_helper_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"context"

apieni "github.com/aws/amazon-ecs-agent/ecs-agent/api/eni"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
)

// ConfigureTaskNamespaceRouting executes the commands required for setting up appropriate routing inside task namespace.
Expand Down
2 changes: 1 addition & 1 deletion agent/ecscni/namespace_helper_unsupported.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"context"

apieni "github.com/aws/amazon-ecs-agent/ecs-agent/api/eni"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
)

// ConfigureTaskNamespaceRouting executes the commands required for setting up appropriate routing inside task namespace.
Expand Down
5 changes: 3 additions & 2 deletions agent/ecscni/namespace_helper_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ import (
"net"
"strings"

"github.com/aws/amazon-ecs-agent/agent/dockerclient"
apieni "github.com/aws/amazon-ecs-agent/ecs-agent/api/eni"
"github.com/cihub/seelog"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/docker/docker/api/types"
"github.com/pkg/errors"

"github.com/aws/amazon-ecs-agent/agent/dockerclient"
)

const (
Expand Down
5 changes: 3 additions & 2 deletions agent/ecscni/namespace_helper_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ import (
"github.com/docker/docker/api/types"
"github.com/stretchr/testify/assert"

mock_dockerapi "github.com/aws/amazon-ecs-agent/agent/dockerclient/dockerapi/mocks"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/golang/mock/gomock"

mock_dockerapi "github.com/aws/amazon-ecs-agent/agent/dockerclient/dockerapi/mocks"
)

const (
Expand Down
6 changes: 1 addition & 5 deletions agent/ecscni/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,10 @@ import (
"github.com/aws/amazon-ecs-agent/ecs-agent/logger"
"github.com/cihub/seelog"
"github.com/containernetworking/cni/libcni"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/pkg/errors"
)

const (
currentCNISpec = "0.3.1"
)

// CNIClient defines the method of setting/cleaning up container namespace
type CNIClient interface {
// Version returns the version of the plugin
Expand Down
15 changes: 2 additions & 13 deletions agent/ecscni/plugin_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/cihub/seelog"
"github.com/containernetworking/cni/libcni"
cnitypes "github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -83,19 +83,8 @@ func (client *cniClient) setupNS(ctx context.Context, cfg *Config) (*current.Res
// Not every netns setup involves ECS Bridge Plugin
return nil, nil
}
if _, err := bridgeResult.GetAsVersion(currentCNISpec); err != nil {
seelog.Warnf("[ECSCNI] Unable to convert result to spec version %s; error: %v; result is of version: %s",
currentCNISpec, err, bridgeResult.Version())
return nil, err
}
var curResult *current.Result
curResult, ok := bridgeResult.(*current.Result)
if !ok {
return nil, errors.Errorf(
"cni setup: unable to convert result to expected version '%v'", bridgeResult)
}

return curResult, nil
return current.GetResult(bridgeResult)
}

// ReleaseIPResource marks the ip available in the ipam db
Expand Down
9 changes: 3 additions & 6 deletions agent/ecscni/plugin_linux_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//go:build linux && unit
// +build linux,unit

// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
Expand All @@ -25,14 +22,14 @@ import (
"testing"
"time"

"github.com/aws/amazon-ecs-agent/agent/api/serviceconnect"

"github.com/aws/amazon-ecs-agent/agent/api/appmesh"
"github.com/aws/amazon-ecs-agent/agent/api/serviceconnect"
mock_libcni "github.com/aws/amazon-ecs-agent/agent/ecscni/mocks_libcni"

"github.com/aws/amazon-ecs-agent/ecs-agent/api/eni"
"github.com/containernetworking/cni/libcni"
cnitypes "github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down
2 changes: 1 addition & 1 deletion agent/ecscni/plugin_unsupported.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"errors"
"time"

"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
)

const (
Expand Down
16 changes: 2 additions & 14 deletions agent/ecscni/plugin_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (

"github.com/cihub/seelog"
"github.com/containernetworking/cni/libcni"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -108,19 +108,7 @@ func (client *cniClient) doSetupNS(ctx context.Context, cfg *Config) (*current.R

seelog.Debugf("[ECSCNI] Completed setting up the container namespace: %s", cfg.ContainerID)

if _, err := ecsBridgeResult.GetAsVersion(currentCNISpec); err != nil {
seelog.Warnf("[ECSCNI] Unable to convert result to spec version %s; error: %v; result is of version: %s",
currentCNISpec, err, ecsBridgeResult.Version())
return nil, err
}
var curResult *current.Result
curResult, ok := ecsBridgeResult.(*current.Result)
if !ok {
return nil, errors.Errorf(
"cni setup: unable to convert result to expected version '%v'", ecsBridgeResult)
}

return curResult, nil
return current.GetResult(ecsBridgeResult)
}

// ReleaseIPResource marks the ip available in the ipam db
Expand Down
3 changes: 2 additions & 1 deletion agent/ecscni/plugin_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ import (
"time"

mock_libcni "github.com/aws/amazon-ecs-agent/agent/ecscni/mocks_libcni"

"github.com/aws/amazon-ecs-agent/ecs-agent/api/eni"
"github.com/containernetworking/cni/libcni"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/golang/mock/gomock"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
Expand Down
10 changes: 5 additions & 5 deletions agent/engine/docker_task_engine_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ import (
"testing"
"time"

"github.com/aws/amazon-ecs-agent/ecs-agent/api/attachmentinfo"
"github.com/aws/amazon-ecs-agent/ecs-agent/api/status"

"github.com/aws/amazon-ecs-agent/agent/api/appmesh"
apicontainer "github.com/aws/amazon-ecs-agent/agent/api/container"
apicontainerstatus "github.com/aws/amazon-ecs-agent/agent/api/container/status"
Expand All @@ -56,16 +53,19 @@ import (
"github.com/aws/amazon-ecs-agent/agent/taskresource/ssmsecret"
resourcestatus "github.com/aws/amazon-ecs-agent/agent/taskresource/status"
mock_ioutilwrapper "github.com/aws/amazon-ecs-agent/agent/utils/ioutilwrapper/mocks"

"github.com/aws/amazon-ecs-agent/ecs-agent/api/attachmentinfo"
apieni "github.com/aws/amazon-ecs-agent/ecs-agent/api/eni"
"github.com/aws/amazon-ecs-agent/ecs-agent/api/status"
"github.com/aws/amazon-ecs-agent/ecs-agent/credentials"

"github.com/aws/aws-sdk-go/aws"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/docker/docker/api/types"
dockercontainer "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/network"
"github.com/golang/mock/gomock"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down
9 changes: 5 additions & 4 deletions agent/engine/docker_task_engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ import (
"testing"
"time"

"github.com/aws/amazon-ecs-agent/ecs-agent/api/attachmentinfo"
"github.com/aws/amazon-ecs-agent/ecs-agent/api/status"

"github.com/aws/amazon-ecs-agent/agent/api"
"github.com/aws/amazon-ecs-agent/agent/api/appmesh"
apicontainer "github.com/aws/amazon-ecs-agent/agent/api/container"
Expand Down Expand Up @@ -65,14 +62,18 @@ import (
mock_taskresource "github.com/aws/amazon-ecs-agent/agent/taskresource/mocks"
"github.com/aws/amazon-ecs-agent/agent/taskresource/ssmsecret"
taskresourcevolume "github.com/aws/amazon-ecs-agent/agent/taskresource/volume"

"github.com/aws/amazon-ecs-agent/ecs-agent/api/attachmentinfo"
apieni "github.com/aws/amazon-ecs-agent/ecs-agent/api/eni"
"github.com/aws/amazon-ecs-agent/ecs-agent/api/status"
"github.com/aws/amazon-ecs-agent/ecs-agent/credentials"
mock_credentials "github.com/aws/amazon-ecs-agent/ecs-agent/credentials/mocks"
mock_ttime "github.com/aws/amazon-ecs-agent/ecs-agent/utils/ttime/mocks"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/secretsmanager"
"github.com/aws/aws-sdk-go/service/ssm"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/docker/docker/api/types"
dockercontainer "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/network"
Expand Down
4 changes: 2 additions & 2 deletions agent/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/awslabs/go-config-generator-for-fluentd-and-fluentbit v0.0.0-20210308162251-8959c62cb8f9
github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575
github.com/containerd/cgroups v1.0.4
github.com/containernetworking/cni v0.8.1
github.com/containernetworking/cni v1.1.2
github.com/containernetworking/plugins v0.9.1
github.com/deniswernert/udev v0.0.0-20170418162847-a12666f7b5a1
github.com/docker/docker v20.10.23+incompatible
Expand Down Expand Up @@ -58,6 +58,7 @@ require (
github.com/moby/term v0.0.0-20221205130635-1aeaba878587 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/onsi/ginkgo/v2 v2.7.0 // indirect
github.com/onsi/gomega v1.25.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
Expand All @@ -69,7 +70,6 @@ require (
golang.org/x/text v0.8.0 // indirect
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect
google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

Expand Down

0 comments on commit 1eb0a87

Please sign in to comment.