diff --git a/agent/api/container/port_binding.go b/agent/api/container/port_binding.go index 64d20805cea..8f770d70787 100644 --- a/agent/api/container/port_binding.go +++ b/agent/api/container/port_binding.go @@ -18,7 +18,6 @@ import ( apierrors "github.com/aws/amazon-ecs-agent/agent/api/errors" - "github.com/aws/aws-sdk-go/aws" "github.com/docker/go-connections/nat" ) @@ -32,9 +31,9 @@ const ( // PortBinding represents a port binding for a container type PortBinding struct { // ContainerPort is the port inside the container - ContainerPort *uint16 + ContainerPort uint16 // ContainerPortRange is a range of ports exposed inside the container - ContainerPortRange *string + ContainerPortRange string // HostPort is the port exposed on the host HostPort uint16 // BindIP is the IP address to which the port is bound @@ -64,7 +63,7 @@ func PortBindingFromDockerPortBinding(dockerPortBindings nat.PortMap) ([]PortBin return nil, &apierrors.DefaultNamedError{Name: UnparseablePortErrorName, Err: "Error parsing port binding as int " + err.Error()} } portBindings = append(portBindings, PortBinding{ - ContainerPort: aws.Uint16(uint16(containerPort)), + ContainerPort: uint16(containerPort), HostPort: uint16(hostPort), BindIP: binding.HostIP, Protocol: protocol, diff --git a/agent/api/container/port_binding_test.go b/agent/api/container/port_binding_test.go index 62781642b81..722a76d064d 100644 --- a/agent/api/container/port_binding_test.go +++ b/agent/api/container/port_binding_test.go @@ -22,7 +22,6 @@ import ( apierrors "github.com/aws/amazon-ecs-agent/agent/api/errors" - "github.com/aws/aws-sdk-go/aws" "github.com/docker/go-connections/nat" ) @@ -41,7 +40,7 @@ func TestPortBindingFromDockerPortBinding(t *testing.T) { { BindIP: "1.2.3.4", HostPort: 55, - ContainerPort: aws.Uint16(53), + ContainerPort: 53, Protocol: TransportProtocolUDP, }, }, @@ -57,13 +56,13 @@ func TestPortBindingFromDockerPortBinding(t *testing.T) { { BindIP: "2.3.4.5", HostPort: 8080, - ContainerPort: aws.Uint16(80), + ContainerPort: 80, Protocol: TransportProtocolTCP, }, { BindIP: "5.6.7.8", HostPort: 80, - ContainerPort: aws.Uint16(80), + ContainerPort: 80, Protocol: TransportProtocolTCP, }, }, diff --git a/agent/api/ecsclient/client.go b/agent/api/ecsclient/client.go index 54b846810d8..46dcfa229b2 100644 --- a/agent/api/ecsclient/client.go +++ b/agent/api/ecsclient/client.go @@ -548,7 +548,7 @@ func getNetworkBindings(change api.ContainerStateChange, shouldExcludeIPv6PortBi } hostPort := int64(binding.HostPort) - containerPort := int64(aws.Uint16Value(binding.ContainerPort)) + containerPort := int64(binding.ContainerPort) bindIP := binding.BindIP protocol := binding.Protocol.String() diff --git a/agent/api/ecsclient/client_test.go b/agent/api/ecsclient/client_test.go index 47393810188..11f7ada479a 100644 --- a/agent/api/ecsclient/client_test.go +++ b/agent/api/ecsclient/client_test.go @@ -226,24 +226,24 @@ func TestSubmitContainerStateChange(t *testing.T) { PortBindings: []apicontainer.PortBinding{ { BindIP: "1.2.3.4", - ContainerPort: aws.Uint16(1), + ContainerPort: 1, HostPort: 2, }, { BindIP: "2.2.3.4", - ContainerPort: aws.Uint16(3), + ContainerPort: 3, HostPort: 4, Protocol: apicontainer.TransportProtocolUDP, }, { BindIP: "5.6.7.8", - ContainerPort: aws.Uint16(11), + ContainerPort: 11, HostPort: 11, Protocol: apicontainer.TransportProtocolUDP, }, { BindIP: "5.6.7.8", - ContainerPort: aws.Uint16(12), + ContainerPort: 12, HostPort: 12, Protocol: apicontainer.TransportProtocolUDP, }, @@ -1195,25 +1195,25 @@ func getTestContainerStateChange() api.ContainerStateChange { NetworkModeUnsafe: testNetworkName, Ports: []apicontainer.PortBinding{ { - ContainerPort: aws.Uint16(10), + ContainerPort: 10, HostPort: 10, Protocol: apicontainer.TransportProtocolTCP, }, { - ContainerPort: aws.Uint16(12), + ContainerPort: 12, HostPort: 12, Protocol: apicontainer.TransportProtocolUDP, }, { - ContainerPort: aws.Uint16(15), + ContainerPort: 15, Protocol: apicontainer.TransportProtocolTCP, }, { - ContainerPortRange: aws.String("21-22"), + ContainerPortRange: "21-22", Protocol: apicontainer.TransportProtocolUDP, }, { - ContainerPortRange: aws.String("96-97"), + ContainerPortRange: "96-97", Protocol: apicontainer.TransportProtocolTCP, }, }, @@ -1236,43 +1236,43 @@ func getTestContainerStateChange() api.ContainerStateChange { Container: testContainer, PortBindings: []apicontainer.PortBinding{ { - ContainerPort: aws.Uint16(10), + ContainerPort: 10, HostPort: 10, BindIP: "0.0.0.0", Protocol: apicontainer.TransportProtocolTCP, }, { - ContainerPort: aws.Uint16(12), + ContainerPort: 12, HostPort: 12, BindIP: "1.2.3.4", Protocol: apicontainer.TransportProtocolUDP, }, { - ContainerPort: aws.Uint16(15), + ContainerPort: 15, HostPort: 20, BindIP: "5.6.7.8", Protocol: apicontainer.TransportProtocolTCP, }, { - ContainerPort: aws.Uint16(21), + ContainerPort: 21, HostPort: 60001, BindIP: "::", Protocol: apicontainer.TransportProtocolUDP, }, { - ContainerPort: aws.Uint16(22), + ContainerPort: 22, HostPort: 60002, BindIP: "::", Protocol: apicontainer.TransportProtocolUDP, }, { - ContainerPort: aws.Uint16(96), + ContainerPort: 96, HostPort: 47001, BindIP: "0.0.0.0", Protocol: apicontainer.TransportProtocolTCP, }, { - ContainerPort: aws.Uint16(97), + ContainerPort: 97, HostPort: 47002, BindIP: "0.0.0.0", Protocol: apicontainer.TransportProtocolTCP, diff --git a/agent/api/statechange_test.go b/agent/api/statechange_test.go index 741f46dfba8..0240f6dfa7d 100644 --- a/agent/api/statechange_test.go +++ b/agent/api/statechange_test.go @@ -28,7 +28,6 @@ import ( apitaskstatus "github.com/aws/amazon-ecs-agent/agent/api/task/status" execcmd "github.com/aws/amazon-ecs-agent/agent/engine/execcmd" - "github.com/aws/aws-sdk-go/aws" "github.com/stretchr/testify/assert" ) @@ -161,7 +160,7 @@ func TestNewUncheckedContainerStateChangeEvent(t *testing.T) { SteadyStateStatusUnsafe: &steadyStateStatus, KnownExitCodeUnsafe: &exitCode, KnownPortBindingsUnsafe: []apicontainer.PortBinding{{ - ContainerPort: aws.Uint16(1), + ContainerPort: 1, HostPort: 2, BindIP: "1.2.3.4", Protocol: 3, @@ -177,7 +176,7 @@ func TestNewUncheckedContainerStateChangeEvent(t *testing.T) { Status: apicontainerstatus.ContainerRunning, ExitCode: &exitCode, PortBindings: []apicontainer.PortBinding{{ - ContainerPort: aws.Uint16(1), + ContainerPort: 1, HostPort: 2, BindIP: "1.2.3.4", Protocol: 3, @@ -219,7 +218,7 @@ func TestNewUncheckedContainerStateChangeEvent_SCBridge(t *testing.T) { addPauseContainer: true, pauseContainerName: fmt.Sprintf("%s-%s", apitask.NetworkPauseContainerName, testContainerName), pauseContainerPortBindings: []apicontainer.PortBinding{{ - ContainerPort: aws.Uint16(1), + ContainerPort: 1, HostPort: 2, BindIP: "1.2.3.4", Protocol: 3, @@ -252,7 +251,7 @@ func TestNewUncheckedContainerStateChangeEvent_SCBridge(t *testing.T) { SteadyStateStatusUnsafe: &steadyStateStatus, KnownExitCodeUnsafe: &exitCode, KnownPortBindingsUnsafe: []apicontainer.PortBinding{{ - ContainerPort: aws.Uint16(8080), // we get this from task definition + ContainerPort: 8080, // we get this from task definition }}, ImageDigest: "image", }, diff --git a/agent/api/task/task.go b/agent/api/task/task.go index 0729f8a5761..9fb8af2d1a2 100644 --- a/agent/api/task/task.go +++ b/agent/api/task/task.go @@ -547,7 +547,7 @@ func (task *Task) initServiceConnectEphemeralPorts() error { // to avoid port conflicts. for _, c := range task.Containers { for _, p := range c.Ports { - utilizedPorts = append(utilizedPorts, aws.Uint16Value(p.ContainerPort)) + utilizedPorts = append(utilizedPorts, p.ContainerPort) } } @@ -1785,12 +1785,12 @@ func (task *Task) dockerExposedPorts(container *apicontainer.Container) (dockerE for _, portBinding := range containerToCheck.Ports { protocol := portBinding.Protocol.String() // per port binding config, either one of ContainerPort or ContainerPortRange is set - if portBinding.ContainerPort != nil { - dockerPort := nat.Port(strconv.Itoa(int(aws.Uint16Value(portBinding.ContainerPort))) + "/" + protocol) + if portBinding.ContainerPort != 0 { + dockerPort := nat.Port(strconv.Itoa(int(portBinding.ContainerPort)) + "/" + protocol) dockerExposedPorts[dockerPort] = struct{}{} - } else if portBinding.ContainerPortRange != nil { + } else if portBinding.ContainerPortRange != "" { // we supply containerPortRange here in case we did not assign a host port range and ask docker to do so - dockerPortRange, err := nat.NewPort(protocol, aws.StringValue(portBinding.ContainerPortRange)) + dockerPortRange, err := nat.NewPort(protocol, portBinding.ContainerPortRange) if err != nil { return nil, err } @@ -2349,18 +2349,18 @@ func (task *Task) dockerPortMap(container *apicontainer.Container) (nat.PortMap, containerPortRangeMap := make(map[string]string) for _, portBinding := range containerToCheck.Ports { // for each port binding config, either one of containerPort or containerPortRange is set - if portBinding.ContainerPort != nil { - containerPort := int(aws.Uint16Value(portBinding.ContainerPort)) + if portBinding.ContainerPort != 0 { + containerPort := int(portBinding.ContainerPort) dockerPort := nat.Port(strconv.Itoa(containerPort) + "/" + portBinding.Protocol.String()) dockerPortMap[dockerPort] = append(dockerPortMap[dockerPort], nat.PortBinding{HostPort: strconv.Itoa(int(portBinding.HostPort))}) // append non-range, singular container port to the containerPortSet containerPortSet[containerPort] = struct{}{} - } else if portBinding.ContainerPortRange != nil { + } else if portBinding.ContainerPortRange != "" { containerToCheck.SetContainerHasPortRange(true) - containerPortRange := aws.StringValue(portBinding.ContainerPortRange) + containerPortRange := portBinding.ContainerPortRange // nat.ParsePortRangeToInt validates a port range; if valid, it returns start and end ports as integers startContainerPort, endContainerPort, err := nat.ParsePortRangeToInt(containerPortRange) if err != nil { diff --git a/agent/api/task/task_test.go b/agent/api/task/task_test.go index 909bf66fa01..25c430ecaa2 100644 --- a/agent/api/task/task_test.go +++ b/agent/api/task/task_test.go @@ -87,24 +87,24 @@ func TestDockerConfigPortBinding(t *testing.T) { Name: "c1", Ports: []apicontainer.PortBinding{ { - ContainerPort: aws.Uint16(10), + ContainerPort: 10, HostPort: 10, BindIP: "", Protocol: apicontainer.TransportProtocolTCP, }, { - ContainerPort: aws.Uint16(20), + ContainerPort: 20, HostPort: 20, BindIP: "", Protocol: apicontainer.TransportProtocolUDP, }, { - ContainerPortRange: aws.String("99-999"), + ContainerPortRange: "99-999", BindIP: "", Protocol: apicontainer.TransportProtocolTCP, }, { - ContainerPortRange: aws.String("121-221"), + ContainerPortRange: "121-221", BindIP: "", Protocol: apicontainer.TransportProtocolUDP, }, @@ -221,13 +221,13 @@ func TestDockerHostConfigPortBinding(t *testing.T) { Name: "c1", Ports: []apicontainer.PortBinding{ { - ContainerPort: aws.Uint16(10), + ContainerPort: 10, HostPort: 10, BindIP: "", Protocol: apicontainer.TransportProtocolTCP, }, { - ContainerPort: aws.Uint16(20), + ContainerPort: 20, HostPort: 20, BindIP: "", Protocol: apicontainer.TransportProtocolUDP, @@ -243,12 +243,12 @@ func TestDockerHostConfigPortBinding(t *testing.T) { Name: "c1", Ports: []apicontainer.PortBinding{ { - ContainerPortRange: aws.String("999-1000"), + ContainerPortRange: "999-1000", BindIP: "", Protocol: apicontainer.TransportProtocolTCP, }, { - ContainerPortRange: aws.String("1-3"), + ContainerPortRange: "1-3", BindIP: "", Protocol: apicontainer.TransportProtocolUDP, }, @@ -263,12 +263,12 @@ func TestDockerHostConfigPortBinding(t *testing.T) { Name: "c1", Ports: []apicontainer.PortBinding{ { - ContainerPortRange: aws.String("55-57"), + ContainerPortRange: "55-57", BindIP: "", Protocol: apicontainer.TransportProtocolUDP, }, { - ContainerPort: aws.Uint16(80), + ContainerPort: 80, BindIP: "", Protocol: apicontainer.TransportProtocolTCP, }, @@ -384,8 +384,8 @@ func getTestTaskServiceConnectBridgeMode() *Task { { Name: "C1", Ports: []apicontainer.PortBinding{ - {ContainerPort: aws.Uint16(SCTaskContainerPort1), HostPort: 0, BindIP: "", Protocol: apicontainer.TransportProtocolTCP}, - {ContainerPort: aws.Uint16(SCTaskContainerPort2), HostPort: 0, BindIP: "", Protocol: apicontainer.TransportProtocolTCP}, + {ContainerPort: SCTaskContainerPort1, HostPort: 0, BindIP: "", Protocol: apicontainer.TransportProtocolTCP}, + {ContainerPort: SCTaskContainerPort2, HostPort: 0, BindIP: "", Protocol: apicontainer.TransportProtocolTCP}, }, NetworkModeUnsafe: "", // should later be overridden to container mode }, @@ -1723,11 +1723,11 @@ func TestTaskFromACS(t *testing.T) { Ports: []apicontainer.PortBinding{ { HostPort: 800, - ContainerPort: aws.Uint16(900), + ContainerPort: 900, Protocol: apicontainer.TransportProtocolUDP, }, { - ContainerPortRange: strptr("99-199"), + ContainerPortRange: "99-199", Protocol: apicontainer.TransportProtocolTCP, }, }, diff --git a/agent/api/testutils/container_equal_test.go b/agent/api/testutils/container_equal_test.go index 88e8efe5617..a3519887974 100644 --- a/agent/api/testutils/container_equal_test.go +++ b/agent/api/testutils/container_equal_test.go @@ -47,7 +47,7 @@ func TestContainerEqual(t *testing.T) { {apicontainer.Container{Memory: 1}, apicontainer.Container{Memory: 1}, true}, {apicontainer.Container{Links: []string{"1", "2"}}, apicontainer.Container{Links: []string{"1", "2"}}, true}, {apicontainer.Container{Links: []string{"1", "2"}}, apicontainer.Container{Links: []string{"2", "1"}}, true}, - {apicontainer.Container{Ports: []apicontainer.PortBinding{{ContainerPort: aws.Uint16(1), HostPort: 2, BindIP: "1", Protocol: apicontainer.TransportProtocolTCP}}}, apicontainer.Container{Ports: []apicontainer.PortBinding{{ContainerPort: aws.Uint16(1), HostPort: 2, BindIP: "1", Protocol: apicontainer.TransportProtocolTCP}}}, true}, + {apicontainer.Container{Ports: []apicontainer.PortBinding{{ContainerPort: 1, HostPort: 2, BindIP: "1", Protocol: apicontainer.TransportProtocolTCP}}}, apicontainer.Container{Ports: []apicontainer.PortBinding{{ContainerPort: 1, HostPort: 2, BindIP: "1", Protocol: apicontainer.TransportProtocolTCP}}}, true}, {apicontainer.Container{Essential: true}, apicontainer.Container{Essential: true}, true}, {apicontainer.Container{EntryPoint: nil}, apicontainer.Container{EntryPoint: nil}, true}, {apicontainer.Container{EntryPoint: &[]string{"1", "2"}}, apicontainer.Container{EntryPoint: &[]string{"1", "2"}}, true}, @@ -66,9 +66,9 @@ func TestContainerEqual(t *testing.T) { {apicontainer.Container{CPU: 1}, apicontainer.Container{CPU: 2e2}, false}, {apicontainer.Container{Memory: 1}, apicontainer.Container{Memory: 2e2}, false}, {apicontainer.Container{Links: []string{"1", "2"}}, apicontainer.Container{Links: []string{"1", "二"}}, false}, - {apicontainer.Container{Ports: []apicontainer.PortBinding{{ContainerPort: aws.Uint16(1), HostPort: 2, BindIP: "1", Protocol: apicontainer.TransportProtocolTCP}}}, apicontainer.Container{Ports: []apicontainer.PortBinding{{ContainerPort: aws.Uint16(1), HostPort: 2, BindIP: "二", Protocol: apicontainer.TransportProtocolTCP}}}, false}, - {apicontainer.Container{Ports: []apicontainer.PortBinding{{ContainerPort: aws.Uint16(1), HostPort: 2, BindIP: "1", Protocol: apicontainer.TransportProtocolTCP}}}, apicontainer.Container{Ports: []apicontainer.PortBinding{{ContainerPort: aws.Uint16(1), HostPort: 22, BindIP: "1", Protocol: apicontainer.TransportProtocolTCP}}}, false}, - {apicontainer.Container{Ports: []apicontainer.PortBinding{{ContainerPort: aws.Uint16(1), HostPort: 2, BindIP: "1", Protocol: apicontainer.TransportProtocolTCP}}}, apicontainer.Container{Ports: []apicontainer.PortBinding{{ContainerPort: aws.Uint16(1), HostPort: 2, BindIP: "1", Protocol: apicontainer.TransportProtocolUDP}}}, false}, + {apicontainer.Container{Ports: []apicontainer.PortBinding{{ContainerPort: 1, HostPort: 2, BindIP: "1", Protocol: apicontainer.TransportProtocolTCP}}}, apicontainer.Container{Ports: []apicontainer.PortBinding{{ContainerPort: 1, HostPort: 2, BindIP: "二", Protocol: apicontainer.TransportProtocolTCP}}}, false}, + {apicontainer.Container{Ports: []apicontainer.PortBinding{{ContainerPort: 1, HostPort: 2, BindIP: "1", Protocol: apicontainer.TransportProtocolTCP}}}, apicontainer.Container{Ports: []apicontainer.PortBinding{{ContainerPort: 1, HostPort: 22, BindIP: "1", Protocol: apicontainer.TransportProtocolTCP}}}, false}, + {apicontainer.Container{Ports: []apicontainer.PortBinding{{ContainerPort: 1, HostPort: 2, BindIP: "1", Protocol: apicontainer.TransportProtocolTCP}}}, apicontainer.Container{Ports: []apicontainer.PortBinding{{ContainerPort: 1, HostPort: 2, BindIP: "1", Protocol: apicontainer.TransportProtocolUDP}}}, false}, {apicontainer.Container{Essential: true}, apicontainer.Container{Essential: false}, false}, {apicontainer.Container{EntryPoint: nil}, apicontainer.Container{EntryPoint: &[]string{"nonnil"}}, false}, {apicontainer.Container{EntryPoint: &[]string{"1", "2"}}, apicontainer.Container{EntryPoint: &[]string{"2", "1"}}, false}, diff --git a/agent/containermetadata/parse_metadata_test.go b/agent/containermetadata/parse_metadata_test.go index a32b7eb6b13..7a3357f7b9b 100644 --- a/agent/containermetadata/parse_metadata_test.go +++ b/agent/containermetadata/parse_metadata_test.go @@ -21,7 +21,6 @@ import ( apitask "github.com/aws/amazon-ecs-agent/agent/api/task" - "github.com/aws/aws-sdk-go/aws" "github.com/docker/docker/api/types" dockercontainer "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/network" @@ -201,7 +200,7 @@ func TestParseHasNetworkSettingsPortBindings(t *testing.T) { assert.Equal(t, len(metadata.dockerContainerMetadata.networkInfo.networks), 2, "Expected two networks") assert.Equal(t, len(metadata.dockerContainerMetadata.ports), 1, "Expected nonempty list of ports") - assert.Equal(t, aws.Uint16(80), metadata.dockerContainerMetadata.ports[0].ContainerPort, "Expected nonempty ContainerPort field") + assert.Equal(t, uint16(80), metadata.dockerContainerMetadata.ports[0].ContainerPort, "Expected nonempty ContainerPort field") assert.Equal(t, uint16(8080), metadata.dockerContainerMetadata.ports[0].HostPort, "Expected nonempty HostPort field") assert.Equal(t, "0.0.0.0", metadata.dockerContainerMetadata.ports[0].BindIP, "Expected nonempty HostIP field") } diff --git a/agent/dockerclient/dockerapi/docker_client_test.go b/agent/dockerclient/dockerapi/docker_client_test.go index 66102cf2643..2442e971266 100644 --- a/agent/dockerclient/dockerapi/docker_client_test.go +++ b/agent/dockerclient/dockerapi/docker_client_test.go @@ -806,7 +806,7 @@ func TestContainerEvents(t *testing.T) { event = <-dockerEvents assert.Equal(t, event.DockerID, "cid2", "Wrong docker id") assert.Equal(t, event.Status, apicontainerstatus.ContainerRunning, "Wrong status") - assert.Equal(t, event.PortBindings[0].ContainerPort, aws.Uint16(80), "Incorrect port bindings") + assert.Equal(t, event.PortBindings[0].ContainerPort, uint16(80), "Incorrect port bindings") assert.Equal(t, event.PortBindings[0].HostPort, uint16(9001), "Incorrect port bindings") assert.Equal(t, event.Volumes[0].Source, "/host/path", "Incorrect volume mapping") assert.Equal(t, event.Volumes[0].Destination, "/container/path", "Incorrect volume mapping") diff --git a/agent/engine/docker_task_engine_test.go b/agent/engine/docker_task_engine_test.go index 53bf4c51d14..99102834aa8 100644 --- a/agent/engine/docker_task_engine_test.go +++ b/agent/engine/docker_task_engine_test.go @@ -2077,7 +2077,7 @@ func TestSynchronizeContainerStatus(t *testing.T) { pauseContainerName: fmt.Sprintf("%s-%s", apitask.NetworkPauseContainerName, testContainerName), pauseContainerPortBindings: []apicontainer.PortBinding{ { - ContainerPort: aws.Uint16(8080), + ContainerPort: 8080, }, }, networkMode: networkModeBridge, @@ -2205,7 +2205,7 @@ func TestContainerMetadataUpdatedOnRestart(t *testing.T) { started: time.Now(), portBindings: []apicontainer.PortBinding{ { - ContainerPort: aws.Uint16(80), + ContainerPort: 80, HostPort: 80, BindIP: "0.0.0.0/0", Protocol: apicontainer.TransportProtocolTCP, @@ -2283,7 +2283,7 @@ func TestContainerMetadataUpdatedOnRestart(t *testing.T) { assert.Equal(t, (tc.started).Format(time.RFC3339), (dockerContainer.Container.GetStartedAt()).Format(time.RFC3339)) assert.Equal(t, (tc.finished).Format(time.RFC3339), (dockerContainer.Container.GetFinishedAt()).Format(time.RFC3339)) if tc.stage == "started" { - assert.Equal(t, aws.Uint16(80), dockerContainer.Container.KnownPortBindingsUnsafe[0].ContainerPort) + assert.Equal(t, uint16(80), dockerContainer.Container.KnownPortBindingsUnsafe[0].ContainerPort) } if tc.stage == "finished" { assert.False(t, task.GetExecutionStoppedAt().IsZero()) diff --git a/agent/engine/engine_unix_integ_test.go b/agent/engine/engine_unix_integ_test.go index 721f696923a..061936c4dd8 100644 --- a/agent/engine/engine_unix_integ_test.go +++ b/agent/engine/engine_unix_integ_test.go @@ -276,7 +276,7 @@ func TestPortForward(t *testing.T) { testTask = createTestTask(testArn) port2 := getUnassignedPort() testTask.Containers[0].Command = []string{fmt.Sprintf("-l=%d", port2), "-serve", serverContent} - testTask.Containers[0].Ports = []apicontainer.PortBinding{{ContainerPort: aws.Uint16(port2), HostPort: port2}} + testTask.Containers[0].Ports = []apicontainer.PortBinding{{ContainerPort: port2, HostPort: port2}} taskEngine.AddTask(testTask) @@ -331,12 +331,12 @@ func TestMultiplePortForwards(t *testing.T) { port1 := getUnassignedPort() port2 := getUnassignedPort() testTask.Containers[0].Command = []string{fmt.Sprintf("-l=%d", port1), "-serve", serverContent + "1"} - testTask.Containers[0].Ports = []apicontainer.PortBinding{{ContainerPort: aws.Uint16(port1), HostPort: port1}} + testTask.Containers[0].Ports = []apicontainer.PortBinding{{ContainerPort: port1, HostPort: port1}} testTask.Containers[0].Essential = false testTask.Containers = append(testTask.Containers, createTestContainer()) testTask.Containers[1].Name = "nc2" testTask.Containers[1].Command = []string{fmt.Sprintf("-l=%d", port1), "-serve", serverContent + "2"} - testTask.Containers[1].Ports = []apicontainer.PortBinding{{ContainerPort: aws.Uint16(port1), HostPort: port2}} + testTask.Containers[1].Ports = []apicontainer.PortBinding{{ContainerPort: port1, HostPort: port2}} go taskEngine.AddTask(testTask) @@ -386,7 +386,7 @@ func TestDynamicPortForward(t *testing.T) { port := getUnassignedPort() testTask.Containers[0].Command = []string{fmt.Sprintf("-l=%d", port), "-serve", serverContent} // No HostPort = docker should pick - testTask.Containers[0].Ports = []apicontainer.PortBinding{{ContainerPort: aws.Uint16(port)}} + testTask.Containers[0].Ports = []apicontainer.PortBinding{{ContainerPort: port}} go taskEngine.AddTask(testTask) @@ -404,7 +404,7 @@ func TestDynamicPortForward(t *testing.T) { } var bindingForcontainerPortOne uint16 for _, binding := range validPortBindings { - if port == aws.Uint16Value(binding.ContainerPort) { + if port == binding.ContainerPort { bindingForcontainerPortOne = binding.HostPort } } @@ -441,7 +441,7 @@ func TestMultipleDynamicPortForward(t *testing.T) { port := getUnassignedPort() testTask.Containers[0].Command = []string{fmt.Sprintf("-l=%d", port), "-serve", serverContent, `-loop`} // No HostPort or 0 hostport; docker should pick two ports for us - testTask.Containers[0].Ports = []apicontainer.PortBinding{{ContainerPort: aws.Uint16(port)}, {ContainerPort: aws.Uint16(port), HostPort: 0}} + testTask.Containers[0].Ports = []apicontainer.PortBinding{{ContainerPort: port}, {ContainerPort: port, HostPort: 0}} go taskEngine.AddTask(testTask) @@ -460,7 +460,7 @@ func TestMultipleDynamicPortForward(t *testing.T) { var bindingForcontainerPortOne_1 uint16 var bindingForcontainerPortOne_2 uint16 for _, binding := range validPortBindings { - if port == aws.Uint16Value(binding.ContainerPort) { + if port == binding.ContainerPort { if bindingForcontainerPortOne_1 == 0 { bindingForcontainerPortOne_1 = binding.HostPort } else { @@ -519,7 +519,7 @@ func TestLinking(t *testing.T) { port := getUnassignedPort() testTask.Containers[1].Command = []string{fmt.Sprintf("-l=%d", port), "linkee_alias:80"} testTask.Containers[1].Links = []string{"linkee:linkee_alias"} - testTask.Containers[1].Ports = []apicontainer.PortBinding{{ContainerPort: aws.Uint16(port), HostPort: port}} + testTask.Containers[1].Ports = []apicontainer.PortBinding{{ContainerPort: port, HostPort: port}} stateChangeEvents := taskEngine.StateChangeEvents() @@ -959,7 +959,7 @@ func TestFluentdTag(t *testing.T) { testTaskFleuntdDriver.Containers[0].Image = testFluentdImage testTaskFleuntdDriver.Containers[0].MountPoints = []apicontainer.MountPoint{{ContainerPath: "/fluentd/log", SourceVolume: "logs"}} - testTaskFleuntdDriver.Containers[0].Ports = []apicontainer.PortBinding{{ContainerPort: aws.Uint16(24224), HostPort: 24224}} + testTaskFleuntdDriver.Containers[0].Ports = []apicontainer.PortBinding{{ContainerPort: 24224, HostPort: 24224}} go taskEngine.AddTask(testTaskFleuntdDriver) verifyContainerRunningStateChange(t, taskEngine) verifyTaskRunningStateChange(t, taskEngine) diff --git a/agent/handlers/introspection_server_setup_test.go b/agent/handlers/introspection_server_setup_test.go index b62d0e6f395..e6d0b4c3dee 100644 --- a/agent/handlers/introspection_server_setup_test.go +++ b/agent/handlers/introspection_server_setup_test.go @@ -24,8 +24,6 @@ import ( "strings" "testing" - "github.com/aws/aws-sdk-go/aws" - apicontainer "github.com/aws/amazon-ecs-agent/agent/api/container" apieni "github.com/aws/amazon-ecs-agent/agent/api/eni" apitask "github.com/aws/amazon-ecs-agent/agent/api/task" @@ -428,7 +426,7 @@ var testTasks = []*apitask.Task{ Name: "awsvpc", Ports: []apicontainer.PortBinding{ { - ContainerPort: aws.Uint16(80), + ContainerPort: 80, HostPort: 80, Protocol: apicontainer.TransportProtocolTCP, }, @@ -447,7 +445,7 @@ var testTasks = []*apitask.Task{ Name: "awsvpc", KnownPortBindingsUnsafe: []apicontainer.PortBinding{ { - ContainerPort: aws.Uint16(80), + ContainerPort: 80, HostPort: 80, Protocol: apicontainer.TransportProtocolTCP, }, diff --git a/agent/handlers/task_server_setup_test.go b/agent/handlers/task_server_setup_test.go index d16902f5b4b..dfe59ffcc74 100644 --- a/agent/handlers/task_server_setup_test.go +++ b/agent/handlers/task_server_setup_test.go @@ -193,7 +193,7 @@ var ( ContainerArn: "arn:aws:ecs:ap-northnorth-1:NNN:container/NNNNNNNN-aaaa-4444-bbbb-00000000000", KnownPortBindingsUnsafe: []apicontainer.PortBinding{ { - ContainerPort: aws.Uint16(containerPort), + ContainerPort: containerPort, Protocol: apicontainer.TransportProtocolTCP, }, }, @@ -313,7 +313,7 @@ var ( Type: apicontainer.ContainerNormal, KnownPortBindingsUnsafe: []apicontainer.PortBinding{ { - ContainerPort: aws.Uint16(containerPort), + ContainerPort: containerPort, Protocol: apicontainer.TransportProtocolTCP, }, }, diff --git a/agent/handlers/v1/response.go b/agent/handlers/v1/response.go index c9c9b57b552..2883e817fb1 100644 --- a/agent/handlers/v1/response.go +++ b/agent/handlers/v1/response.go @@ -20,8 +20,6 @@ import ( "github.com/aws/amazon-ecs-agent/agent/containermetadata" "github.com/aws/amazon-ecs-agent/agent/engine/dockerstate" "github.com/aws/amazon-ecs-agent/agent/handlers/utils" - - "github.com/aws/aws-sdk-go/aws" ) // MetadataResponse is the schema for the metadata response JSON object @@ -141,7 +139,7 @@ func NewPortBindingsResponse(dockerContainer *apicontainer.DockerContainer, eni for _, binding := range bindings { port := PortResponse{ - ContainerPort: aws.Uint16Value(binding.ContainerPort), + ContainerPort: binding.ContainerPort, Protocol: binding.Protocol.String(), } diff --git a/agent/handlers/v1/response_test.go b/agent/handlers/v1/response_test.go index 2da27696772..e18301aeecc 100644 --- a/agent/handlers/v1/response_test.go +++ b/agent/handlers/v1/response_test.go @@ -25,7 +25,6 @@ import ( apitask "github.com/aws/amazon-ecs-agent/agent/api/task" apitaskstatus "github.com/aws/amazon-ecs-agent/agent/api/task/status" - "github.com/aws/aws-sdk-go/aws" "github.com/docker/docker/api/types" "github.com/stretchr/testify/assert" ) @@ -102,7 +101,7 @@ func TestTaskResponse(t *testing.T) { Name: containerName, Ports: []apicontainer.PortBinding{ { - ContainerPort: aws.Uint16(80), + ContainerPort: 80, Protocol: apicontainer.TransportProtocolTCP, }, }, @@ -166,7 +165,7 @@ func TestContainerResponse(t *testing.T) { Name: containerName, Ports: []apicontainer.PortBinding{ { - ContainerPort: aws.Uint16(80), + ContainerPort: 80, Protocol: apicontainer.TransportProtocolTCP, }, }, @@ -210,7 +209,7 @@ func TestPortBindingsResponse(t *testing.T) { Name: containerName, Ports: []apicontainer.PortBinding{ { - ContainerPort: aws.Uint16(80), + ContainerPort: 80, HostPort: 80, Protocol: apicontainer.TransportProtocolTCP, }, diff --git a/agent/handlers/v2/response.go b/agent/handlers/v2/response.go index 54e121f5255..d97c77d88f3 100644 --- a/agent/handlers/v2/response.go +++ b/agent/handlers/v2/response.go @@ -273,7 +273,7 @@ func NewContainerResponse( for _, binding := range container.GetKnownPortBindings() { port := v1.PortResponse{ - ContainerPort: aws.Uint16Value(binding.ContainerPort), + ContainerPort: binding.ContainerPort, Protocol: binding.Protocol.String(), } if eni == nil { diff --git a/agent/handlers/v2/response_test.go b/agent/handlers/v2/response_test.go index bb53508fba8..19d89f2c573 100644 --- a/agent/handlers/v2/response_test.go +++ b/agent/handlers/v2/response_test.go @@ -97,7 +97,7 @@ func TestTaskResponse(t *testing.T) { Type: apicontainer.ContainerNormal, Ports: []apicontainer.PortBinding{ { - ContainerPort: aws.Uint16(80), + ContainerPort: 80, Protocol: apicontainer.TransportProtocolTCP, }, }, @@ -193,7 +193,7 @@ func TestTaskResponseWithV4Metadata(t *testing.T) { Type: apicontainer.ContainerNormal, Ports: []apicontainer.PortBinding{ { - ContainerPort: aws.Uint16(80), + ContainerPort: 80, Protocol: apicontainer.TransportProtocolTCP, }, }, @@ -276,7 +276,7 @@ func TestContainerResponse(t *testing.T) { }, Ports: []apicontainer.PortBinding{ { - ContainerPort: aws.Uint16(80), + ContainerPort: 80, Protocol: apicontainer.TransportProtocolTCP, }, }, @@ -404,7 +404,7 @@ func TestTaskResponseMarshal(t *testing.T) { ImageID: imageID, KnownPortBindingsUnsafe: []apicontainer.PortBinding{ { - ContainerPort: aws.Uint16(80), + ContainerPort: 80, Protocol: apicontainer.TransportProtocolTCP, }, }, @@ -537,7 +537,7 @@ func TestContainerResponseMarshal(t *testing.T) { }, KnownPortBindingsUnsafe: []apicontainer.PortBinding{ { - ContainerPort: aws.Uint16(80), + ContainerPort: 80, Protocol: apicontainer.TransportProtocolTCP, }, }, @@ -627,7 +627,7 @@ func TestTaskResponseWithV4TagsError(t *testing.T) { Type: apicontainer.ContainerNormal, Ports: []apicontainer.PortBinding{ { - ContainerPort: aws.Uint16(80), + ContainerPort: 80, Protocol: apicontainer.TransportProtocolTCP, }, }, diff --git a/agent/handlers/v4/response_test.go b/agent/handlers/v4/response_test.go index 517bf7c827b..0423d910423 100644 --- a/agent/handlers/v4/response_test.go +++ b/agent/handlers/v4/response_test.go @@ -29,7 +29,6 @@ import ( apitaskstatus "github.com/aws/amazon-ecs-agent/agent/api/task/status" mock_dockerstate "github.com/aws/amazon-ecs-agent/agent/engine/dockerstate/mocks" - "github.com/aws/aws-sdk-go/aws" "github.com/docker/docker/api/types" "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" @@ -107,7 +106,7 @@ func TestNewTaskContainerResponses(t *testing.T) { Type: apicontainer.ContainerNormal, Ports: []apicontainer.PortBinding{ { - ContainerPort: aws.Uint16(80), + ContainerPort: 80, Protocol: apicontainer.TransportProtocolTCP, }, },