Skip to content

Added the Windows DaemonManager and ManagedDaemon - #2

Open
saurabhc123 wants to merge 6 commits into
ebsAttachWindowsfrom
windowsDaemonManager
Open

saurabhc123 wants to merge 6 commits into
ebsAttachWindowsfrom
windowsDaemonManager

Conversation

@saurabhc123

Copy link
Copy Markdown
Owner

Summary

This PR adds the DaemonManager and ManagedDaemon components to support EBS-TaskAttach for Windows.

Implementation details

We refactored the existing DaemonManager and ManagedDaemon modules for linux and repurposed the high-level workflow. The platform specific details were moved to the respective windows/linux modules.

Testing

We used the existing linux tests and refactored them so that all of them can be repurposed for Windows.

New tests cover the changes: Yes

Description for the changelog

Add support EBS-TaskAttach for Windows.

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Comment thread agent/api/task/task_linux.go Outdated
return errors.New("task with FSx for Windows File Server volumes is only supported on Windows container instance")
}

func (task *Task) getTaskUser(container *container.Container) string {

@rawahars rawahars Jun 4, 2024

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code will return empty user string for Linux when the conditions are not met.
That is not how it is in presently for Linux.

Maybe return container.user itself

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got this verified by the Linux team. They don't care about what user it is. I also checked with them on the change of the sequence of operation too. They agreed with the change.

@rawahars rawahars Jun 6, 2024

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically it is correct as the struct is declared in the method and therefore would be initialised with empty string. But think from method construction viewpoint, the name is getTaskUser and it returns empty unless specific conditions are met. It sets an incorrect precedent for the future where folks would be confused about the reason for setting it as empty and not returning the actual user.

I would strongly suggest that this be rectified.

Comment thread agent/api/task/task_windows.go Outdated
Comment thread agent/ebs/watcher_windows.go Outdated

const (
csiDriverSocketAddress = "C:\\ProgramData\\Amazon\\ECS\\ebs-csi-driver\\csi-driver.sock"
hostMountDir = "C:\\var\\lib\\kubelet"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we have kubelet here?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CSIProxt won't allow to mount in any folder other than something under this. This needs to be investigated further for the CSIDriver work.

logger.Fields{
field.Image: loadedImageRef,
})
mountPoint := dockermount.Mount{

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why mounts were skipped in the common code?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No mounts were skipped in the common code. The previous code was hardcoding the mount type to bind and we want some of our mounts to be npipe which we are passing from upstream and processing accordingly.

https://github.com/saurabhc123/amazon-ecs-agent/pull/2/files#diff-c27a802d01286c3a45f84d314f4bf1feb2448370cba4991ebf67d9afdc433d5aR116-R131

Comment thread agent/engine/daemonmanager/daemon_manager_test.go
Comment thread agent/engine/daemonmanager/daemon_manager_windows.go Outdated
Comment thread agent/engine/daemonmanager/daemon_manager_windows.go Outdated
Comment thread agent/utils/utils_windows.go
fsTypeBlockName = "block"
)

func DefaultSocketFilePath() string {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add comments

)

const (
imageTarPath = "C:\\ProgramData\\Amazon\\ECS\\data\\"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need a separate file with the same method.
Can we just convert the values as constants declared in platform files and then keep the method common?

imageTarPath = "C:\\ProgramData\\Amazon\\ECS\\data\\"
imageTagDefault = "latest"
defaultAgentCommunicationPathHostRoot = "C:\\ProgramData\\Amazon\\ECS"
defaultApplicationLogPathHostRoot = "C:\\ProgramData\\Amazon\\ECS\\log"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, please do not hardcode ProgramData directly as on ECS EC2, customers can set their own path for the same.

)

const (
imageTarPath = "C:\\ProgramData\\Amazon\\ECS\\data\\"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments as earlier. I don't think we need to copy and fork the method.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only method that needs forking. Reason being, there are different mount points for Windows and especially because of the additional ones for the CSIProxy. In addition to this, the configuration of ADMIN and the KernelCapabilities (windows doesn't need it) varies between linux and windows. There is very little common between them.

Comment thread agent/api/task/task_windows.go Outdated

// For Windows task run via the docker DaemonManager, we will run them as ContainerAdministrator
func (task *Task) getTaskUser(container *container.Container) string {
return config.ContainerAdminUser

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, we need to check the code paths from where the docker config method is called. Setting user to containerAdministrator in all container configs can have unintended impact. Take example that a customer specifies a lower user to run the container but we set it to Admin.

Correct approach would be to not pass the user for Windows. Keep it empty and then let the container take user as defined in the image.

// containerAdminUser is the admin username for any container on Windows.
ContainerAdminUser = "ContainerAdministrator"
// This is the path that will be used to store the local named pipe for CSI Proxy
ManagedDaemonSocketPathHostRoot = "C:\\ProgramData\\Amazon\\ECS\\ebs-csi-driver"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as comment from previous review.

Please do not hardcode ProgramData path. It can change dynamically on ECS EC2.
Correct approach is to construct it via ProgramData Env as has been done in other parts of the agent.

@rawahars

rawahars commented Jun 6, 2024

Copy link
Copy Markdown

While the review is not completely ready to be shipped, there are not grave concerns except a few regarding setting of container user. Please create a formal PR in the aws repo and I can provide other review comments there. That would help Linux team have context and can chime in if needed about the practises they use in the agent.

@jiuchoe4
jiuchoe4 force-pushed the ebsAttachWindows branch from b88b1e3 to 437e051 Compare July 3, 2024 19:42
@saurabhc123
saurabhc123 force-pushed the windowsDaemonManager branch 6 times, most recently from d7ea047 to 6661a29 Compare July 10, 2024 20:32
@jiuchoe4
jiuchoe4 force-pushed the ebsAttachWindows branch 5 times, most recently from e8caab6 to cb8525b Compare July 12, 2024 21:02
@saurabhc123
saurabhc123 force-pushed the windowsDaemonManager branch from 6661a29 to 7983f48 Compare July 12, 2024 23:09
@saurabhc123
saurabhc123 force-pushed the windowsDaemonManager branch 2 times, most recently from 0046c02 to 67b17ce Compare July 12, 2024 23:23
@jiuchoe4
jiuchoe4 force-pushed the ebsAttachWindows branch 2 times, most recently from 397d052 to ec9bde1 Compare July 15, 2024 20:07
@jiuchoe4
jiuchoe4 force-pushed the windowsDaemonManager branch 3 times, most recently from 82fc629 to 64718fc Compare July 16, 2024 21:56
@jiuchoe4
jiuchoe4 force-pushed the windowsDaemonManager branch from 64718fc to 70e9fa1 Compare July 16, 2024 22:32
@saurabhc123
saurabhc123 force-pushed the windowsDaemonManager branch from 67b17ce to 864edbe Compare July 22, 2024 22:05
@jiuchoe4
jiuchoe4 force-pushed the windowsDaemonManager branch from 864edbe to 70e9fa1 Compare July 22, 2024 23:09
@saurabhc123
saurabhc123 force-pushed the windowsDaemonManager branch from 8df1c99 to 320e62a Compare July 23, 2024 02:39
@saurabhc123
saurabhc123 force-pushed the windowsDaemonManager branch from 320e62a to a421e01 Compare July 23, 2024 04:14
@jiuchoe4
jiuchoe4 force-pushed the ebsAttachWindows branch 8 times, most recently from aa83d2c to b1d7a81 Compare July 29, 2024 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants