Skip to content

Commit

Permalink
Migrate Agent to use vpc-eni plugin for awsvpc mode instead of ecs-en…
Browse files Browse the repository at this point in the history
…i plugin on Linux (#3873)
  • Loading branch information
amogh09 authored Sep 1, 2023
1 parent 39f1f9c commit a6b6076
Show file tree
Hide file tree
Showing 20 changed files with 87 additions and 110 deletions.
2 changes: 1 addition & 1 deletion agent/api/task/task_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func (task *Task) BuildCNIConfigAwsvpc(includeIPAMConfig bool, cniConfig *ecscni
// compatibility), consider it a "standard" ENI attachment.
case "", ni.DefaultInterfaceAssociationProtocol:
cniConfig.ID = eni.MacAddress
ifName, netconf, err = ecscni.NewENINetworkConfig(eni, cniConfig)
ifName, netconf, err = ecscni.NewVPCENINetworkConfig(eni, cniConfig)
case ni.VLANInterfaceAssociationProtocol:
cniConfig.ID = eni.MacAddress
ifName, netconf, err = ecscni.NewBranchENINetworkConfig(eni, cniConfig)
Expand Down
16 changes: 8 additions & 8 deletions agent/api/task/task_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1319,13 +1319,13 @@ func TestBuildCNIConfigRegularENIWithAppMesh(t *testing.T) {
// ENI, Bridge and Appmesh
require.Len(t, cniConfig.NetworkConfigs, 3)
// The first one should be for the ENI.
var eniConfig ecscni.ENIConfig
var eniConfig ecscni.VPCENIPluginConfig
err = json.Unmarshal(cniConfig.NetworkConfigs[0].CNINetworkConfig.Bytes, &eniConfig)
require.NoError(t, err)
assert.Equal(t, mac, eniConfig.MACAddress, eniConfig)
assert.Equal(t, []string{ipv4 + ipv4Block, ipv6 + ipv6Block}, eniConfig.IPAddresses)
assert.Equal(t, mac, eniConfig.ENIMACAddress, eniConfig)
assert.Equal(t, []string{ipv4 + ipv4Block, ipv6 + ipv6Block}, eniConfig.ENIIPAddresses)
assert.Equal(t, []string{ipv4Gateway}, eniConfig.GatewayIPAddresses)
assert.Equal(t, blockIMDS, eniConfig.BlockInstanceMetadata)
assert.Equal(t, blockIMDS, eniConfig.BlockIMDS)
// The second one should be for the Bridge.
var bridgeConfig ecscni.BridgeConfig
err = json.Unmarshal(cniConfig.NetworkConfigs[1].CNINetworkConfig.Bytes, &bridgeConfig)
Expand Down Expand Up @@ -1365,13 +1365,13 @@ func TestBuildCNIConfigRegularENIWithServiceConnect(t *testing.T) {
// ENI, Bridge and ServiceConnect
require.Len(t, cniConfig.NetworkConfigs, 3)
// The first one should be for the ENI.
var eniConfig ecscni.ENIConfig
var eniConfig ecscni.VPCENIPluginConfig
err = json.Unmarshal(cniConfig.NetworkConfigs[0].CNINetworkConfig.Bytes, &eniConfig)
require.NoError(t, err)
assert.Equal(t, mac, eniConfig.MACAddress, eniConfig)
assert.Equal(t, []string{ipv4 + ipv4Block, ipv6 + ipv6Block}, eniConfig.IPAddresses)
assert.Equal(t, mac, eniConfig.ENIMACAddress, eniConfig)
assert.Equal(t, []string{ipv4 + ipv4Block, ipv6 + ipv6Block}, eniConfig.ENIIPAddresses)
assert.Equal(t, []string{ipv4Gateway}, eniConfig.GatewayIPAddresses)
assert.Equal(t, blockIMDS, eniConfig.BlockInstanceMetadata)
assert.Equal(t, blockIMDS, eniConfig.BlockIMDS)
// The second one should be for the Bridge.
var bridgeConfig ecscni.BridgeConfig
err = json.Unmarshal(cniConfig.NetworkConfigs[1].CNINetworkConfig.Bytes, &bridgeConfig)
Expand Down
4 changes: 2 additions & 2 deletions agent/api/task/task_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,12 +596,12 @@ func TestBuildCNIConfig(t *testing.T) {
// For the task ns setup.
err = json.Unmarshal(cniConfig.NetworkConfigs[0].CNINetworkConfig.Bytes, &eniConfig)
require.NoError(t, err)
assert.EqualValues(t, ecscni.ECSVPCENIPluginName, eniConfig.Type)
assert.EqualValues(t, ecscni.VPCENIPluginName, eniConfig.Type)
assert.False(t, eniConfig.UseExistingNetwork)
// For the ecs-bridge setup.
err = json.Unmarshal(cniConfig.NetworkConfigs[1].CNINetworkConfig.Bytes, &eniConfig)
require.NoError(t, err)
assert.EqualValues(t, ecscni.ECSVPCENIPluginName, eniConfig.Type)
assert.EqualValues(t, ecscni.VPCENIPluginName, eniConfig.Type)
assert.True(t, eniConfig.UseExistingNetwork)
assert.EqualValues(t, ecscni.ECSBridgeNetworkName, cniConfig.NetworkConfigs[1].CNINetworkConfig.Network.Name)
}
4 changes: 2 additions & 2 deletions agent/app/agent_capability_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,11 @@ func (agent *ecsAgent) appendFSxWindowsFileServerCapabilities(capabilities []*ec
// doesn't contribute to placement decisions and just serves as additional
// debugging information
func (agent *ecsAgent) getTaskENIPluginVersionAttribute() (*ecs.Attribute, error) {
version, err := agent.cniClient.Version(ecscni.ECSENIPluginName)
version, err := agent.cniClient.Version(ecscni.VPCENIPluginName)
if err != nil {
seelog.Warnf(
"Unable to determine the version of the plugin '%s': %v",
ecscni.ECSENIPluginName, err)
ecscni.VPCENIPluginName, err)
return nil, err
}

Expand Down
6 changes: 3 additions & 3 deletions agent/app/agent_capability_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestVolumeDriverCapabilitiesUnix(t *testing.T) {
dockerclient.Version_1_18,
dockerclient.Version_1_19,
}),
cniClient.EXPECT().Version(ecscni.ECSENIPluginName).Return("v1", nil),
cniClient.EXPECT().Version(ecscni.VPCENIPluginName).Return("v1", nil),
mockMobyPlugins.EXPECT().Scan().Return([]string{"fancyvolumedriver"}, nil),
client.EXPECT().ListPluginsWithFilters(gomock.Any(), gomock.Any(), gomock.Any(),
gomock.Any()).Return(
Expand Down Expand Up @@ -326,7 +326,7 @@ func TestENITrunkingCapabilitiesUnix(t *testing.T) {
client.EXPECT().KnownVersions().Return([]dockerclient.DockerVersion{
dockerclient.Version_1_17,
}),
cniClient.EXPECT().Version(ecscni.ECSENIPluginName).Return("v1", nil),
cniClient.EXPECT().Version(ecscni.VPCENIPluginName).Return("v1", nil),
cniClient.EXPECT().Version(ecscni.ECSBranchENIPluginName).Return("v2", nil),
mockMobyPlugins.EXPECT().Scan().AnyTimes().Return([]string{}, nil),
client.EXPECT().ListPluginsWithFilters(gomock.Any(), gomock.Any(), gomock.Any(),
Expand Down Expand Up @@ -415,7 +415,7 @@ func TestNoENITrunkingCapabilitiesUnix(t *testing.T) {
client.EXPECT().KnownVersions().Return([]dockerclient.DockerVersion{
dockerclient.Version_1_17,
}),
cniClient.EXPECT().Version(ecscni.ECSENIPluginName).Return("v1", nil),
cniClient.EXPECT().Version(ecscni.VPCENIPluginName).Return("v1", nil),
mockMobyPlugins.EXPECT().Scan().AnyTimes().Return([]string{}, nil),
client.EXPECT().ListPluginsWithFilters(gomock.Any(), gomock.Any(), gomock.Any(),
gomock.Any()).AnyTimes().Return([]string{}, nil),
Expand Down
4 changes: 2 additions & 2 deletions agent/app/agent_capability_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ func (agent *ecsAgent) appendFSxWindowsFileServerCapabilities(capabilities []*ec
}

// getTaskENIPluginVersionAttribute returns the version information of the ECS
// CNI plugins. It just executes the ECSVPCENIPluginName plugin to get the Version information.
// CNI plugins. It just executes the vpc-eni plugin to get the Version information.
// Currently, only this plugin is used by ECS Windows for awsvpc mode.
func (agent *ecsAgent) getTaskENIPluginVersionAttribute() (*ecs.Attribute, error) {
version, err := agent.cniClient.Version(ecscni.ECSVPCENIPluginExecutable)
if err != nil {
seelog.Warnf(
"Unable to determine the version of the plugin '%s': %v",
ecscni.ECSVPCENIPluginName, err)
ecscni.VPCENIPluginName, err)
return nil, err
}

Expand Down
5 changes: 3 additions & 2 deletions agent/app/agent_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ const initPID = 1

// awsVPCCNIPlugins is a list of CNI plugins required by the ECS Agent
// to configure the ENI for a task
var awsVPCCNIPlugins = []string{ecscni.ECSENIPluginName,
var awsVPCCNIPlugins = []string{
ecscni.VPCENIPluginName,
ecscni.ECSBridgePluginName,
ecscni.ECSIPAMPluginName,
ecscni.ECSAppMeshPluginName,
Expand Down Expand Up @@ -100,7 +101,7 @@ func (agent *ecsAgent) initializeTaskENIDependencies(state dockerstate.TaskEngin
// verifyCNIPluginsCapabilities returns an error if there's an error querying
// capabilities or if the required capability is absent from the capabilities
// of the following plugins:
// a. ecs-eni
// a. vpc-eni
// b. ecs-bridge
// c. ecs-ipam
// d. aws-appmesh
Expand Down
14 changes: 7 additions & 7 deletions agent/app/agent_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ func TestDoStartTaskENIHappyPath(t *testing.T) {
mockMetadata.EXPECT().PrimaryENIMAC().Return(mac, nil),
mockMetadata.EXPECT().VPCID(mac).Return(vpcID, nil),
mockMetadata.EXPECT().SubnetID(mac).Return(subnetID, nil),
cniClient.EXPECT().Capabilities(ecscni.ECSENIPluginName).Return(cniCapabilities, nil),
cniClient.EXPECT().Capabilities(ecscni.VPCENIPluginName).Return(cniCapabilities, nil),
cniClient.EXPECT().Capabilities(ecscni.ECSBridgePluginName).Return(cniCapabilities, nil),
cniClient.EXPECT().Capabilities(ecscni.ECSIPAMPluginName).Return(cniCapabilities, nil),
cniClient.EXPECT().Capabilities(ecscni.ECSAppMeshPluginName).Return(cniCapabilities, nil),
cniClient.EXPECT().Capabilities(ecscni.ECSBranchENIPluginName).Return(cniCapabilities, nil),
mockCredentialsProvider.EXPECT().Retrieve().Return(credentials.Value{}, nil),
dockerClient.EXPECT().SupportedVersions().Return(nil),
dockerClient.EXPECT().KnownVersions().Return(nil),
cniClient.EXPECT().Version(ecscni.ECSENIPluginName).Return("v1", nil),
cniClient.EXPECT().Version(ecscni.VPCENIPluginName).Return("v1", nil),
cniClient.EXPECT().Version(ecscni.ECSBranchENIPluginName).Return("v2", nil),
mockMobyPlugins.EXPECT().Scan().Return([]string{}, nil),
dockerClient.EXPECT().ListPluginsWithFilters(gomock.Any(), gomock.Any(), gomock.Any(),
Expand Down Expand Up @@ -288,7 +288,7 @@ func TestQueryCNIPluginsCapabilitiesHappyPath(t *testing.T) {
cniCapabilities := []string{ecscni.CapabilityAWSVPCNetworkingMode}
cniClient := mock_ecscni.NewMockCNIClient(ctrl)
gomock.InOrder(
cniClient.EXPECT().Capabilities(ecscni.ECSENIPluginName).Return(cniCapabilities, nil),
cniClient.EXPECT().Capabilities(ecscni.VPCENIPluginName).Return(cniCapabilities, nil),
cniClient.EXPECT().Capabilities(ecscni.ECSBridgePluginName).Return(cniCapabilities, nil),
cniClient.EXPECT().Capabilities(ecscni.ECSIPAMPluginName).Return(cniCapabilities, nil),
cniClient.EXPECT().Capabilities(ecscni.ECSAppMeshPluginName).Return(cniCapabilities, nil),
Expand All @@ -308,7 +308,7 @@ func TestQueryCNIPluginsCapabilitiesEmptyCapabilityListFromPlugin(t *testing.T)
defer ctrl.Finish()

cniClient := mock_ecscni.NewMockCNIClient(ctrl)
cniClient.EXPECT().Capabilities(ecscni.ECSENIPluginName).Return([]string{}, nil)
cniClient.EXPECT().Capabilities(ecscni.VPCENIPluginName).Return([]string{}, nil)

agent := &ecsAgent{
cniClient: cniClient,
Expand All @@ -324,7 +324,7 @@ func TestQueryCNIPluginsCapabilitiesMissAppMesh(t *testing.T) {
cniCapabilities := []string{ecscni.CapabilityAWSVPCNetworkingMode}
cniClient := mock_ecscni.NewMockCNIClient(ctrl)
gomock.InOrder(
cniClient.EXPECT().Capabilities(ecscni.ECSENIPluginName).Return(cniCapabilities, nil),
cniClient.EXPECT().Capabilities(ecscni.VPCENIPluginName).Return(cniCapabilities, nil),
cniClient.EXPECT().Capabilities(ecscni.ECSBridgePluginName).Return(cniCapabilities, nil),
cniClient.EXPECT().Capabilities(ecscni.ECSIPAMPluginName).Return(cniCapabilities, nil),
cniClient.EXPECT().Capabilities(ecscni.ECSAppMeshPluginName).Return(nil, errors.New("error")),
Expand All @@ -342,7 +342,7 @@ func TestQueryCNIPluginsCapabilitiesErrorGettingCapabilitiesFromPlugin(t *testin
defer ctrl.Finish()

cniClient := mock_ecscni.NewMockCNIClient(ctrl)
cniClient.EXPECT().Capabilities(ecscni.ECSENIPluginName).Return(nil, errors.New("error"))
cniClient.EXPECT().Capabilities(ecscni.VPCENIPluginName).Return(nil, errors.New("error"))

agent := &ecsAgent{
cniClient: cniClient,
Expand Down Expand Up @@ -408,7 +408,7 @@ func TestInitializeTaskENIDependenciesQueryCNICapabilitiesError(t *testing.T) {
mockMetadata.EXPECT().PrimaryENIMAC().Return(mac, nil),
mockMetadata.EXPECT().VPCID(mac).Return(vpcID, nil),
mockMetadata.EXPECT().SubnetID(mac).Return(subnetID, nil),
cniClient.EXPECT().Capabilities(ecscni.ECSENIPluginName).Return([]string{}, nil),
cniClient.EXPECT().Capabilities(ecscni.VPCENIPluginName).Return([]string{}, nil),
)
agent := &ecsAgent{
ec2MetadataClient: mockMetadata,
Expand Down
19 changes: 9 additions & 10 deletions agent/ecscni/netconfig_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,17 @@ func newIPAMConfig(cfg *Config) (IPAMConfig, error) {
return ipamConfig, nil
}

// NewENINetworkConfig creates a new ENI CNI network configuration.
func NewENINetworkConfig(eni *ni.NetworkInterface, cfg *Config) (string, *libcni.NetworkConfig, error) {
eniConf := ENIConfig{
Type: ECSENIPluginName,
ENIID: eni.ID,
MACAddress: eni.MacAddress,
IPAddresses: eni.GetIPAddressesWithPrefixLength(),
GatewayIPAddresses: []string{eni.GetSubnetGatewayIPv4Address()},
BlockInstanceMetadata: cfg.BlockInstanceMetadata,
// NewVPCENINetworkConfig creates a new vpc-eni CNI plugin configuration.
func NewVPCENINetworkConfig(eni *ni.NetworkInterface, cfg *Config) (string, *libcni.NetworkConfig, error) {
eniConf := VPCENIPluginConfig{
Type: VPCENIPluginName,
ENIMACAddress: eni.MacAddress,
ENIIPAddresses: eni.GetIPAddressesWithPrefixLength(),
GatewayIPAddresses: []string{eni.GetSubnetGatewayIPv4Address()},
BlockIMDS: cfg.BlockInstanceMetadata,
}

networkConfig, err := newNetworkConfig(eniConf, ECSENIPluginName, cfg.MinSupportedCNIVersion)
networkConfig, err := newNetworkConfig(eniConf, VPCENIPluginName, cfg.MinSupportedCNIVersion)
if err != nil {
return "", nil, fmt.Errorf("cni config: failed to create configuration: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions agent/ecscni/netconfig_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func NewVPCENIPluginConfigForTaskNSSetup(eni *ni.NetworkInterface, cfg *Config)
}

eniConf := VPCENIPluginConfig{
Type: ECSVPCENIPluginName,
Type: VPCENIPluginName,
DNS: dns,
ENIName: eni.GetLinkName(),
ENIMACAddress: eni.MacAddress,
Expand All @@ -72,7 +72,7 @@ func NewVPCENIPluginConfigForTaskNSSetup(eni *ni.NetworkInterface, cfg *Config)
// NewVPCENIPluginConfigForECSBridgeSetup creates the configuration required by vpc-eni plugin to setup ecs-bridge endpoint for the task.
func NewVPCENIPluginConfigForECSBridgeSetup(cfg *Config) (*libcni.NetworkConfig, error) {
bridgeConf := VPCENIPluginConfig{
Type: ECSVPCENIPluginName,
Type: VPCENIPluginName,
UseExistingNetwork: true,
BlockIMDS: cfg.BlockInstanceMetadata,
}
Expand Down
31 changes: 15 additions & 16 deletions agent/ecscni/plugin_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestSetupNS(t *testing.T) {
// ENI plugin was called first
libcniClient.EXPECT().AddNetwork(gomock.Any(), gomock.Any(), gomock.Any()).Return(&cniTypesCurrent.Result{}, nil).Do(
func(ctx context.Context, net *libcni.NetworkConfig, rt *libcni.RuntimeConf) {
assert.Equal(t, ECSENIPluginName, net.Network.Type, "first plugin should be eni")
assert.Equal(t, VPCENIPluginName, net.Network.Type, "first plugin should be eni")
}),
// Bridge plugin was called second
libcniClient.EXPECT().AddNetwork(gomock.Any(), gomock.Any(), gomock.Any()).Return(&cniTypesCurrent.Result{}, nil).Do(
Expand All @@ -98,7 +98,7 @@ func TestSetupNS(t *testing.T) {
}

func eniNetworkConfig(config *Config) *NetworkConfig {
_, eniNetworkConfig, _ := NewENINetworkConfig(
_, eniNetworkConfig, _ := NewVPCENINetworkConfig(
&ni.NetworkInterface{
ID: eniID,
IPV4Addresses: []*ni.IPV4Address{
Expand Down Expand Up @@ -192,7 +192,7 @@ func TestSetupNSAppMeshEnabled(t *testing.T) {
// ENI plugin was called first
libcniClient.EXPECT().AddNetwork(gomock.Any(), gomock.Any(), gomock.Any()).Return(&cniTypesCurrent.Result{}, nil).Do(
func(ctx context.Context, net *libcni.NetworkConfig, rt *libcni.RuntimeConf) {
assert.Equal(t, ECSENIPluginName, net.Network.Type, "first plugin should be eni")
assert.Equal(t, VPCENIPluginName, net.Network.Type, "first plugin should be eni")
}),
// Bridge plugin was called second
libcniClient.EXPECT().AddNetwork(gomock.Any(), gomock.Any(), gomock.Any()).Return(&cniTypesCurrent.Result{}, nil).Do(
Expand Down Expand Up @@ -256,7 +256,7 @@ func TestSetupNSServiceConnectEnabled(t *testing.T) {
// ENI plugin was called first
libcniClient.EXPECT().AddNetwork(gomock.Any(), gomock.Any(), gomock.Any()).Return(&cniTypesCurrent.Result{}, nil).Do(
func(ctx context.Context, net *libcni.NetworkConfig, rt *libcni.RuntimeConf) {
assert.Equal(t, ECSENIPluginName, net.Network.Type, "first plugin should be eni")
assert.Equal(t, VPCENIPluginName, net.Network.Type, "first plugin should be eni")
}),
// Bridge plugin was called second
libcniClient.EXPECT().AddNetwork(gomock.Any(), gomock.Any(), gomock.Any()).Return(&cniTypesCurrent.Result{}, nil).Do(
Expand Down Expand Up @@ -489,16 +489,16 @@ func TestReleaseIPInIPAM(t *testing.T) {
assert.NoError(t, err)
}

// TestConstructENINetworkConfig tests createENINetworkConfig creates the correct
// configuration for eni plugin
func TestConstructENINetworkConfig(t *testing.T) {
// TestConstructVPCENINetworkConfig tests that NewVPCENINetworkConfig creates the correct
// configuration for vpc-eni plugin
func TestConstructVPCENINetworkConfig(t *testing.T) {
config := &Config{
ContainerID: "containerid12",
ContainerPID: "pid",
BlockInstanceMetadata: true,
}

eniName, eniNetworkConfig, err := NewENINetworkConfig(
eniName, eniNetworkConfig, err := NewVPCENINetworkConfig(
&ni.NetworkInterface{
ID: eniID,
IPV4Addresses: []*ni.IPV4Address{
Expand All @@ -515,16 +515,15 @@ func TestConstructENINetworkConfig(t *testing.T) {
config)
require.NoError(t, err, "Failed to construct eni network config")
assert.Equal(t, "eth0", eniName)
eniConfig := &ENIConfig{}
eniConfig := &VPCENIPluginConfig{}
err = json.Unmarshal(eniNetworkConfig.Bytes, eniConfig)
require.NoError(t, err, "unmarshal config from bytes failed")
assert.Equal(t, &ENIConfig{
Type: "ecs-eni",
ENIID: eniID,
IPAddresses: []string{eniIPV4AddressWithBlockSize, eniIPV6AddressWithBlockSize},
MACAddress: eniMACAddress,
BlockInstanceMetadata: true,
GatewayIPAddresses: []string{eniSubnetGatewayIPV4AddressWithoutBlockSize},
assert.Equal(t, &VPCENIPluginConfig{
Type: "vpc-eni",
ENIIPAddresses: []string{eniIPV4AddressWithBlockSize, eniIPV6AddressWithBlockSize},
ENIMACAddress: eniMACAddress,
BlockIMDS: true,
GatewayIPAddresses: []string{eniSubnetGatewayIPV4AddressWithoutBlockSize},
}, eniConfig)
}

Expand Down
2 changes: 1 addition & 1 deletion agent/ecscni/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const (
// ECSCNIVersion, ECSCNIGitHash, VPCCNIGitHash needs to be updated every time CNI plugin is updated.
currentECSCNIVersion = "2020.09.0"
currentECSCNIGitHash = "53a8481891251e66e35847554d52a13fc7c4fd03"
currentVPCCNIGitHash = "a83b66349768e020487a00e31767fc2e6fc88136"
currentVPCCNIGitHash = "be5214353252f8315a1341f4df9ffbd8cf69000c"
)

// Asserts that CNI plugin version matches the expected version
Expand Down
4 changes: 2 additions & 2 deletions agent/ecscni/plugin_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func TestConstructNetworkConfig(t *testing.T) {

subnet := strings.Split(eniSubnetGatewayIPV4Address, "/")
ipv4Addr := fmt.Sprintf("%s/%s", taskENI.GetPrimaryIPv4Address(), subnet[1])
assert.Equal(t, ECSVPCENIPluginName, taskENIConfig.Type)
assert.Equal(t, VPCENIPluginName, taskENIConfig.Type)
assert.Equal(t, TaskHNSNetworkNamePrefix, config.NetworkConfigs[0].CNINetworkConfig.Network.Name)
assert.Equal(t, eniID, taskENIConfig.ENIName)
assert.EqualValues(t, []string{ipv4Addr}, taskENIConfig.ENIIPAddresses)
Expand All @@ -217,7 +217,7 @@ func TestConstructNetworkConfig(t *testing.T) {
ecsBridgeConfig := &VPCENIPluginConfig{}
err = json.Unmarshal(config.NetworkConfigs[1].CNINetworkConfig.Bytes, ecsBridgeConfig)
require.NoError(t, err, "unmarshal ecs-bridge config from bytes failed")
assert.Equal(t, ECSVPCENIPluginName, ecsBridgeConfig.Type)
assert.Equal(t, VPCENIPluginName, ecsBridgeConfig.Type)
assert.Equal(t, ECSBridgeNetworkName, config.NetworkConfigs[1].CNINetworkConfig.Network.Name)
assert.True(t, ecsBridgeConfig.UseExistingNetwork)
}
Expand Down
Loading

0 comments on commit a6b6076

Please sign in to comment.