-
Notifications
You must be signed in to change notification settings - Fork 620
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
eventhandler: reduce scope of task states ticker can submit #1178
Conversation
996e301
to
69ad0e5
Compare
69ad0e5
to
954bd70
Compare
agent/eventhandler/task_handler.go
Outdated
TaskARN: taskARN, | ||
Status: task.GetKnownStatus(), | ||
Task: task, | ||
if task.GetKnownStatus() < api.TaskStopped { |
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 add modify/add a unit test to cover this?
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.
added test.
agent/eventhandler/task_handler.go
Outdated
TaskARN: taskARN, | ||
Status: task.GetKnownStatus(), | ||
Task: task, | ||
if task.GetKnownStatus() < api.TaskStopped { |
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.
- There's a remote possibility that task's known status would change between lines 187 and 190. Can you assign it to a variable instead of getting it twice?
- Also, you can reduce the levels of indentation by doing something like:
taskKnownStatus := task.GetKnownStatus()
if taskKnownStatus >= api.TaskStopped {
continue
}
event := api.TaskStateChange {
...
}
...
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.
sounds good to me. fixed.
8dc8b3d
to
3b9aebe
Compare
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.
I have am minor comment. Please address that before merging this.
agent/eventhandler/task_handler.go
Outdated
@@ -184,6 +184,10 @@ func (handler *TaskHandler) taskStateChangesToSend() []api.TaskStateChange { | |||
// safety mechanism) and add it to the list of task state changes | |||
// that need to be sent to ECS | |||
if task, ok := handler.state.TaskByArn(taskARN); ok { | |||
knownStatus := task.GetKnownStatus() | |||
if knownStatus >= api.TaskStopped { |
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.
minor: Can you also add a comment for why this is done?
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.
LGTM
Reduce scope of task states the eventhandler ticker can submit. This change only allows the ticker to submit task states that are `< api.TaskStopped`.
3b9aebe
to
2bbb8f3
Compare
Summary
This is the fix for missing container exit code for stopped tasks. This change reduces the scope of task states the eventhandler ticker can submit and only allows the ticker to submit task states that are
< api.TaskStopped
.Implementation details
Testing
make release
)go build -out amazon-ecs-agent.exe ./agent
)make test
) passgo test -timeout=25s ./agent/...
) passmake run-integ-tests
) pass.\scripts\run-integ-tests.ps1
) passmake run-functional-tests
) pass.\scripts\run-functional-tests.ps1
) passNew tests cover the changes:
Description for the changelog
Licensing
This contribution is under the terms of the Apache 2.0 License:
yes