Skip to content

Commit

Permalink
Add containerId, networkNameSpace, containerCGroup to ManagedDaemon
Browse files Browse the repository at this point in the history
  • Loading branch information
as14692 committed Nov 21, 2023
1 parent 5f35c93 commit 7ab7dc4
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 8 deletions.

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")
}

0 comments on commit 7ab7dc4

Please sign in to comment.