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

Check the sentstatus before updating #1383

Merged
merged 2 commits into from
May 11, 2018
Merged

Conversation

richardpen
Copy link

There could be a case that SubmitTaskStateChange for STOPPED happened
before RUNNING, where the sentstatus of the task would be set to
RUNNING. This PR fix this by checking the sentstatus before updating.

Summary

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

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@richardpen richardpen added this to the 1.18.0 milestone May 10, 2018
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.

have a couple of minor comments. Can you please add unit tests for this as well?

@@ -186,14 +186,16 @@ type setStatusSent func(event *sendableEvent)

// setContainerChangeSent sets the event's container change object as sent
func setContainerChangeSent(event *sendableEvent) {
if event.containerChange.Container != nil {
if event.containerChange.Container != nil &&
Copy link
Contributor

Choose a reason for hiding this comment

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

can you just assign event.containerChange.Container to a var and reuse it in this method so that it's easier to read this code?

event.containerChange.Container.SetSentStatus(event.containerChange.Status)
}
}

// setTaskChangeSent sets the event's task change object as sent
func setTaskChangeSent(event *sendableEvent) {
if event.taskChange.Task != nil {
if event.taskChange.Task != nil &&
Copy link
Contributor

Choose a reason for hiding this comment

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

can you just assign event.taskChange.Task to a var and reuse it in this method so that it's easier to read this code?

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 some minor comments. Please fix them before merging.

if event.containerChange.Container != nil {
event.containerChange.Container.SetSentStatus(event.containerChange.Status)
containerChangeStatus := event.containerChange.Status
if event.containerChange.Container != nil &&
Copy link
Contributor

Choose a reason for hiding this comment

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

event.containerChange.Container can be a var as well

if event.taskChange.Task != nil {
event.taskChange.Task.SetSentStatus(event.taskChange.Status)
taskChangeStatus := event.taskChange.Status
if event.taskChange.Task != nil &&
Copy link
Contributor

Choose a reason for hiding this comment

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

event.taskChange.Task can be a var as well

Peng Yin added 2 commits May 11, 2018 16:17
There could be a case that SubmitTaskStateChange for STOPPED happened
before RUNNING, where the sentstatus of the task would be set to
RUNNING. This PR fix this by checking the sentstatus before updating.
@richardpen richardpen merged commit 45f4c7a into aws:dev May 11, 2018
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