Skip to content

Commit

Permalink
Update windows builds to golang v1.17 (#3010)
Browse files Browse the repository at this point in the history
* Update GO_VERSION_WINDOWS

Signed-off-by: Siddharth Vinothkumar <[email protected]>

* Update parse_windows for WS2016 checks

Signed-off-by: Siddharth Vinothkumar <[email protected]>

* Update go.mod

Signed-off-by: Siddharth Vinothkumar <[email protected]>

* Update go.sum

Signed-off-by: Siddharth Vinothkumar <[email protected]>

* Update vendor

Signed-off-by: Siddharth Vinothkumar <[email protected]>

* Skip ordering integ tests for WS 2016

Signed-off-by: Siddharth Vinothkumar <[email protected]>

* Update github workflow for windows

Signed-off-by: Siddharth Vinothkumar <[email protected]>

* Add `race` flag to github workflow for windows

Signed-off-by: Siddharth Vinothkumar <[email protected]>

* Plumb GO111MODULE in Makefile

Signed-off-by: Siddharth Vinothkumar <[email protected]>

* Add `IsWindows2016` to all platforms

Signed-off-by: Siddharth Vinothkumar <[email protected]>

* Add environment override for windows server version check

Signed-off-by: Siddharth Vinothkumar <[email protected]>

* Update github workflow for windows

Signed-off-by: Siddharth Vinothkumar <[email protected]>
  • Loading branch information
vsiddharth authored Sep 10, 2021
1 parent 1fd2d38 commit 0c1e813
Show file tree
Hide file tree
Showing 277 changed files with 110,110 additions and 16,271 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@ jobs:
run: |
$Env:GOPATH = "$Env:GITHUB_WORKSPACE"
cd "$Env:GITHUB_WORKSPACE"
cd "src/github.com/aws/amazon-ecs-agent"
go test -race -tags unit -timeout 40s ./agent/...
cd "src/github.com/aws/amazon-ecs-agent/agent"
gcc --version
$env:ZZZ_SKIP_WINDOWS_SERVER_VERSION_CHECK_NOT_SUPPORTED_IN_PRODUCTION = 'true'
$packages=go list .\... | Where-Object {$_ -NotMatch 'vendor'}
go test -v -tags unit -timeout=40s $packages
2 changes: 1 addition & 1 deletion GO_VERSION_WINDOWS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.12
1.17
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ docker-release: pause-container-release cni-plugins .out-stamp
@docker build --build-arg GO_VERSION=${GO_VERSION} -f scripts/dockerfiles/Dockerfile.cleanbuild -t "amazon/amazon-ecs-agent-${BUILD}:make" .
@docker run --net=none \
--env TARGET_OS="${TARGET_OS}" \
--env GO111MODULE=auto \
--env LDFLAGS="-X github.com/aws/amazon-ecs-agent/agent/config.DefaultPauseContainerTag=$(PAUSE_CONTAINER_TAG) \
-X github.com/aws/amazon-ecs-agent/agent/config.DefaultPauseContainerImageName=$(PAUSE_CONTAINER_IMAGE)" \
--user "$(USERID)" \
Expand Down Expand Up @@ -195,6 +196,7 @@ get-cni-sources:
build-ecs-cni-plugins:
@docker build --build-arg GO_VERSION=$(GO_VERSION) -f scripts/dockerfiles/Dockerfile.buildECSCNIPlugins -t "amazon/amazon-ecs-build-ecs-cni-plugins:make" .
docker run --rm --net=none \
-e GO111MODULE=auto \
-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)" \
Expand All @@ -206,6 +208,7 @@ build-ecs-cni-plugins:
build-vpc-cni-plugins:
@docker build --build-arg GOARCH=$(GOARCH) --build-arg GO_VERSION=$(GO_VERSION) -f $(VPC_CNI_REPOSITORY_DOCKER_FILE) -t "amazon/amazon-ecs-build-vpc-cni-plugins:make" .
docker run --rm --net=none \
-e GO111MODULE=off \
-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/${TARGET_OS}_$(GOARCH)" \
Expand Down
6 changes: 6 additions & 0 deletions agent/config/parse_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@

package config

import "errors"

func parseGMSACapability() bool {
return false
}

func parseFSxWindowsFileServerCapability() bool {
return false
}

var IsWindows2016 = func() (bool, error) {
return false, errors.New("unsupported platform")
}
6 changes: 6 additions & 0 deletions agent/config/parse_unsupported.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@

package config

import "errors"

func parseGMSACapability() bool {
return false
}

func parseFSxWindowsFileServerCapability() bool {
return false
}

var IsWindows2016 = func() (bool, error) {
return false, errors.New("unsupported platform")
}
38 changes: 21 additions & 17 deletions agent/config/parse_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ package config

import (
"os"
"os/exec"
"strings"
"syscall"
"unsafe"

"golang.org/x/sys/windows/registry"

"github.com/aws/amazon-ecs-agent/agent/utils"
"github.com/cihub/seelog"
)
Expand All @@ -32,6 +31,11 @@ const (
// domain join check validation. This is useful for integration and
// functional-tests but should not be set for any non-test use-case.
envSkipDomainJoinCheck = "ZZZ_SKIP_DOMAIN_JOIN_CHECK_NOT_SUPPORTED_IN_PRODUCTION"

// envSkipWindowsServerVersionCheck is an environment setting that can be used
// to skip the windows server version check. This is useful for testing and
// should not be set for any non-test use-case.
envSkipWindowsServerVersionCheck = "ZZZ_SKIP_WINDOWS_SERVER_VERSION_CHECK_NOT_SUPPORTED_IN_PRODUCTION"
)

// parseGMSACapability is used to determine if gMSA support can be enabled
Expand All @@ -43,7 +47,7 @@ func parseGMSACapability() bool {
// parseFSxWindowsFileServerCapability is used to determine if fsxWindowsFileServer support can be enabled
func parseFSxWindowsFileServerCapability() bool {
// fsxwindowsfileserver is not supported on Windows 2016 and non-domain-joined container instances
status, err := isWindows2016()
status, err := IsWindows2016()
if err != nil || status == true {
return false
}
Expand Down Expand Up @@ -91,25 +95,25 @@ func isDomainJoined() (bool, error) {
return status == syscall.NetSetupDomainName, nil
}

// isWindows2016 is used to check if container instance is versioned Windows 2016
// Reference: https://godoc.org/golang.org/x/sys/windows/registry
var isWindows2016 = func() (bool, error) {
key, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows NT\CurrentVersion`, registry.QUERY_VALUE)
if err != nil {
seelog.Errorf("Unable to open Windows registry key to determine Windows version: %v", err)
return false, err
// Making it visible for unit testing
var execCommand = exec.Command

var IsWindows2016 = func() (bool, error) {
// Check for environment override before proceeding.
envSkipWindowsServerVersionCheck := utils.ParseBool(os.Getenv(envSkipWindowsServerVersionCheck), false)
if envSkipWindowsServerVersionCheck {
seelog.Debug("Skipping windows server version check based on environment override")
return false, nil
}
defer key.Close()

version, _, err := key.GetStringValue("ProductName")
cmd := "systeminfo | findstr /B /C:\"OS Name\""
out, err := execCommand("powershell", "-Command", cmd).CombinedOutput()
if err != nil {
seelog.Errorf("Unable to read current version from Windows registry: %v", err)
return false, err
}

if strings.HasPrefix(version, "Windows Server 2016") {
return true, nil
}
str := string(out)
isWS2016 := strings.Contains(str, "Microsoft Windows Server 2016 Datacenter")

return false, nil
return isWS2016, nil
}
2 changes: 1 addition & 1 deletion agent/config/parse_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestParseBooleanEnvVar(t *testing.T) {
}

func TestParseFSxWindowsFileServerCapability(t *testing.T) {
isWindows2016 = func() (bool, error) {
IsWindows2016 = func() (bool, error) {
return false, nil
}
os.Setenv("ECS_FSX_WINDOWS_FILE_SERVER_SUPPORTED", "False")
Expand Down
49 changes: 49 additions & 0 deletions agent/engine/ordering_integ_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/aws/amazon-ecs-agent/agent/api"
apicontainer "github.com/aws/amazon-ecs-agent/agent/api/container"
"github.com/aws/amazon-ecs-agent/agent/api/container/status"
"github.com/aws/amazon-ecs-agent/agent/config"
"github.com/aws/aws-sdk-go/aws"
"github.com/stretchr/testify/assert"
)
Expand All @@ -31,6 +32,12 @@ const orderingTimeout = 90 * time.Second
// TestDependencyHealthCheck is a happy-case integration test that considers a workflow with a HEALTHY dependency
// condition. We ensure that the task can be both started and stopped.
func TestDependencyHealthCheck(t *testing.T) {
// Skip these tests on WS 2016 until the failures are root-caused.
isWindows2016, err := config.IsWindows2016()
if err == nil && isWindows2016 == true {
t.Skip()
}

taskEngine, done, _ := setupWithDefaultConfig(t)
defer done()

Expand Down Expand Up @@ -84,6 +91,12 @@ func TestDependencyHealthCheck(t *testing.T) {
// TestDependencyComplete validates that the COMPLETE dependency condition will resolve when the child container exits
// with exit code 1. It ensures that the child is started and stopped before the parent starts.
func TestDependencyComplete(t *testing.T) {
// Skip these tests on WS 2016 until the failures are root-caused.
isWindows2016, err := config.IsWindows2016()
if err == nil && isWindows2016 == true {
t.Skip()
}

taskEngine, done, _ := setupWithDefaultConfig(t)
defer done()

Expand Down Expand Up @@ -137,6 +150,12 @@ func TestDependencyComplete(t *testing.T) {
// TestDependencySuccess validates that the SUCCESS dependency condition will resolve when the child container exits
// with exit code 0. It ensures that the child is started and stopped before the parent starts.
func TestDependencySuccess(t *testing.T) {
// Skip these tests on WS 2016 until the failures are root-caused.
isWindows2016, err := config.IsWindows2016()
if err == nil && isWindows2016 == true {
t.Skip()
}

taskEngine, done, _ := setupWithDefaultConfig(t)
defer done()

Expand Down Expand Up @@ -190,6 +209,12 @@ func TestDependencySuccess(t *testing.T) {
// TestDependencySuccess validates that the SUCCESS dependency condition will fail when the child exits 1. This is a
// contrast to how COMPLETE behaves. Instead of starting the parent, the task should simply exit.
func TestDependencySuccessErrored(t *testing.T) {
// Skip these tests on WS 2016 until the failures are root-caused.
isWindows2016, err := config.IsWindows2016()
if err == nil && isWindows2016 == true {
t.Skip()
}

taskEngine, done, _ := setupWithDefaultConfig(t)
defer done()

Expand Down Expand Up @@ -237,6 +262,12 @@ func TestDependencySuccessErrored(t *testing.T) {

// TestDependencySuccessTimeout
func TestDependencySuccessTimeout(t *testing.T) {
// Skip these tests on WS 2016 until the failures are root-caused.
isWindows2016, err := config.IsWindows2016()
if err == nil && isWindows2016 == true {
t.Skip()
}

taskEngine, done, _ := setupWithDefaultConfig(t)
defer done()

Expand Down Expand Up @@ -287,6 +318,12 @@ func TestDependencySuccessTimeout(t *testing.T) {

// TestDependencyHealthyTimeout
func TestDependencyHealthyTimeout(t *testing.T) {
// Skip these tests on WS 2016 until the failures are root-caused.
isWindows2016, err := config.IsWindows2016()
if err == nil && isWindows2016 == true {
t.Skip()
}

taskEngine, done, _ := setupWithDefaultConfig(t)
defer done()

Expand Down Expand Up @@ -344,6 +381,12 @@ func TestDependencyHealthyTimeout(t *testing.T) {

// TestShutdownOrder
func TestShutdownOrder(t *testing.T) {
// Skip these tests on WS 2016 until the failures are root-caused.
isWindows2016, err := config.IsWindows2016()
if err == nil && isWindows2016 == true {
t.Skip()
}

shutdownOrderingTimeout := 120 * time.Second
taskEngine, done, _ := setupWithDefaultConfig(t)
defer done()
Expand Down Expand Up @@ -434,6 +477,12 @@ func TestShutdownOrder(t *testing.T) {
}

func TestMultipleContainerDependency(t *testing.T) {
// Skip these tests on WS 2016 until the failures are root-caused.
isWindows2016, err := config.IsWindows2016()
if err == nil && isWindows2016 == true {
t.Skip()
}

taskEngine, done, _ := setupWithDefaultConfig(t)
defer done()

Expand Down
2 changes: 1 addition & 1 deletion agent/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ replace (
github.com/vishvananda/netns => github.com/vishvananda/netns v0.0.0-20171111001504-be1fbeda1936
golang.org/x/crypto => golang.org/x/crypto v0.0.0-20171113213409-9f005a07e0d3
golang.org/x/net => golang.org/x/net v0.0.0-20171107184841-a337091b0525
golang.org/x/sys => golang.org/x/sys v0.0.0-20171114162044-bf42f188b9bc
golang.org/x/sys => golang.org/x/sys v0.0.0-20190830141801-acfa387b8d69
golang.org/x/tools => golang.org/x/tools v0.0.0-20171114152239-bd4635fd2559
)
4 changes: 2 additions & 2 deletions agent/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAG
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20171114162044-bf42f188b9bc h1:pt5pMsz4A/sZRT17MOvX/nidmCt7n6ILLJBkNh5QqC8=
golang.org/x/sys v0.0.0-20171114162044-bf42f188b9bc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190830141801-acfa387b8d69 h1:Wdn4Yb8d5VrsO3jWgaeSZss09x1VLVBMePDh4VW/xSQ=
golang.org/x/sys v0.0.0-20190830141801-acfa387b8d69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
Expand Down
1 change: 1 addition & 0 deletions agent/vendor/golang.org/x/sys/unix/.gitignore

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

20 changes: 10 additions & 10 deletions agent/vendor/golang.org/x/sys/unix/README.md

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

Loading

0 comments on commit 0c1e813

Please sign in to comment.