Skip to content

Commit

Permalink
Moved NetConfigClient struct into netconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
mye956 committed Sep 26, 2024
1 parent ef1a678 commit e651ae8
Show file tree
Hide file tree
Showing 24 changed files with 189 additions and 450 deletions.
7 changes: 4 additions & 3 deletions agent/handlers/task_server_setup_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
mock_stats "github.com/aws/amazon-ecs-agent/agent/stats/mock"
mock_ecs "github.com/aws/amazon-ecs-agent/ecs-agent/api/ecs/mocks"
v4 "github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/v4/state"
"github.com/aws/amazon-ecs-agent/ecs-agent/tmds/utils/netconfig"
mock_netlinkwrapper "github.com/aws/amazon-ecs-agent/ecs-agent/utils/netlinkwrapper/mocks"

"github.com/golang/mock/gomock"
Expand All @@ -45,7 +46,7 @@ func TestV4GetTaskMetadataWithTaskNetworkConfig(t *testing.T) {
name: "happy case with awsvpc mode",
setStateExpectations: func(state *mock_dockerstate.MockTaskEngineState) {
task := standardTask()
task.FaultInjectionEnabled = true
task.EnableFaultInjection = true
task.NetworkNamespace = networkNamespace
task.DefaultIfname = defaultIfname
gomock.InOrder(
Expand All @@ -64,7 +65,7 @@ func TestV4GetTaskMetadataWithTaskNetworkConfig(t *testing.T) {
name: "happy case with host mode",
setStateExpectations: func(state *mock_dockerstate.MockTaskEngineState) {
hostTask := standardHostTask()
hostTask.FaultInjectionEnabled = true
hostTask.EnableFaultInjection = true
hostTask.NetworkNamespace = networkNamespace
hostTask.DefaultIfname = defaultIfname
gomock.InOrder(
Expand Down Expand Up @@ -127,7 +128,7 @@ func TestV4GetTaskMetadataWithTaskNetworkConfig(t *testing.T) {
}
tmdsAgentState := agentV4.NewTMDSAgentState(state, statsEngine, ecsClient, clusterName, availabilityzone, vpcID, containerInstanceArn)

netConfigClient := v4.NewNetworkConfigClient()
netConfigClient := netconfig.NewNetworkConfigClient()

if tc.setNetLinkExpectations != nil {
mock_netlinkwrapper := mock_netlinkwrapper.NewMockNetLink(ctrl)
Expand Down
4 changes: 2 additions & 2 deletions agent/handlers/task_server_setup_other_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestV4GetTaskMetadataWithTaskNetworkConfig(t *testing.T) {
name: "happy case with awsvpc mode",
setStateExpectations: func(state *mock_dockerstate.MockTaskEngineState) {
task := standardTask()
task.FaultInjectionEnabled = true
task.EnableFaultInjection = true
task.NetworkNamespace = networkNamespace
task.DefaultIfname = defaultIfname
gomock.InOrder(
Expand All @@ -60,7 +60,7 @@ func TestV4GetTaskMetadataWithTaskNetworkConfig(t *testing.T) {
name: "happy case with host mode",
setStateExpectations: func(state *mock_dockerstate.MockTaskEngineState) {
hostTask := standardHostTask()
hostTask.FaultInjectionEnabled = true
hostTask.EnableFaultInjection = true
hostTask.NetworkNamespace = networkNamespace
hostTask.DefaultIfname = defaultIfname
gomock.InOrder(
Expand Down
4 changes: 3 additions & 1 deletion agent/handlers/v4/tmdsstate_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ import (
"github.com/aws/amazon-ecs-agent/ecs-agent/tmds/utils/netconfig"
)

func (s *TMDSAgentState) GetTaskMetadataWithTaskNetworkConfig(v3EndpointID string, networkConfigClient *tmdsv4.NetworkConfigClient) (tmdsv4.TaskResponse, error) {
// Returns task metadata including the task network configuration in v4 format for the
// task identified by the provided endpointContainerID.
func (s *TMDSAgentState) GetTaskMetadataWithTaskNetworkConfig(v3EndpointID string, networkConfigClient *netconfig.NetworkConfigClient) (tmdsv4.TaskResponse, error) {
taskResponse, err := s.getTaskMetadata(v3EndpointID, false, true)
if err == nil {
if taskResponse.TaskNetworkConfig != nil && taskResponse.TaskNetworkConfig.NetworkMode == "host" {
Expand Down
5 changes: 4 additions & 1 deletion agent/handlers/v4/tmdsstate_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ package v4

import (
tmdsv4 "github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/v4/state"
"github.com/aws/amazon-ecs-agent/ecs-agent/tmds/utils/netconfig"
)

func (s *TMDSAgentState) GetTaskMetadataWithTaskNetworkConfig(v3EndpointID string, networkConfigClient *tmdsv4.NetworkConfigClient) (tmdsv4.TaskResponse, error) {
// Returns task metadata including the task network configuration in v4 format for the
// task identified by the provided endpointContainerID.
func (s *TMDSAgentState) GetTaskMetadataWithTaskNetworkConfig(v3EndpointID string, networkConfigClient *netconfig.NetworkConfigClient) (tmdsv4.TaskResponse, error) {
return s.getTaskMetadata(v3EndpointID, false, true)
}

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

This file was deleted.

This file was deleted.

This file was deleted.

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

This file was deleted.

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

Loading

0 comments on commit e651ae8

Please sign in to comment.