Skip to content

Add containerId, networkNameSpace, containerCGroup to ManagedDaemon #4041

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

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 54 additions & 4 deletions ecs-agent/manageddaemon/managed_daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ type ManagedDaemon struct {

linuxParameters *ecsacs.LinuxParameters
privileged bool

containerId string

containerCGroup string
networkNameSpace string
}

// A valid managed daemon will require
Expand Down Expand Up @@ -184,6 +189,11 @@ func (md *ManagedDaemon) GetCommand() []string {
return md.command
}

func (md *ManagedDaemon) SetCommand(command []string) {
md.command = make([]string, len(command))
copy(md.command, command)
}

// returns list of mountpoints without the
// agentCommunicationMount and applicationLogMount
func (md *ManagedDaemon) GetFilteredMountPoints() []*MountPoint {
Expand Down Expand Up @@ -211,6 +221,26 @@ func (md *ManagedDaemon) GetLoadedDaemonImageRef() string {
return md.loadedDaemonImageRef
}

func (md *ManagedDaemon) SetLoadedDaemonImageRef(loadedImageRef string) {
md.loadedDaemonImageRef = loadedImageRef
}

func (md *ManagedDaemon) GetHealthCheckTest() []string {
return md.healthCheckTest
}

func (md *ManagedDaemon) GetHealthCheckInterval() time.Duration {
return md.healthCheckInterval
}

func (md *ManagedDaemon) GetHealthCheckTimeout() time.Duration {
return md.healthCheckTimeout
}

func (md *ManagedDaemon) GetHealthCheckRetries() int {
return md.healthCheckRetries
}

func (md *ManagedDaemon) SetHealthCheck(
healthCheckTest []string,
healthCheckInterval time.Duration,
Expand Down Expand Up @@ -277,14 +307,34 @@ func (md *ManagedDaemon) SetEnvironment(environment map[string]string) {
}
}

func (md *ManagedDaemon) SetLoadedDaemonImageRef(loadedImageRef string) {
md.loadedDaemonImageRef = loadedImageRef
}

func (md *ManagedDaemon) SetPrivileged(isPrivileged bool) {
md.privileged = isPrivileged
}

func (md *ManagedDaemon) GetContainerId() string {
return md.containerId
}

func (md *ManagedDaemon) SetContainerId(containerId string) {
md.containerId = containerId
}

func (md *ManagedDaemon) GetContainerCGroup() string {
return md.containerCGroup
}

func (md *ManagedDaemon) SetContainerCGroup(containerCGroup string) {
md.containerCGroup = containerCGroup
}

func (md *ManagedDaemon) GetNetworkNameSpace() string {
return md.networkNameSpace
}

func (md *ManagedDaemon) SetNetworkNameSpace(networkNameSpace string) {
md.networkNameSpace = networkNameSpace
}

// AddMountPoint will add by MountPoint.SourceVolume
// which is unique to the task and is a required field
// and will throw an error if an existing
Expand Down
28 changes: 28 additions & 0 deletions ecs-agent/manageddaemon/managed_daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,31 @@ func TestIsValidManagedDaemon(t *testing.T) {
})
}
}

func TestSetContainerId(t *testing.T) {
testContainerId := "testContainerId"
tmd := NewManagedDaemon(TestImageName, TestImageTag)
tmd.SetContainerId(testContainerId)
assert.Equal(t, testContainerId, tmd.GetContainerId(), "Wrong value for set ContainerId")
}

func TestSetContainerCGroup(t *testing.T) {
testContainerCGroup := "testContainerCGroup"
tmd := NewManagedDaemon(TestImageName, TestImageTag)
tmd.SetContainerCGroup(testContainerCGroup)
assert.Equal(t, testContainerCGroup, tmd.GetContainerCGroup(), "Wrong value for set ContainerCGroup")
}

func TestSetNetworkNameSpace(t *testing.T) {
testNetworkNameSpace := "testNetworkNameSpace"
tmd := NewManagedDaemon(TestImageName, TestImageTag)
tmd.SetNetworkNameSpace(testNetworkNameSpace)
assert.Equal(t, testNetworkNameSpace, tmd.GetNetworkNameSpace(), "Wrong value for set NetworkNameSpace")
}

func TestSetCommand(t *testing.T) {
testCommand := []string{"testCommand1", "testCommand2"}
tmd := NewManagedDaemon(TestImageName, TestImageTag)
tmd.SetCommand(testCommand)
assert.Equal(t, testCommand, tmd.GetCommand(), "Wrong value for set Command")
}