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

Persist container exit code in agent state file #1125

Merged
merged 1 commit into from
Dec 4, 2017
Merged

Persist container exit code in agent state file #1125

merged 1 commit into from
Dec 4, 2017

Conversation

ofiliz
Copy link
Contributor

@ofiliz ofiliz commented Dec 2, 2017

Summary

Container exit code needs to be persisted in the agent state file so
that api.Container structs can be rebuilt after agent restarts. Go's
default JSON encoder marshals only public fields. This PR renames
and exports that field, updates access functions and adds a test case
for exercising the new logic.

Future work: We should write a custom marshaler for container class
so that we don't have to expose internal state. Since this improvement
is not specific to exit code, I chose to fix it first, and implement the
custom marshaler in a later commit.

Implementation details

  • Rename and export KnownExitCodeUnsafe with proper JSON marking.
  • Add test to ensure exit code is persisted and catch any regressions.
  • Fix existing test panics caused by continuing after fatal nil checks.

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: yes

  • Confirmed the new test case fails before this commit, and succeeds after it.

Description for the changelog

Bug - Persist container exit code in agent state file

Licensing

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

Fixes #986

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.

Nice!

@aaithal
Copy link
Contributor

aaithal commented Dec 4, 2017

I missed this in my comments. Can you please add a changelog entry as well? Example: 6527d7d#diff-4ac32a78649ca5bdd8e0ba38b7006a1eR4

Container exit code needs to be persisted in the agent state file so
that api.Container structs can be rebuilt after agent restarts. Go's
default JSON encoder marshals only public fields.

Rename and export KnownExitCodeUnsafe with proper JSON marking.
Add test to ensure exit code is persisted and catch any regressions.
Fix existing test panics caused by continuing after fatal nil checks.
Copy link
Contributor

@nmeyerhans nmeyerhans left a comment

Choose a reason for hiding this comment

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

ship it.

// the JSON body while saving the state.
// NOTE: Do not access KnownExitCodeUnsafe directly. Instead, use `GetKnownExitCode`
// and `SetKnownExitCode`.
KnownExitCodeUnsafe *int `json:"KnownExitCode"`

Choose a reason for hiding this comment

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

You may also bump the state file version here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the KnownExitCode was part of the state file since the beginning. It was recently accidentally removed, this change is just putting it back in. So I thought I shouldn't bump the version?

@ofiliz ofiliz merged commit f79e4ca into aws:dev Dec 4, 2017
@ofiliz ofiliz deleted the fix-container-exit-code branch December 4, 2017 19:41
@aaithal aaithal added this to the 1.17.0 milestone Dec 13, 2017
@aaithal aaithal mentioned this pull request Dec 18, 2017
8 tasks
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.

4 participants