-
Notifications
You must be signed in to change notification settings - Fork 618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Awsvpc windows : Check if the pause image is loaded on the container instance #2498
Conversation
Awsvpc windows
… We will cache pause image on ECS-Optimized Windows AMI. On agent startup, we check if the pause image is already loaded. The following changes are made as part of this commit: 1. Moved common functions from pause_linux.go to load.go 2. Moved the common code from IsLoaded function to a function in load.go 3. Unit tests for the same were moved from Linux specific files to common files This was a refactoring change with minimal addition of new code
agent/config/config_windows.go
Outdated
DefaultPauseContainerImageName = "amazonaws.com/ecs/pause-windows" | ||
DefaultPauseContainerTag = "latest" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not move these default values into the const block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed with @sparrc , we have added the Windows pause image name and tag in the Makefile and corresponding changes have been made in build file to invoke Windows agent build using the loader flags.
Additionally, a Powershell script has been created which can build standalone agent on Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall changes look good, left minor comments and questions.
agent/app/agent_windows.go
Outdated
@@ -279,5 +279,9 @@ func (agent *ecsAgent) getPlatformDevices() []*ecs.PlatformDevice { | |||
} | |||
|
|||
func (agent *ecsAgent) loadPauseContainer() error { | |||
return nil | |||
//The pause image would be cached in th ECS-Optimized Windows AMI's and will be available. We will throw an error if the image is not loaded. | |||
//If the agent is run on non-supported instances then pause image has to be loaded manually by the client. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by non-supported instance types and manual loading of pause container? Could you please elaborate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
non-supported instances are those which are launched using Non-ECS-Optimized Windows AMI. Manual loading of the pause container refers to creating/loading (using docker load) a pause image.
agent/config/config_windows.go
Outdated
@@ -57,6 +57,8 @@ func DefaultConfig() Config { | |||
programData := utils.DefaultIfBlank(os.Getenv("ProgramData"), `C:\ProgramData`) | |||
ecsRoot := filepath.Join(programData, "Amazon", "ECS") | |||
dataDir := filepath.Join(ecsRoot, "data") | |||
DefaultPauseContainerImageName = "amazonaws.com/ecs/pause-windows" | |||
DefaultPauseContainerTag = "latest" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does using latest
make sense given that we might use different ECS Optimized Windows AMIs?
Can the pause containers tag be something specific like ltsc2019
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering that ECS would support future releases of Windows, it would be advisable to use a generic tag. We can probably consider checking the version of windows on the pause container to ensure that it is using the supported version.
config.DefaultPauseContainerImageName, config.DefaultPauseContainerTag, dockerClient) | ||
|
||
if err != nil { | ||
return false, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are some errors wrapped and others not? Can you make it consistent across the module?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message returned from 'getPauseContainerImage' is sufficient to understand the error.
Therefore, we have returned the same error from this function.
agent/config/config_windows.go
Outdated
@@ -57,6 +57,8 @@ func DefaultConfig() Config { | |||
programData := utils.DefaultIfBlank(os.Getenv("ProgramData"), `C:\ProgramData`) | |||
ecsRoot := filepath.Join(programData, "Amazon", "ECS") | |||
dataDir := filepath.Join(ecsRoot, "data") | |||
DefaultPauseContainerImageName = "amazonaws.com/ecs/pause-windows" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be a const or a var?
Also should there be a mechanism for customers to override the defaultPauseContainer
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed with the agent team, we have added the Windows pause image name and tag in the Makefile and corresponding changes have been made in build file to invoke Windows agent build using the loader flags. The default values for both name and tag will be injected using the loader flag.
Additionally, a Powershell script has been created which can build standalone agent on Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you squash some of the commits into one? merges you'll have to leave as is, but at least the last 3 commits could be squashed into one commit.
d6d2264
to
3616559
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious why did you decide to add env vars for the windows pause container?
Currently we set the linux pause container name using build flags in the Makefile target (see https://github.com/aws/amazon-ecs-agent/blob/master/Makefile#L148)
Why was this pattern not followed? If there is some reason that windows cannot follow this pattern, perhaps we should make it consistent and set the linux pause container name and tag using env vars as well.
agent/config/config_windows.go
Outdated
|
||
// We check if the pause container image name and tag are overridden by setting an environment variable | ||
// If not then we assign the default name and tag | ||
pauseContainerImageNameFromEnv := os.Getenv("PAUSE_CONTAINER_IMAGE_NAME") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with our other env vars, these should be prepended with "ECS_"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, these should be parsed in the environmentConfig function, where we parse the rest of our env vars: https://github.com/aws/amazon-ecs-agent/blob/master/agent/config/config.go#L484
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following our offline discussion, we have decided against introducing any environment variables.
As discussed, we have added the Windows pause image name and tag in the Makefile and corresponding changes have been made in build file to invoke Windows agent build using the loader flags.
Additionally, a Powershell script has been created which can build standalone agent on Windows.
96e69fa
to
fe2291e
Compare
1. The pause container image name and tag have been moved to Makefile 2. The corresponding config is populated using loader flags at build time. This is similar to how Linux agent populates these values 3. Formatting changes 4. Modified the Readme
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…instance (aws#2498) * Changes to check if the pause image has been loaded on agent startup. We will cache pause image on ECS-Optimized Windows AMI. On agent startup, we check if the pause image is already loaded. The following changes are made as part of this commit: 1. Moved common functions from pause_linux.go to load.go 2. Moved the common code from IsLoaded function to a function in load.go 3. Unit tests for the same were moved from Linux specific files to common files This was a refactoring change with minimal addition of new code
…instance (aws#2498) * Changes to check if the pause image has been loaded on agent startup. We will cache pause image on ECS-Optimized Windows AMI. On agent startup, we check if the pause image is already loaded. The following changes are made as part of this commit: 1. Moved common functions from pause_linux.go to load.go 2. Moved the common code from IsLoaded function to a function in load.go 3. Unit tests for the same were moved from Linux specific files to common files This was a refactoring change with minimal addition of new code
…instance (aws#2498) * Changes to check if the pause image has been loaded on agent startup. We will cache pause image on ECS-Optimized Windows AMI. On agent startup, we check if the pause image is already loaded. The following changes are made as part of this commit: 1. Moved common functions from pause_linux.go to load.go 2. Moved the common code from IsLoaded function to a function in load.go 3. Unit tests for the same were moved from Linux specific files to common files
…instance (aws#2498) * Changes to check if the pause image has been loaded on agent startup. We will cache pause image on ECS-Optimized Windows AMI. On agent startup, we check if the pause image is already loaded. The following changes are made as part of this commit: 1. Moved common functions from pause_linux.go to load.go 2. Moved the common code from IsLoaded function to a function in load.go 3. Unit tests for the same were moved from Linux specific files to common files
…instance (aws#2498) * Changes to check if the pause image has been loaded on agent startup. We will cache pause image on ECS-Optimized Windows AMI. On agent startup, we check if the pause image is already loaded. The following changes are made as part of this commit: 1. Moved common functions from pause_linux.go to load.go 2. Moved the common code from IsLoaded function to a function in load.go 3. Unit tests for the same were moved from Linux specific files to common files
…instance (aws#2498) * Changes to check if the pause image has been loaded on agent startup. We will cache pause image on ECS-Optimized Windows AMI. On agent startup, we check if the pause image is already loaded. The following changes are made as part of this commit: 1. Moved common functions from pause_linux.go to load.go 2. Moved the common code from IsLoaded function to a function in load.go 3. Unit tests for the same were moved from Linux specific files to common files
…instance (aws#2498) * Changes to check if the pause image has been loaded on agent startup. We will cache pause image on ECS-Optimized Windows AMI. On agent startup, we check if the pause image is already loaded. The following changes are made as part of this commit: 1. Moved common functions from pause_linux.go to load.go 2. Moved the common code from IsLoaded function to a function in load.go 3. Unit tests for the same were moved from Linux specific files to common files
…instance (aws#2498) * Changes to check if the pause image has been loaded on agent startup. We will cache pause image on ECS-Optimized Windows AMI. On agent startup, we check if the pause image is already loaded. The following changes are made as part of this commit: 1. Moved common functions from pause_linux.go to load.go 2. Moved the common code from IsLoaded function to a function in load.go 3. Unit tests for the same were moved from Linux specific files to common files
Summary
This change is the first step for enabling awsvpc network mode for ECS Windows.
We will be caching pause image in the ECS-Optimized Windows AMI. When the agent starts, we will check if the pause image has been loaded. Without a pause container image loaded on the container instance, awsvpc mode cannot be supported by the instance.
The changes are specific for Windows instances.
Implementation details
Majority of the changes are refactoring of existing code which is used in Linux. We have made following changes-
Moved common functions from pause_linux.go to load.go
Moved the common code from IsLoaded function to a function in load.go
Unit tests for the same were moved from Linux specific test files to common test files
Testing
The unit tests and integration tests were executed on Linux and Windows platform.
New tests cover the changes:
No. We will be reusing the existing code and relevant unit tests which have been moved to the common files.
New tests cover the changes:
Description for the changelog
On agent startup for Windows instances, check if the pause image has been loaded.
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.