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

eventhandler: reduce scope of task states ticker can submit #1178

Merged
merged 1 commit into from
Jan 12, 2018

Conversation

adnxn
Copy link
Contributor

@adnxn adnxn commented Jan 12, 2018

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

  • Builds on Linux (make release)
  • Builds on Windows (go build -out amazon-ecs-agent.exe ./agent)
  • Unit tests on Linux (make test) pass
  • Unit tests on Windows (go test -timeout=25s ./agent/...) pass
  • Integration tests on Linux (make run-integ-tests) pass
  • Integration tests on Windows (.\scripts\run-integ-tests.ps1) pass
  • Functional tests on Linux (make run-functional-tests) pass
  • Functional tests on Windows (.\scripts\run-functional-tests.ps1) pass

New tests cover the changes:

Description for the changelog

Licensing

This contribution is under the terms of the Apache 2.0 License:
yes

TaskARN: taskARN,
Status: task.GetKnownStatus(),
Task: task,
if task.GetKnownStatus() < api.TaskStopped {

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added test.

TaskARN: taskARN,
Status: task.GetKnownStatus(),
Task: task,
if task.GetKnownStatus() < api.TaskStopped {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 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?
  2. Also, you can reduce the levels of indentation by doing something like:
taskKnownStatus := task.GetKnownStatus()
if taskKnownStatus >= api.TaskStopped {
 continue
}
event := api.TaskStateChange {
 ...
}
...

Copy link
Contributor Author

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.

@adnxn adnxn force-pushed the reduce-ticker-scope branch 2 times, most recently from 8dc8b3d to 3b9aebe Compare January 12, 2018 18:10
Copy link
Contributor

@aaithal aaithal left a 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.

@@ -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 {
Copy link
Contributor

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?

Copy link

@richardpen richardpen left a 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`.
@adnxn adnxn merged commit 2bbb8f3 into aws:v1.16.x Jan 12, 2018
adnxn added a commit to adnxn/amazon-ecs-agent that referenced this pull request Jan 15, 2018
@adnxn adnxn deleted the reduce-ticker-scope branch June 4, 2018 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants