Skip to content

Commit

Permalink
Add ServiceName to task (#3342)
Browse files Browse the repository at this point in the history
* Add ServiceName to task

* Update windows unit tests

Co-authored-by: Amogh Rathore <[email protected]>
  • Loading branch information
2 people authored and YashdalfTheGray committed Aug 17, 2022
1 parent d1c4aa4 commit 11b64b2
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 1 deletion.
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

0 comments on commit 11b64b2

Please sign in to comment.