Skip to content

Commit

Permalink
Showing 7 changed files with 60 additions and 15 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
28 changes: 22 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
@@ -237,21 +237,37 @@ 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/...
7 changes: 4 additions & 3 deletions agent/ecscni/plugin.go
Original file line number Diff line number Diff line change
@@ -33,9 +33,10 @@ import (

const (
currentCNISpec = "0.3.1"
// CNIVersion and CNIGitHash needs to be updated every time CNI plugin is updated
currentCNIVersion = "2018.10.0"
currentCNIGitHash = "93f4377604504bff92e7555da73b0cba732a4fbb"
// ECSCNIVersion, ECSCNIGitHash, VPCCNIGitHash needs to be updated every time CNI plugin is updated
currentECSCNIVersion = "2018.10.0"
currentECSCNIGitHash = "93f4377604504bff92e7555da73b0cba732a4fbb"
currentVPCCNIGitHash = "490b13789ff416dec197eb1e3cb0e2a776e20efd"
)

// CNIClient defines the method of setting/cleaning up container namespace
13 changes: 8 additions & 5 deletions agent/ecscni/plugin_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// +build linux,unit

// Copyright 2014-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// Copyright 2014-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
@@ -365,7 +365,7 @@ func TestCNIPluginVersion(t *testing.T) {
// Asserts that CNI plugin version matches the expected version
func TestCNIPluginVersionNumber(t *testing.T) {
versionStr := getCNIVersionString(t)
assert.Equal(t, currentCNIVersion, versionStr)
assert.Equal(t, currentECSCNIVersion, versionStr)
}

// Asserts that CNI plugin version is upgraded when new commits are made to CNI plugin submodule
@@ -374,10 +374,13 @@ func TestCNIPluginVersionUpgrade(t *testing.T) {
cmd := exec.Command("git", "submodule")
versionInfo, err := cmd.Output()
assert.NoError(t, err, "Error running the command: git submodule")
versionInfoStr := string(versionInfo)
versionInfoStrList := strings.Split(string(versionInfo), "\n")
// If a new commit is added, version should be upgraded
if currentCNIGitHash != strings.Split(versionInfoStr, " ")[1] {
assert.NotEqual(t, currentCNIVersion, versionStr)
if currentECSCNIGitHash != strings.Split(versionInfoStrList[0], " ")[1] {
assert.NotEqual(t, currentECSCNIVersion, versionStr)
}
if currentVPCCNIGitHash != strings.Split(versionInfoStrList[1], " ")[1] {
assert.NotEqual(t, currentVPCCNIGitHash, versionStr)
}
}

1 change: 1 addition & 0 deletions amazon-vpc-cni-plugins
Submodule amazon-vpc-cni-plugins added at 490b13
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may
# not use this file except in compliance with the License. A copy of the
21 changes: 21 additions & 0 deletions scripts/dockerfiles/Dockerfile.buildVPCCNIPlugins
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may
# not use this file except in compliance with the License. A copy of the
# License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.

FROM golang:1.10
MAINTAINER Amazon Web Services, Inc.

RUN mkdir -p /go/src/github.com/aws/

WORKDIR /go/src/github.com/aws/amazon-vpc-cni-plugins

CMD ["make", "aws-appmesh"]

0 comments on commit 774d936

Please sign in to comment.