Skip to content
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

Add ServiceName to task #3342

Merged
merged 2 commits into from
Aug 16, 2022
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
3 changes: 2 additions & 1 deletion agent/acs/model/api/api-2.json
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,8 @@
"pidMode":{"shape":"String"},
"ipcMode":{"shape":"String"},
"proxyConfiguration":{"shape":"ProxyConfiguration"},
"launchType":{"shape":"String"}
"launchType":{"shape":"String"},
"serviceName":{"shape":"String"}
}
},
"TaskList":{
Expand Down
2 changes: 2 additions & 0 deletions agent/acs/model/ecsacs/api.go

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

3 changes: 3 additions & 0 deletions agent/api/task/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ type Task struct {
Family string
// Version is the version of the task definition
Version string
// ServiceName is the name of the service to which the task belongs.
// It is empty if the task does not belong to any service.
ServiceName string
// Containers are the containers for the task
Containers []*apicontainer.Container
// Associations are the available associations for the task.
Expand Down
12 changes: 12 additions & 0 deletions agent/api/task/task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,7 @@ func TestTaskFromACS(t *testing.T) {
DesiredStatus: strptr("RUNNING"),
Family: strptr("myFamily"),
Version: strptr("1"),
ServiceName: strptr("myService"),
Containers: []*ecsacs.Container{
{
Name: strptr("myName"),
Expand Down Expand Up @@ -1273,6 +1274,7 @@ func TestTaskFromACS(t *testing.T) {
DesiredStatusUnsafe: apitaskstatus.TaskRunning,
Family: "myFamily",
Version: "1",
ServiceName: "myService",
Containers: []*apicontainer.Container{
{
Name: "myName",
Expand Down Expand Up @@ -3281,6 +3283,16 @@ func TestTaskFromACSPerContainerTimeouts(t *testing.T) {
assert.Equal(t, task.Containers[0].StopTimeout, expectedTimeout)
}

// Tests that ACS Task to Task translation does not fail when ServiceName is missing.
// Asserts that Task.ServiceName is empty in such a case.
func TestTaskFromACSServiceNameMissing(t *testing.T) {
taskFromACS := ecsacs.Task{} // No service name
seqNum := int64(42)
task, err := TaskFromACS(&taskFromACS, &ecsacs.PayloadMessage{SeqNum: &seqNum})
assert.Nil(t, err, "Should be able to handle acs task")
assert.Equal(t, task.ServiceName, "")
}

func TestGetContainerIndex(t *testing.T) {
task := &Task{
Containers: []*apicontainer.Container{
Expand Down
1 change: 1 addition & 0 deletions agent/api/task/taskvolume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func TestMarshalTaskVolumesEFS(t *testing.T) {
"Arn": "test",
"Family": "",
"Version": "",
"ServiceName": "",
"Containers": null,
"associations": null,
"resources": null,
Expand Down
1 change: 1 addition & 0 deletions agent/api/task/taskvolume_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func TestMarshalTaskVolumeFSxWindowsFileServer(t *testing.T) {
"Arn": "test",
"Family": "",
"Version": "",
"ServiceName": "",
"Containers": null,
"associations": null,
"resources": null,
Expand Down