Skip to content

Commit 7565a9a

Browse files
authored
Merge pull request aws#3702 from ohsoo/update-cni-current-dep
Update containernetworking/cni dependency to v1.1.2 and the vpc-cni plugin version
2 parents 0e22645 + f946a86 commit 7565a9a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1239
-536
lines changed

agent/config/config_unix_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ import (
2323
"testing"
2424
"time"
2525

26-
"github.com/aws/amazon-ecs-agent/agent/dockerclient"
27-
"github.com/aws/amazon-ecs-agent/agent/ec2"
28-
cnitypes "github.com/containernetworking/cni/pkg/types"
26+
cniTypes "github.com/containernetworking/cni/pkg/types"
2927
"github.com/stretchr/testify/assert"
3028
"github.com/stretchr/testify/require"
29+
30+
"github.com/aws/amazon-ecs-agent/agent/dockerclient"
31+
"github.com/aws/amazon-ecs-agent/agent/ec2"
3132
)
3233

3334
func TestConfigDefault(t *testing.T) {
@@ -124,7 +125,7 @@ func TestConfigFromFile(t *testing.T) {
124125
assert.Equal(t, testPauseImageName, cfg.PauseContainerImageName, "should read PauseContainerImageName")
125126
assert.Equal(t, testPauseTag, cfg.PauseContainerTag, "should read PauseContainerTag")
126127
assert.Equal(t, 1, len(cfg.AWSVPCAdditionalLocalRoutes), "should have one additional local route")
127-
expectedLocalRoute, err := cnitypes.ParseCIDR("169.254.172.1/32")
128+
expectedLocalRoute, err := cniTypes.ParseCIDR("169.254.172.1/32")
128129
assert.NoError(t, err)
129130
assert.Equal(t, expectedLocalRoute.IP, cfg.AWSVPCAdditionalLocalRoutes[0].IP, "should match expected route IP")
130131
assert.Equal(t, expectedLocalRoute.Mask, cfg.AWSVPCAdditionalLocalRoutes[0].Mask, "should match expected route Mask")

agent/config/parse.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
"github.com/aws/amazon-ecs-agent/agent/utils"
2727

2828
"github.com/cihub/seelog"
29-
cnitypes "github.com/containernetworking/cni/pkg/types"
29+
cniTypes "github.com/containernetworking/cni/pkg/types"
3030
"github.com/docker/go-connections/nat"
3131
)
3232

@@ -216,8 +216,8 @@ func parseInstanceAttributes(errs []error) (map[string]string, []error) {
216216
return instanceAttributes, errs
217217
}
218218

219-
func parseAdditionalLocalRoutes(errs []error) ([]cnitypes.IPNet, []error) {
220-
var additionalLocalRoutes []cnitypes.IPNet
219+
func parseAdditionalLocalRoutes(errs []error) ([]cniTypes.IPNet, []error) {
220+
var additionalLocalRoutes []cniTypes.IPNet
221221
additionalLocalRoutesEnv := os.Getenv("ECS_AWSVPC_ADDITIONAL_LOCAL_ROUTES")
222222
if additionalLocalRoutesEnv != "" {
223223
err := json.Unmarshal([]byte(additionalLocalRoutesEnv), &additionalLocalRoutes)

agent/config/types.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ package config
1616
import (
1717
"time"
1818

19+
cniTypes "github.com/containernetworking/cni/pkg/types"
20+
1921
"github.com/aws/amazon-ecs-agent/agent/dockerclient"
20-
cnitypes "github.com/containernetworking/cni/pkg/types"
2122
)
2223

2324
// ImagePullBehaviorType is an enum variable type corresponding to different agent pull
@@ -247,12 +248,12 @@ type Config struct {
247248
// will limit you to running one `awsvpc` task at a time. IPv4 addresses
248249
// must be specified in decimal-octet form and also specify the subnet
249250
// size (e.g., "169.254.172.42/22").
250-
OverrideAWSVPCLocalIPv4Address *cnitypes.IPNet
251+
OverrideAWSVPCLocalIPv4Address *cniTypes.IPNet
251252

252253
// AWSVPCAdditionalLocalRoutes allows the specification of routing table
253254
// entries that will be added in the task's network namespace via the
254255
// instance bridge interface rather than via the ENI.
255-
AWSVPCAdditionalLocalRoutes []cnitypes.IPNet
256+
AWSVPCAdditionalLocalRoutes []cniTypes.IPNet
256257

257258
// ContainerMetadataEnabled specifies if the agent should provide a metadata
258259
// file for containers.

agent/ecscni/mocks/ecscni_mocks.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

agent/ecscni/mocks/namespace_helper_mocks.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

agent/ecscni/namespace_helper.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@ package ecscni
1616
import (
1717
"context"
1818

19+
cniTypesCurrent "github.com/containernetworking/cni/pkg/types/100"
20+
1921
"github.com/aws/amazon-ecs-agent/agent/dockerclient/dockerapi"
2022
apieni "github.com/aws/amazon-ecs-agent/ecs-agent/api/eni"
21-
"github.com/containernetworking/cni/pkg/types/current"
2223
)
2324

2425
// NamespaceHelper defines the methods for performing additional actions to setup/clean the task namespace.
2526
// Task namespace in awsvpc network mode is configured using pause container which is the first container
2627
// launched for the task. These commands are executed inside that container.
2728
type NamespaceHelper interface {
28-
ConfigureTaskNamespaceRouting(ctx context.Context, taskENI *apieni.ENI, config *Config, result *current.Result) error
29+
ConfigureTaskNamespaceRouting(ctx context.Context, taskENI *apieni.ENI, config *Config, result *cniTypesCurrent.Result) error
2930
}
3031

3132
// helper is the client for executing methods of NamespaceHelper interface.

agent/ecscni/namespace_helper_linux.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ package ecscni
1919
import (
2020
"context"
2121

22+
cniTypesCurrent "github.com/containernetworking/cni/pkg/types/100"
23+
2224
apieni "github.com/aws/amazon-ecs-agent/ecs-agent/api/eni"
23-
"github.com/containernetworking/cni/pkg/types/current"
2425
)
2526

2627
// ConfigureTaskNamespaceRouting executes the commands required for setting up appropriate routing inside task namespace.
2728
// This is applicable only for Windows.
28-
func (nsHelper *helper) ConfigureTaskNamespaceRouting(ctx context.Context, taskENI *apieni.ENI, config *Config, result *current.Result) error {
29+
func (nsHelper *helper) ConfigureTaskNamespaceRouting(ctx context.Context, taskENI *apieni.ENI, config *Config, result *cniTypesCurrent.Result) error {
2930
return nil
3031
}

agent/ecscni/namespace_helper_unsupported.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ package ecscni
1919
import (
2020
"context"
2121

22+
cniTypesCurrent "github.com/containernetworking/cni/pkg/types/100"
23+
2224
apieni "github.com/aws/amazon-ecs-agent/ecs-agent/api/eni"
23-
"github.com/containernetworking/cni/pkg/types/current"
2425
)
2526

2627
// ConfigureTaskNamespaceRouting executes the commands required for setting up appropriate routing inside task namespace.
2728
// This is applicable only for Windows.
28-
func (nsHelper *helper) ConfigureTaskNamespaceRouting(ctx context.Context, taskENI *apieni.ENI, config *Config, result *current.Result) error {
29+
func (nsHelper *helper) ConfigureTaskNamespaceRouting(ctx context.Context, taskENI *apieni.ENI, config *Config, result *cniTypesCurrent.Result) error {
2930
return nil
3031
}

agent/ecscni/namespace_helper_windows.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ import (
2222
"net"
2323
"strings"
2424

25-
"github.com/aws/amazon-ecs-agent/agent/dockerclient"
26-
apieni "github.com/aws/amazon-ecs-agent/ecs-agent/api/eni"
2725
"github.com/cihub/seelog"
28-
"github.com/containernetworking/cni/pkg/types/current"
26+
cniTypesCurrent "github.com/containernetworking/cni/pkg/types/100"
2927
"github.com/docker/docker/api/types"
3028
"github.com/pkg/errors"
29+
30+
"github.com/aws/amazon-ecs-agent/agent/dockerclient"
31+
apieni "github.com/aws/amazon-ecs-agent/ecs-agent/api/eni"
3132
)
3233

3334
const (
@@ -57,7 +58,7 @@ const (
5758
// netsh interface ipv4 add route prefix=169.254.169.254/32 interface="vEthernet (task-br-<mac>-ep-<container_id>)
5859
// netsh interface ipv4 add route prefix=169.254.169.254/32 interface="Loopback"
5960
// netsh interface ipv4 add route prefix=<local-route> interface="vEthernet (nat-ep-<container_id>)
60-
func (nsHelper *helper) ConfigureTaskNamespaceRouting(ctx context.Context, taskENI *apieni.ENI, config *Config, result *current.Result) error {
61+
func (nsHelper *helper) ConfigureTaskNamespaceRouting(ctx context.Context, taskENI *apieni.ENI, config *Config, result *cniTypesCurrent.Result) error {
6162
// Obtain the ecs-bridge endpoint's subnet IP address from the CNI plugin execution result.
6263
ecsBridgeSubnetIPAddress := &net.IPNet{
6364
IP: result.IPs[0].Address.IP.Mask(result.IPs[0].Address.Mask),

agent/ecscni/namespace_helper_windows_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,25 @@ import (
2424
"testing"
2525
"time"
2626

27-
cnitypes "github.com/containernetworking/cni/pkg/types"
27+
"github.com/golang/mock/gomock"
28+
"github.com/stretchr/testify/assert"
2829

30+
cniTypes "github.com/containernetworking/cni/pkg/types"
31+
cniTypesCurrent "github.com/containernetworking/cni/pkg/types/100"
2932
"github.com/docker/docker/api/types"
30-
"github.com/stretchr/testify/assert"
3133

3234
mock_dockerapi "github.com/aws/amazon-ecs-agent/agent/dockerclient/dockerapi/mocks"
33-
"github.com/containernetworking/cni/pkg/types/current"
34-
"github.com/golang/mock/gomock"
3535
)
3636

3737
const (
3838
containerID = "abc12345"
3939
containerExecID = "container1234"
4040
)
4141

42-
// getECSBridgeResult returns an instance of current.Result.
43-
func getECSBridgeResult() *current.Result {
44-
return &current.Result{
45-
IPs: []*current.IPConfig{{
42+
// getECSBridgeResult returns an instance of cniTypesCurrent.Result.
43+
func getECSBridgeResult() *cniTypesCurrent.Result {
44+
return &cniTypesCurrent.Result{
45+
IPs: []*cniTypesCurrent.IPConfig{{
4646
Address: net.IPNet{
4747
IP: net.ParseIP(ipv4),
4848
Mask: net.CIDRMask(24, 32),
@@ -77,7 +77,7 @@ func TestConfigureTaskNamespaceRouting(t *testing.T) {
7777
cniConfig := getCNIConfig()
7878
cniConfig.BlockInstanceMetadata = tt.blockIMDS
7979

80-
cniConfig.AdditionalLocalRoutes = append(cniConfig.AdditionalLocalRoutes, cnitypes.IPNet{
80+
cniConfig.AdditionalLocalRoutes = append(cniConfig.AdditionalLocalRoutes, cniTypes.IPNet{
8181
IP: net.ParseIP("10.0.0.0"),
8282
Mask: net.CIDRMask(24, 32),
8383
})

0 commit comments

Comments
 (0)