Skip to content

Commit 0aabad1

Browse files
committed
Merge remote-tracking branch 'origin/dev' into jchorl/updatecgroup
2 parents 1803e8c + c461602 commit 0aabad1

File tree

477 files changed

+88729
-12860
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

477 files changed

+88729
-12860
lines changed

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,11 @@ docker-release: pause-container-release cni-plugins .out-stamp
108108
--rm \
109109
"amazon/amazon-ecs-agent-${BUILD}:make"
110110

111+
ifeq (${TARGET_OS},windows)
112+
CSI_DRIVER_EXE=ebs-csi-driver
113+
endif
111114
# Legacy target : Release packages our agent into a "scratch" based dockerfile
112-
release: certs docker-release
115+
release: certs docker-release ${CSI_DRIVER_EXE}
113116
@./scripts/create-amazon-ecs-scratch
114117
@docker build -f scripts/dockerfiles/Dockerfile.release -t "amazon/amazon-ecs-agent:latest" .
115118
@echo "Built Docker image \"amazon/amazon-ecs-agent:latest\""

agent/api/task/task.go

+1
Original file line numberDiff line numberDiff line change
@@ -1781,6 +1781,7 @@ func (task *Task) dockerConfig(container *apicontainer.Container, apiVersion doc
17811781
return nil, &apierrors.DockerClientConfigError{Msg: "Unable decode given docker config: " + err.Error()}
17821782
}
17831783
}
1784+
17841785
if container.HealthCheckType == apicontainer.DockerHealthCheckType && containerConfig.Healthcheck == nil {
17851786
return nil, &apierrors.DockerClientConfigError{
17861787
Msg: "docker health check is nil while container health check type is DOCKER"}

agent/api/task/task_windows.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,22 @@ package task
1919
import (
2020
"time"
2121

22-
"github.com/aws/amazon-ecs-agent/agent/ecscni"
23-
"github.com/aws/amazon-ecs-agent/agent/utils"
24-
"github.com/aws/amazon-ecs-agent/ecs-agent/logger"
25-
"github.com/aws/amazon-ecs-agent/ecs-agent/logger/field"
26-
"github.com/containernetworking/cni/libcni"
27-
2822
"github.com/aws/amazon-ecs-agent/agent/config"
23+
"github.com/aws/amazon-ecs-agent/agent/ecscni"
2924
"github.com/aws/amazon-ecs-agent/agent/taskresource"
3025
"github.com/aws/amazon-ecs-agent/agent/taskresource/fsxwindowsfileserver"
3126
resourcetype "github.com/aws/amazon-ecs-agent/agent/taskresource/types"
3227
taskresourcevolume "github.com/aws/amazon-ecs-agent/agent/taskresource/volume"
28+
"github.com/aws/amazon-ecs-agent/agent/utils"
29+
"github.com/aws/amazon-ecs-agent/ecs-agent/logger"
30+
"github.com/aws/amazon-ecs-agent/ecs-agent/logger/field"
31+
3332
"github.com/aws/amazon-ecs-agent/ecs-agent/credentials"
3433
ni "github.com/aws/amazon-ecs-agent/ecs-agent/netlib/model/networkinterface"
3534
eautils "github.com/aws/amazon-ecs-agent/ecs-agent/utils"
35+
3636
"github.com/cihub/seelog"
37+
"github.com/containernetworking/cni/libcni"
3738
dockercontainer "github.com/docker/docker/api/types/container"
3839
"github.com/pkg/errors"
3940
)

agent/app/agent_unix.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func (agent *ecsAgent) startEBSWatcher(
159159
) {
160160
if agent.ebsWatcher == nil {
161161
seelog.Debug("Creating new EBS watcher...")
162-
agent.ebsWatcher = ebs.NewWatcher(agent.ctx, state, taskEngine, dockerClient)
162+
agent.ebsWatcher = ebs.NewWatcher(agent.ctx, agent.cfg, state, taskEngine, dockerClient)
163163
go agent.ebsWatcher.Start()
164164
}
165165
}

agent/app/agent_windows.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
asmfactory "github.com/aws/amazon-ecs-agent/agent/asm/factory"
2626
"github.com/aws/amazon-ecs-agent/agent/data"
2727
"github.com/aws/amazon-ecs-agent/agent/dockerclient/dockerapi"
28+
ebs "github.com/aws/amazon-ecs-agent/agent/ebs"
2829
"github.com/aws/amazon-ecs-agent/agent/ecscni"
2930
"github.com/aws/amazon-ecs-agent/agent/engine"
3031
"github.com/aws/amazon-ecs-agent/agent/engine/dockerstate"
@@ -105,7 +106,11 @@ func (agent *ecsAgent) startEBSWatcher(
105106
taskEngine engine.TaskEngine,
106107
dockerClient dockerapi.DockerClient,
107108
) {
108-
seelog.Debug("Windows EBS Watcher not implemented: No Op")
109+
if agent.ebsWatcher == nil {
110+
seelog.Debug("Creating new EBS watcher...")
111+
agent.ebsWatcher = ebs.NewWatcher(agent.ctx, agent.cfg, state, taskEngine, dockerClient)
112+
go agent.ebsWatcher.Start()
113+
}
109114
}
110115

111116
// handler implements https://godoc.org/golang.org/x/sys/windows/svc#Handler

agent/config/config_unix.go

+9
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ const (
6060
minimumContainerCreateTimeout = 1 * time.Minute
6161
// default docker inactivity time is extra time needed on container extraction
6262
defaultImagePullInactivityTimeout = 1 * time.Minute
63+
// default socket filepath is "/var/run/ecs/ebs-csi-driver/csi-driver.sock"
64+
defaultCSIDriverSocketPath = "/var/run/ecs/ebs-csi-driver/csi-driver.sock"
65+
// nodeStageTimeout is the deafult timeout for staging an EBS TA volume
66+
nodeStageTimeout = 2 * time.Second
67+
// nodeUnstageTimeout is the deafult timeout for unstaging an EBS TA volume
68+
nodeUnstageTimeout = 30 * time.Second
6369
)
6470

6571
// DefaultConfig returns the default configuration for Linux
@@ -112,6 +118,9 @@ func DefaultConfig() Config {
112118
RuntimeStatsLogFile: defaultRuntimeStatsLogFile,
113119
EnableRuntimeStats: BooleanDefaultFalse{Value: NotSet},
114120
ShouldExcludeIPv6PortBinding: BooleanDefaultTrue{Value: ExplicitlyEnabled},
121+
CSIDriverSocketPath: defaultCSIDriverSocketPath,
122+
NodeStageTimeout: nodeStageTimeout,
123+
NodeUnstageTimeout: nodeUnstageTimeout,
115124
}
116125
}
117126

agent/config/config_unix_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ func TestConfigDefault(t *testing.T) {
7777
assert.False(t, cfg.EnableRuntimeStats.Enabled(), "Default EnableRuntimeStats set incorrectly")
7878
assert.True(t, cfg.ShouldExcludeIPv6PortBinding.Enabled(), "Default ShouldExcludeIPv6PortBinding set incorrectly")
7979
assert.False(t, cfg.FSxWindowsFileServerCapable.Enabled(), "Default FSxWindowsFileServerCapable set incorrectly")
80+
assert.Equal(t, "/var/run/ecs/ebs-csi-driver/csi-driver.sock", cfg.CSIDriverSocketPath, "Default CSIDriverSocketPath set incorrectly")
81+
assert.Equal(t, 2*time.Second, cfg.NodeStageTimeout, "Default NodeStage timeout set incorrectly")
82+
assert.Equal(t, 30*time.Second, cfg.NodeUnstageTimeout, "Default NodeUntage timeout set incorrectly")
8083
}
8184

8285
// TestConfigFromFile tests the configuration can be read from file

agent/config/config_windows.go

+9
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ const (
7676
adminSid = "S-1-5-32-544"
7777
// default directory name of CNI Plugins
7878
defaultCNIPluginDirName = "cni"
79+
// Setting the node stage and unstage timeout to 600 seconds as Windows takes longer to stage and unstage volumes
80+
// nodeStageTimeout is the deafult timeout for staging an EBS TA volume
81+
nodeStageTimeout = 600 * time.Second
82+
// nodeUnstageTimeout is the deafult timeout for unstaging an EBS TA volume
83+
nodeUnstageTimeout = 600 * time.Second
7984
)
8085

8186
var (
@@ -97,6 +102,7 @@ func DefaultConfig() Config {
97102

98103
programFiles := utils.DefaultIfBlank(os.Getenv("ProgramFiles"), `C:\Program Files`)
99104
ecsBinaryDir := filepath.Join(programFiles, "Amazon", "ECS")
105+
defaultCSIDriverSocketPath := filepath.Join(ecsRoot, "ebs-csi-driver", "csi-driver.sock")
100106

101107
platformVariables := PlatformVariables{
102108
CPUUnbounded: BooleanDefaultFalse{Value: ExplicitlyDisabled},
@@ -157,6 +163,9 @@ func DefaultConfig() Config {
157163
RuntimeStatsLogFile: filepath.Join(ecsRoot, defaultRuntimeStatsLogFile),
158164
EnableRuntimeStats: BooleanDefaultFalse{Value: NotSet},
159165
ShouldExcludeIPv6PortBinding: BooleanDefaultTrue{Value: ExplicitlyEnabled},
166+
CSIDriverSocketPath: defaultCSIDriverSocketPath,
167+
NodeStageTimeout: nodeStageTimeout,
168+
NodeUnstageTimeout: nodeUnstageTimeout,
160169
}
161170
}
162171

agent/config/config_windows_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ func TestConfigDefault(t *testing.T) {
7373
assert.False(t, cfg.EnableRuntimeStats.Enabled(), "Default EnableRuntimeStats set incorrectly")
7474
assert.True(t, cfg.ShouldExcludeIPv6PortBinding.Enabled(), "Default ShouldExcludeIPv6PortBinding set incorrectly")
7575
assert.True(t, cfg.FSxWindowsFileServerCapable.Enabled(), "Default FSxWindowsFileServerCapable set incorrectly")
76+
assert.Equal(t, "C:\\ProgramData\\Amazon\\ECS\\ebs-csi-driver\\csi-driver.sock", cfg.CSIDriverSocketPath, "Default CSIDriverSocketPath set incorrectly")
77+
assert.Equal(t, 600*time.Second, cfg.NodeStageTimeout, "Default NodeStage timeout set incorrectly")
78+
assert.Equal(t, 600*time.Second, cfg.NodeUnstageTimeout, "Default NodeUntage timeout set incorrectly")
7679
}
7780

7881
func TestConfigIAMTaskRolesReserves80(t *testing.T) {

agent/config/const_linux.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,11 @@
1616

1717
package config
1818

19-
// OSType is the type of operating system where agent is running
20-
const OSType = "linux"
19+
const (
20+
// OSType is the type of operating system where agent is running
21+
OSType = "linux"
22+
// This is the path that will be used for the csi-driver socker
23+
ManagedDaemonSocketPathHostRoot = "/var/run/ecs"
24+
// This is the path that will be used to store the log file for the CSI Driver Managed Daemon
25+
ManagedDaemonLogPathHostRoot = "/log/daemons"
26+
)

agent/config/const_windows.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,12 @@
1717
package config
1818

1919
// OSType is the type of operating system where agent is running
20-
const OSType = "windows"
20+
const (
21+
OSType = "windows"
22+
// containerAdminUser is the admin username for any container on Windows.
23+
ContainerAdminUser = "ContainerAdministrator"
24+
// This is the path that will be used to store the local named pipe for CSI Proxy
25+
ManagedDaemonSocketPathHostRoot = "C:\\ProgramData\\Amazon\\ECS\\ebs-csi-driver"
26+
// This is the path that will be used to store the log file for the CSI Driver Managed Daemon
27+
ManagedDaemonLogPathHostRoot = "C:\\ProgramData\\Amazon\\ECS\\log\\daemons"
28+
)

agent/config/types.go

+10
Original file line numberDiff line numberDiff line change
@@ -384,4 +384,14 @@ type Config struct {
384384
// cgroup setting at the ECS task level.
385385
// see https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html#pid
386386
TaskPidsLimit int
387+
388+
// CSIDriverSocketPath specifies the path that the CSI driver socket file is located at.
389+
// Defaults to "/var/run/ecs/ebs-csi-driver/csi-driver.sock"
390+
CSIDriverSocketPath string
391+
392+
// NodeStageTimeout is the amount of time to wait for staging an EBS TA volume
393+
NodeStageTimeout time.Duration
394+
395+
// NodeUnstageTimeout is the amount of time to wait for unstaging an EBS TA volume
396+
NodeUnstageTimeout time.Duration
387397
}

agent/ebs/watcher.go

+6-8
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"time"
2323

2424
ecsapi "github.com/aws/amazon-ecs-agent/agent/api"
25+
"github.com/aws/amazon-ecs-agent/agent/config"
2526
"github.com/aws/amazon-ecs-agent/agent/dockerclient/dockerapi"
2627
ecsengine "github.com/aws/amazon-ecs-agent/agent/engine"
2728
"github.com/aws/amazon-ecs-agent/agent/engine/dockerstate"
@@ -36,17 +37,13 @@ import (
3637
v1 "k8s.io/api/core/v1"
3738
)
3839

39-
const (
40-
nodeStageTimeout = 2 * time.Second
41-
hostMountDir = "/mnt/ecs/ebs"
42-
)
43-
4440
type EBSWatcher struct {
4541
ctx context.Context
4642
cancel context.CancelFunc
4743
agentState dockerstate.TaskEngineState
4844
// TODO: The dataClient will be used to save to agent's data client as well as start the ACK timer. This will be added once the data client functionality have been added
4945
// dataClient data.Client
46+
cfg *config.Config
5047
discoveryClient apiebs.EBSDiscovery
5148
csiClient csi.CSIClient
5249
scanTicker *time.Ticker
@@ -57,15 +54,16 @@ type EBSWatcher struct {
5754

5855
// NewWatcher is used to return a new instance of the EBSWatcher struct
5956
func NewWatcher(ctx context.Context,
57+
cfg *config.Config,
6058
state dockerstate.TaskEngineState,
6159
taskEngine ecsengine.TaskEngine,
6260
dockerClient dockerapi.DockerClient) *EBSWatcher {
6361
derivedContext, cancel := context.WithCancel(ctx)
6462
discoveryClient := apiebs.NewDiscoveryClient(derivedContext)
65-
// TODO pull this socket out into config
66-
csiClient := csi.NewCSIClient("/var/run/ecs/ebs-csi-driver/csi-driver.sock")
63+
csiClient := csi.NewCSIClient(cfg.CSIDriverSocketPath)
6764
return &EBSWatcher{
6865
ctx: derivedContext,
66+
cfg: cfg,
6967
cancel: cancel,
7068
agentState: state,
7169
discoveryClient: discoveryClient,
@@ -266,7 +264,7 @@ func (w *EBSWatcher) stageVolumeEBS(volID, deviceName string) error {
266264
stubFsGroup, _ := strconv.ParseInt("123456", 10, 8)
267265
publishContext := map[string]string{"devicePath": deviceName}
268266
// call CSI NodeStage
269-
timeoutCtx, cancelFunc := context.WithTimeout(w.ctx, nodeStageTimeout)
267+
timeoutCtx, cancelFunc := context.WithTimeout(w.ctx, w.cfg.NodeStageTimeout)
270268
defer cancelFunc()
271269
err := w.csiClient.NodeStageVolume(timeoutCtx,
272270
volID,

agent/ebs/watcher_linux.go

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//go:build linux
2+
// +build linux
3+
4+
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License"). You may
7+
// not use this file except in compliance with the License. A copy of the
8+
// License is located at
9+
//
10+
// http://aws.amazon.com/apache2.0/
11+
//
12+
// or in the "license" file accompanying this file. This file is distributed
13+
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14+
// express or implied. See the License for the specific language governing
15+
// permissions and limitations under the License.
16+
17+
package ebs
18+
19+
const (
20+
hostMountDir = "/mnt/ecs/ebs"
21+
)

agent/ebs/watcher_linux_test.go

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//go:build linux && unit
2+
// +build linux,unit
3+
4+
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License"). You may
7+
// not use this file except in compliance with the License. A copy of the
8+
// License is located at
9+
//
10+
// http://aws.amazon.com/apache2.0/
11+
//
12+
// or in the "license" file accompanying this file. This file is distributed
13+
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14+
// express or implied. See the License for the specific language governing
15+
// permissions and limitations under the License.
16+
17+
package ebs
18+
19+
const (
20+
CSIDriverSocketPath = "/var/run/ecs/ebs-csi-driver/csi-driver.sock"
21+
)

agent/ebs/watcher_test.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"time"
2727

2828
"github.com/aws/amazon-ecs-agent/agent/api/task"
29+
"github.com/aws/amazon-ecs-agent/agent/config"
2930
mock_dockerapi "github.com/aws/amazon-ecs-agent/agent/dockerclient/dockerapi/mocks"
3031
"github.com/aws/amazon-ecs-agent/agent/engine"
3132
"github.com/aws/amazon-ecs-agent/agent/engine/daemonmanager"
@@ -60,8 +61,10 @@ const (
6061
func newTestEBSWatcher(ctx context.Context, agentState dockerstate.TaskEngineState,
6162
discoveryClient apiebs.EBSDiscovery, taskEngine engine.TaskEngine, csiClient csi.CSIClient) *EBSWatcher {
6263
derivedContext, cancel := context.WithCancel(ctx)
64+
defaultConfig := config.DefaultConfig()
6365
return &EBSWatcher{
6466
ctx: derivedContext,
67+
cfg: &defaultConfig,
6568
cancel: cancel,
6669
agentState: agentState,
6770
discoveryClient: discoveryClient,
@@ -737,7 +740,8 @@ func TestTick(t *testing.T) {
737740
tc.setDiscoveryClientExpectations(discoveryClient)
738741
}
739742

740-
watcher := NewWatcher(context.Background(), taskEngineState, taskEngine, dockerClient)
743+
defaultConfig := config.DefaultConfig()
744+
watcher := NewWatcher(context.Background(), &defaultConfig, taskEngineState, taskEngine, dockerClient)
741745
watcher.discoveryClient = discoveryClient
742746
watcher.tick()
743747

agent/ebs/watcher_unsupported.go

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//go:build !linux && !windows
2+
// +build !linux,!windows
3+
4+
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License"). You may
7+
// not use this file except in compliance with the License. A copy of the
8+
// License is located at
9+
//
10+
// http://aws.amazon.com/apache2.0/
11+
//
12+
// or in the "license" file accompanying this file. This file is distributed
13+
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14+
// express or implied. See the License for the specific language governing
15+
// permissions and limitations under the License.
16+
17+
package ebs
18+
19+
const (
20+
hostMountDir = ""
21+
)

agent/ebs/watcher_windows.go

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//go:build windows
2+
// +build windows
3+
4+
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License"). You may
7+
// not use this file except in compliance with the License. A copy of the
8+
// License is located at
9+
//
10+
// http://aws.amazon.com/apache2.0/
11+
//
12+
// or in the "license" file accompanying this file. This file is distributed
13+
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14+
// express or implied. See the License for the specific language governing
15+
// permissions and limitations under the License.
16+
17+
package ebs
18+
19+
const (
20+
// Host mount root path where the EBS volumes will be mounted
21+
hostMountDir = "C:\\ProgramData\\Amazon\\ECS\\ebs\\"
22+
)

agent/ebs/watcher_windows_test.go

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//go:build windows && unit
2+
// +build windows,unit
3+
4+
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License"). You may
7+
// not use this file except in compliance with the License. A copy of the
8+
// License is located at
9+
//
10+
// http://aws.amazon.com/apache2.0/
11+
//
12+
// or in the "license" file accompanying this file. This file is distributed
13+
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14+
// express or implied. See the License for the specific language governing
15+
// permissions and limitations under the License.
16+
17+
package ebs
18+
19+
const (
20+
CSIDriverSocketPath = "C:\\ProgramData\\Amazon\\ECS\\ebs-csi-driver\\csi-driver.sock"
21+
)

0 commit comments

Comments
 (0)