Skip to content

Commit

Permalink
Merge branch 'dev' into eni-trunking
Browse files Browse the repository at this point in the history
  • Loading branch information
fenxiong committed Mar 4, 2019
2 parents e0b6a1b + 92dd8b4 commit 96c473e
Show file tree
Hide file tree
Showing 127 changed files with 3,799 additions and 804 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "amazon-ecs-cni-plugins"]
path = amazon-ecs-cni-plugins
url = https://github.com/aws/amazon-ecs-cni-plugins.git
[submodule "amazon-vpc-cni-plugins"]
path = amazon-vpc-cni-plugins
url = https://github.com/aws/amazon-vpc-cni-plugins.git
31 changes: 14 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
language: go
go_import_path: github.com/aws/amazon-ecs-agent
sudo: false
go:
- 1.9
os:
- windows
- linux
go_import_path: github.com/aws/amazon-ecs-agent
script:
- |
(
if [ "$TRAVIS_OS_NAME" = 'windows' ]; then
go test -race -tags unit -timeout 40s ./agent/...
else
make get-deps
make test
make static-check
make xplatform-build
fi
)
- 1.11

matrix:
include:
- os: linux
script:
- make get-deps
- make test
- make static-check
- make xplatform-build
- os: windows
script:
- go test -v -race -tags unit -timeout 40s ./agent/...
30 changes: 23 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ gobuild:

# create output directories
.out-stamp:
mkdir -p ./out/test-artifacts ./out/cni-plugins
mkdir -p ./out/test-artifacts ./out/cni-plugins ./out/amazon-ecs-cni-plugins ./out/amazon-vpc-cni-plugins
touch .out-stamp

# Basic go build
Expand Down Expand Up @@ -237,27 +237,43 @@ ECS_CNI_REPOSITORY_REVISION=master

# Variable to override cni repository location
ECS_CNI_REPOSITORY_SRC_DIR=$(PWD)/amazon-ecs-cni-plugins
VPC_CNI_REPOSITORY_SRC_DIR=$(PWD)/amazon-vpc-cni-plugins

get-cni-sources:
git submodule update --init --checkout
git submodule update --init --recursive --remote

cni-plugins: get-cni-sources .out-stamp
@docker build -f scripts/dockerfiles/Dockerfile.buildCNIPlugins -t "amazon/amazon-ecs-build-cniplugins:make" .
build-ecs-cni-plugins:
@docker build -f scripts/dockerfiles/Dockerfile.buildECSCNIPlugins -t "amazon/amazon-ecs-build-ecs-cni-plugins:make" .
docker run --rm --net=none \
-e GIT_SHORT_HASH=$(shell cd $(ECS_CNI_REPOSITORY_SRC_DIR) && git rev-parse --short=8 HEAD) \
-e GIT_PORCELAIN=$(shell cd $(ECS_CNI_REPOSITORY_SRC_DIR) && git status --porcelain 2> /dev/null | wc -l | sed 's/^ *//') \
-u "$(USERID)" \
-v "$(PWD)/out/cni-plugins:/go/src/github.com/aws/amazon-ecs-cni-plugins/bin/plugins" \
-v "$(PWD)/out/amazon-ecs-cni-plugins:/go/src/github.com/aws/amazon-ecs-cni-plugins/bin/plugins" \
-v "$(ECS_CNI_REPOSITORY_SRC_DIR):/go/src/github.com/aws/amazon-ecs-cni-plugins" \
"amazon/amazon-ecs-build-cniplugins:make"
"amazon/amazon-ecs-build-ecs-cni-plugins:make"
@echo "Built amazon-ecs-cni-plugins successfully."

build-vpc-cni-plugins:
@docker build -f scripts/dockerfiles/Dockerfile.buildVPCCNIPlugins -t "amazon/amazon-ecs-build-vpc-cni-plugins:make" .
docker run --rm --net=none \
-e GIT_SHORT_HASH=$(shell cd $(VPC_CNI_REPOSITORY_SRC_DIR) && git rev-parse --short=8 HEAD) \
-u "$(USERID)" \
-v "$(PWD)/out/amazon-vpc-cni-plugins:/go/src/github.com/aws/amazon-vpc-cni-plugins/build/linux_amd64" \
-v "$(VPC_CNI_REPOSITORY_SRC_DIR):/go/src/github.com/aws/amazon-vpc-cni-plugins" \
"amazon/amazon-ecs-build-vpc-cni-plugins:make"
@echo "Built amazon-vpc-cni-plugins successfully."

cni-plugins: get-cni-sources .out-stamp build-ecs-cni-plugins build-vpc-cni-plugins
mv $(PWD)/out/amazon-ecs-cni-plugins/* $(PWD)/out/cni-plugins
mv $(PWD)/out/amazon-vpc-cni-plugins/* $(PWD)/out/cni-plugins
@echo "Built all cni plugins successfully."

ifeq (${BUILD_PLATFORM},aarch64)
run-integ-tests: test-registry gremlin container-health-check-image run-sudo-tests
. ./scripts/shared_env && go test -tags integration -timeout=20m -v ./agent/engine/... ./agent/stats/... ./agent/app/...
else
run-integ-tests: test-registry gremlin container-health-check-image run-sudo-tests
. ./scripts/shared_env && go test -race -tags integration -timeout=12m -v ./agent/engine/... ./agent/stats/... ./agent/app/...
. ./scripts/shared_env && go test -race -tags integration -timeout=20m -v ./agent/engine/... ./agent/stats/... ./agent/app/...
endif

ifeq (${BUILD_PLATFORM},aarch64)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ additional details on each available environment variable.
| `ECS_SELINUX_CAPABLE` | `true` | Whether SELinux is available on the container instance. | `false` | `false` |
| `ECS_APPARMOR_CAPABLE` | `true` | Whether AppArmor is available on the container instance. | `false` | `false` |
| `ECS_ENGINE_TASK_CLEANUP_WAIT_DURATION` | 10m | Time to wait to delete containers for a stopped task. If set to less than 1 minute, the value is ignored. | 3h | 3h |
| `ECS_CONTAINER_STOP_TIMEOUT` | 10m | Time to wait for the container to exit normally before being forcibly killed. | 30s | 30s |
| `ECS_CONTAINER_STOP_TIMEOUT` | 10m | Instance scoped configuration for time to wait for the container to exit normally before being forcibly killed. | 30s | 30s |
| `ECS_CONTAINER_START_TIMEOUT` | 10m | Timeout before giving up on starting a container. | 3m | 8m |
| `ECS_ENABLE_TASK_IAM_ROLE` | `true` | Whether to enable IAM Roles for Tasks on the Container Instance | `false` | `false` |
| `ECS_ENABLE_TASK_IAM_ROLE_NETWORK_HOST` | `true` | Whether to enable IAM Roles for Tasks when launched with `host` network mode on the Container Instance | `false` | `false` |
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.25.2
1.25.3
11 changes: 11 additions & 0 deletions agent/acs/handler/payload_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

"github.com/aws/amazon-ecs-agent/agent/acs/model/ecsacs"
"github.com/aws/amazon-ecs-agent/agent/api"
apiappmesh "github.com/aws/amazon-ecs-agent/agent/api/appmesh"
apieni "github.com/aws/amazon-ecs-agent/agent/api/eni"
apitask "github.com/aws/amazon-ecs-agent/agent/api/task"
apitaskstatus "github.com/aws/amazon-ecs-agent/agent/api/task/status"
Expand Down Expand Up @@ -222,6 +223,16 @@ func (payloadHandler *payloadRequestHandler) addPayloadTasks(payload *ecsacs.Pay

apiTask.SetTaskENI(eni)
}
// Add the app mesh information to task struct
if task.ProxyConfiguration != nil {
appmesh, err := apiappmesh.AppMeshFromACS(task.ProxyConfiguration)
if err != nil {
payloadHandler.handleUnrecognizedTask(task, err, payload)
allTasksOK = false
continue
}
apiTask.SetAppMesh(appmesh)
}
if task.ExecutionRoleCredentials != nil {
// The payload message contains execution credentials for the task.
// Add the credentials to the credentials manager and set the
Expand Down
72 changes: 72 additions & 0 deletions agent/acs/handler/payload_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,78 @@ func TestPayloadHandlerAddedENIToTask(t *testing.T) {
assert.Equal(t, aws.StringValue(expectedENI.Ipv6Addresses[0].Address), taskeni.IPV6Addresses[0].Address)
}

func TestPayloadHandlerAddedAppMeshToTask(t *testing.T) {
appMeshType := "APPMESH"
mockEgressIgnoredIP1 := "128.0.0.1"
mockEgressIgnoredIP2 := "171.1.3.24"
mockAppPort1 := "8000"
mockAppPort2 := "8001"
mockEgressIgnoredPort1 := "13000"
mockEgressIgnoredPort2 := "13001"
mockIgnoredUID := "1337"
mockIgnoredGID := "2339"
mockProxyIngressPort := "9000"
mockProxyEgressPort := "9001"
mockAppPorts := mockAppPort1 + "," + mockAppPort2
mockEgressIgnoredIPs := mockEgressIgnoredIP1 + "," + mockEgressIgnoredIP2
mockEgressIgnoredPorts := mockEgressIgnoredPort1 + "," + mockEgressIgnoredPort2
mockContainerName := "testEnvoyContainer"
taskMetadataEndpointIP := "169.254.170.2"
instanceMetadataEndpointIP := "169.254.169.254"
tester := setup(t)
defer tester.ctrl.Finish()

var addedTask *apitask.Task
tester.mockTaskEngine.EXPECT().AddTask(gomock.Any()).Do(
func(task *apitask.Task) {
addedTask = task
})

payloadMessage := &ecsacs.PayloadMessage{
Tasks: []*ecsacs.Task{
{
Arn: aws.String("arn"),
ProxyConfiguration: &ecsacs.ProxyConfiguration{
Type: aws.String(appMeshType),
Properties: map[string]*string{
"IgnoredUID": aws.String(mockIgnoredUID),
"IgnoredGID": aws.String(mockIgnoredGID),
"ProxyIngressPort": aws.String(mockProxyIngressPort),
"ProxyEgressPort": aws.String(mockProxyEgressPort),
"AppPorts": aws.String(mockAppPorts),
"EgressIgnoredIPs": aws.String(mockEgressIgnoredIPs),
"EgressIgnoredPorts": aws.String(mockEgressIgnoredPorts),
},
ContainerName: aws.String(mockContainerName),
},
},
},
MessageId: aws.String(payloadMessageId),
}

err := tester.payloadHandler.handleSingleMessage(payloadMessage)
assert.NoError(t, err)

// Validate the added task has the eni information as expected
appMesh := addedTask.GetAppMesh()
assert.NotNil(t, appMesh)
assert.Equal(t, mockIgnoredUID, appMesh.IgnoredUID)
assert.Equal(t, mockIgnoredGID, appMesh.IgnoredGID)
assert.Equal(t, mockProxyIngressPort, appMesh.ProxyIngressPort)
assert.Equal(t, mockProxyEgressPort, appMesh.ProxyEgressPort)
assert.Equal(t, 2, len(appMesh.AppPorts))
assert.Equal(t, mockAppPort1, appMesh.AppPorts[0])
assert.Equal(t, mockAppPort2, appMesh.AppPorts[1])
assert.Equal(t, 4, len(appMesh.EgressIgnoredIPs))
assert.Equal(t, mockEgressIgnoredIP1, appMesh.EgressIgnoredIPs[0])
assert.Equal(t, mockEgressIgnoredIP2, appMesh.EgressIgnoredIPs[1])
assert.Equal(t, taskMetadataEndpointIP, appMesh.EgressIgnoredIPs[2])
assert.Equal(t, instanceMetadataEndpointIP, appMesh.EgressIgnoredIPs[3])
assert.Equal(t, 2, len(appMesh.EgressIgnoredPorts))
assert.Equal(t, mockEgressIgnoredPort1, appMesh.EgressIgnoredPorts[0])
assert.Equal(t, mockEgressIgnoredPort2, appMesh.EgressIgnoredPorts[1])
}

func TestPayloadHandlerAddedECRAuthData(t *testing.T) {
tester := setup(t)
defer tester.ctrl.Finish()
Expand Down
45 changes: 40 additions & 5 deletions agent/acs/model/api/api-2.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,30 @@
"healthCheckType":{"shape":"HealthCheckType"},
"registryAuthentication":{"shape":"RegistryAuthenticationData"},
"logsAuthStrategy":{"shape":"AuthStrategy"},
"secrets":{"shape":"SecretList"}
"secrets":{"shape":"SecretList"},
"dependsOn":{"shape":"ContainerDependencies"},
"startTimeout":{"shape":"Integer"},
"stopTimeout":{"shape":"Integer"}
}
},
"ContainerCondition":{
"type":"string",
"enum":[
"START",
"COMPLETE",
"SUCCESS",
"HEALTHY"
]
},
"ContainerDependencies":{
"type":"list",
"member":{"shape":"ContainerDependency"}
},
"ContainerDependency":{
"type":"structure",
"members":{
"containerName":{"shape":"String"},
"condition":{"shape":"ContainerCondition"}
}
},
"ContainerList":{
Expand Down Expand Up @@ -453,6 +476,18 @@
"type":"list",
"member":{"shape":"PortMapping"}
},
"ProxyConfiguration":{
"type":"structure",
"members":{
"type":{"shape":"ProxyConfigurationType"},
"containerName":{"shape":"String"},
"properties":{"shape":"StringMap"}
}
},
"ProxyConfigurationType":{
"type":"string",
"enum":["APPMESH"]
},
"RegistryAuthenticationData":{
"type":"structure",
"members":{
Expand Down Expand Up @@ -500,8 +535,7 @@
"SecretType":{
"type":"string",
"enum":[
"ENVIRONMENT_VARIABLE",
"MOUNT_POINT"
"ENVIRONMENT_VARIABLE"
]
},
"SensitiveString":{
Expand Down Expand Up @@ -552,7 +586,8 @@
"memory":{"shape":"Integer"},
"associations":{"shape":"Associations"},
"pidMode":{"shape":"String"},
"ipcMode":{"shape":"String"}
"ipcMode":{"shape":"String"},
"proxyConfiguration":{"shape":"ProxyConfiguration"}
}
},
"TaskList":{
Expand Down Expand Up @@ -613,4 +648,4 @@
]
}
}
}
}
48 changes: 46 additions & 2 deletions agent/acs/model/ecsacs/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ type Container struct {

Cpu *int64 `locationName:"cpu" type:"integer"`

DependsOn []*ContainerDependency `locationName:"dependsOn" type:"list"`

DockerConfig *DockerConfig `locationName:"dockerConfig" type:"structure"`

EntryPoint []*string `locationName:"entryPoint" type:"list"`
Expand Down Expand Up @@ -308,6 +310,10 @@ type Container struct {

Secrets []*Secret `locationName:"secrets" type:"list"`

StartTimeout *int64 `locationName:"startTimeout" type:"integer"`

StopTimeout *int64 `locationName:"stopTimeout" type:"integer"`

VolumesFrom []*VolumeFrom `locationName:"volumesFrom" type:"list"`
}

Expand All @@ -321,6 +327,24 @@ func (s Container) GoString() string {
return s.String()
}

type ContainerDependency struct {
_ struct{} `type:"structure"`

Condition *string `locationName:"condition" type:"string" enum:"ContainerCondition"`

ContainerName *string `locationName:"containerName" type:"string"`
}

// String returns the string representation
func (s ContainerDependency) String() string {
return awsutil.Prettify(s)
}

// GoString returns the string representation
func (s ContainerDependency) GoString() string {
return s.String()
}

type DockerConfig struct {
_ struct{} `type:"structure"`

Expand Down Expand Up @@ -957,6 +981,26 @@ func (s PortMapping) GoString() string {
return s.String()
}

type ProxyConfiguration struct {
_ struct{} `type:"structure"`

ContainerName *string `locationName:"containerName" type:"string"`

Properties map[string]*string `locationName:"properties" type:"map"`

Type *string `locationName:"type" type:"string" enum:"ProxyConfigurationType"`
}

// String returns the string representation
func (s ProxyConfiguration) String() string {
return awsutil.Prettify(s)
}

// GoString returns the string representation
func (s ProxyConfiguration) GoString() string {
return s.String()
}

type RefreshTaskIAMRoleCredentialsInput struct {
_ struct{} `type:"structure"`

Expand Down Expand Up @@ -1033,8 +1077,6 @@ type Secret struct {
Type *string `locationName:"type" type:"string" enum:"SecretType"`

ValueFrom *string `locationName:"valueFrom" type:"string"`

Target string `locationName:"target" type:"string"`
}

// String returns the string representation
Expand Down Expand Up @@ -1154,6 +1196,8 @@ type Task struct {

PidMode *string `locationName:"pidMode" type:"string"`

ProxyConfiguration *ProxyConfiguration `locationName:"proxyConfiguration" type:"structure"`

RoleCredentials *IAMRoleCredentials `locationName:"roleCredentials" type:"structure"`

TaskDefinitionAccountId *string `locationName:"taskDefinitionAccountId" type:"string"`
Expand Down
Loading

0 comments on commit 96c473e

Please sign in to comment.