-
Notifications
You must be signed in to change notification settings - Fork 619
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
acs: add an empty task in TaskStateChange for unrecognized tasks #1467
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,12 +15,13 @@ | |
package handler | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"fmt" | ||
"reflect" | ||
"sync" | ||
"testing" | ||
|
||
"context" | ||
|
||
"github.com/aws/amazon-ecs-agent/agent/acs/model/ecsacs" | ||
"github.com/aws/amazon-ecs-agent/agent/api" | ||
"github.com/aws/amazon-ecs-agent/agent/api/mocks" | ||
|
@@ -754,3 +755,30 @@ func TestPayloadHandlerAddedASMAuthData(t *testing.T) { | |
assert.Equal(t, aws.StringValue(expected.AsmAuthData.Region), actual.ASMAuthData.Region) | ||
assert.Equal(t, aws.StringValue(expected.AsmAuthData.CredentialsParameter), actual.ASMAuthData.CredentialsParameter) | ||
} | ||
|
||
func TestHandleUnrecognizedTask(t *testing.T) { | ||
tester := setup(t) | ||
defer tester.ctrl.Finish() | ||
|
||
arn := "arn" | ||
ecsacsTask := &ecsacs.Task{Arn: &arn} | ||
payloadMessage := &ecsacs.PayloadMessage{ | ||
Tasks: []*ecsacs.Task{ecsacsTask}, | ||
MessageId: aws.String(payloadMessageId), | ||
} | ||
|
||
mockECSACSClient := mock_api.NewMockECSClient(tester.ctrl) | ||
taskHandler := eventhandler.NewTaskHandler(tester.ctx, tester.payloadHandler.saver, nil, mockECSACSClient) | ||
tester.payloadHandler.taskHandler = taskHandler | ||
|
||
wait := &sync.WaitGroup{} | ||
wait.Add(1) | ||
|
||
mockECSACSClient.EXPECT().SubmitTaskStateChange(gomock.Any()).Do(func(change api.TaskStateChange) { | ||
assert.NotNil(t, change.Task) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we allow unrecognized tasks to run and complete? If so, how do we know that the task state changes after this are handled ok? i.e. Is the empty task passed on to another component? And if so, we we creating a new untested code path by creating the empty task? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't allow unrecognized tasks to run or complete. If it's unrecognized, we simply drop it and tell backend that this task is stopped because it's unrecognized. To stop a task, we don't even need to specify a task struct when calling |
||
wait.Done() | ||
}) | ||
|
||
tester.payloadHandler.handleUnrecognizedTask(ecsacsTask, errors.New("test error"), payloadMessage) | ||
wait.Wait() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you do a nil check here, as the task isn't always nil here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clarified offline.