Skip to content

Commit 9124443

Browse files
jiuchoe4saurabhc123
authored andcommitted
Add implementation of CSI-Driver for Windows (#3)
* Added the first cut of the implementation for the CSIDriver. * Cleaned the branch with unneeded vendor files. --------- Co-authored-by: Saurabh Chakravarty <[email protected]>
1 parent df1820c commit 9124443

29 files changed

+2117
-55
lines changed

agent/app/agent_unix.go

Lines changed: 1 addition & 1 deletion
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, state, taskEngine, dockerClient, agent.cfg.CSIDriverSocketPath)
163163
go agent.ebsWatcher.Start()
164164
}
165165
}

agent/app/agent_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func (agent *ecsAgent) startEBSWatcher(
108108
) {
109109
if agent.ebsWatcher == nil {
110110
seelog.Debug("Creating new EBS watcher...")
111-
agent.ebsWatcher = ebs.NewWatcher(agent.ctx, state, taskEngine, dockerClient)
111+
agent.ebsWatcher = ebs.NewWatcher(agent.ctx, state, taskEngine, dockerClient, agent.cfg.CSIDriverSocketPath)
112112
go agent.ebsWatcher.Start()
113113
}
114114
}

agent/config/config_unix.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ 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"
6365
)
6466

6567
// DefaultConfig returns the default configuration for Linux
@@ -112,6 +114,7 @@ func DefaultConfig() Config {
112114
RuntimeStatsLogFile: defaultRuntimeStatsLogFile,
113115
EnableRuntimeStats: BooleanDefaultFalse{Value: NotSet},
114116
ShouldExcludeIPv6PortBinding: BooleanDefaultTrue{Value: ExplicitlyEnabled},
117+
CSIDriverSocketPath: defaultCSIDriverSocketPath,
115118
}
116119
}
117120

agent/config/config_unix_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ 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")
8081
}
8182

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

agent/config/config_windows.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ func DefaultConfig() Config {
9797

9898
programFiles := utils.DefaultIfBlank(os.Getenv("ProgramFiles"), `C:\Program Files`)
9999
ecsBinaryDir := filepath.Join(programFiles, "Amazon", "ECS")
100+
defaultCSIDriverSocketPath := filepath.Join(ecsBinaryDir, "ebs-csi-driver", "csi-driver.sock")
100101

101102
platformVariables := PlatformVariables{
102103
CPUUnbounded: BooleanDefaultFalse{Value: ExplicitlyDisabled},
@@ -157,6 +158,7 @@ func DefaultConfig() Config {
157158
RuntimeStatsLogFile: filepath.Join(ecsRoot, defaultRuntimeStatsLogFile),
158159
EnableRuntimeStats: BooleanDefaultFalse{Value: NotSet},
159160
ShouldExcludeIPv6PortBinding: BooleanDefaultTrue{Value: ExplicitlyEnabled},
161+
CSIDriverSocketPath: defaultCSIDriverSocketPath,
160162
}
161163
}
162164

agent/config/config_windows_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ 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:\\Program Files\\Amazon\\ECS\\ebs-csi-driver\\csi-driver.sock", cfg.CSIDriverSocketPath, "Default CSIDriverSocketPath set incorrectly")
7677
}
7778

7879
func TestConfigIAMTaskRolesReserves80(t *testing.T) {

agent/config/types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,4 +384,8 @@ 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
387391
}

agent/ebs/watcher.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ type EBSWatcher struct {
5959
func NewWatcher(ctx context.Context,
6060
state dockerstate.TaskEngineState,
6161
taskEngine ecsengine.TaskEngine,
62-
dockerClient dockerapi.DockerClient) *EBSWatcher {
62+
dockerClient dockerapi.DockerClient,
63+
csiDriverSocketPath string) *EBSWatcher {
6364
derivedContext, cancel := context.WithCancel(ctx)
6465
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")
66+
csiClient := csi.NewCSIClient(csiDriverSocketPath)
6767
return &EBSWatcher{
6868
ctx: derivedContext,
6969
cancel: cancel,

agent/ebs/watcher_linux_test.go

Lines changed: 21 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ func TestTick(t *testing.T) {
737737
tc.setDiscoveryClientExpectations(discoveryClient)
738738
}
739739

740-
watcher := NewWatcher(context.Background(), taskEngineState, taskEngine, dockerClient)
740+
watcher := NewWatcher(context.Background(), taskEngineState, taskEngine, dockerClient, CSIDriverSocketPath)
741741
watcher.discoveryClient = discoveryClient
742742
watcher.tick()
743743

0 commit comments

Comments
 (0)