diff --git a/agent/api/task/task_windows.go b/agent/api/task/task_windows.go index 1a036e1842a..1c7061a8eaf 100644 --- a/agent/api/task/task_windows.go +++ b/agent/api/task/task_windows.go @@ -74,7 +74,22 @@ func (task *Task) downcaseAllVolumePaths() { } func getCanonicalPath(path string) string { - return filepath.Clean(strings.ToLower(path)) + lowercasedPath := strings.ToLower(path) + // if the path is a bare drive like "d:", don't filepath.Clean it because it will add a '.'. + // this is to fix the case where mounting from D:\ to D: is supported by docker but not ecs + if isBareDrive(lowercasedPath) { + return lowercasedPath + } + + return filepath.Clean(lowercasedPath) +} + +func isBareDrive(path string) bool { + if filepath.VolumeName(path) == path { + return true + } + + return false } // platformHostConfigOverride provides an entry point to set up default HostConfig options to be diff --git a/agent/api/task/task_windows_test.go b/agent/api/task/task_windows_test.go index a92ef38b028..932ab54387e 100644 --- a/agent/api/task/task_windows_test.go +++ b/agent/api/task/task_windows_test.go @@ -295,3 +295,29 @@ func TestCPUPercentBasedOnUnboundedEnabled(t *testing.T) { }) } } + +func TestGetCanonicalPath(t *testing.T) { + testcases := []struct { + name string + path string + expectedResult string + }{ + { + name: "folderPath", + path: `C:\myFile`, + expectedResult: `c:\myfile`, + }, + { + name: "drivePath", + path: `D:`, + expectedResult: `d:`, + }, + } + + for _, tc := range testcases { + t.Run(tc.name, func(t *testing.T) { + result := getCanonicalPath(tc.path) + assert.Equal(t, result, tc.expectedResult) + }) + } +}