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

engine: update container metadata when container status stays the same #1972

Merged
merged 1 commit into from
Apr 17, 2019

Conversation

yumex93
Copy link
Contributor

@yumex93 yumex93 commented Apr 2, 2019

Agent discards container metadata update for redundant container status changing, however, for some cases, even the status is not changed, the metadata may change. Using container health status as an example, there is situation that when container status just transits to RUNNING, health status is still UNKNOWN and after some time, it changes to HEALTHY.

Summary

Implementation details

Testing

New tests cover the changes:
yes

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.

@@ -422,11 +428,6 @@ func (mtask *managedTask) handleContainerChange(containerChange dockerContainerC
}
}

// Update the container health status
if container.HealthStatusShouldBeReported() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you explain a bit why this block of code is deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updateContainerMetadata already has this part of logic.


// Only update container metadata when status keeps the same, ignore updating metadata if there
// is backward transition
if event.Status == containerKnownStatus {
Copy link
Contributor

Choose a reason for hiding this comment

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

should we explicitly check for RUNNING status if the use case covers only that?

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 will update it to start from only covering RUNNING since so far I haven't found out other use cases.

@@ -407,6 +407,11 @@ func (mtask *managedTask) handleContainerChange(containerChange dockerContainerC
if event.Status <= containerKnownStatus {
seelog.Infof("Managed task [%s]: redundant container state change. %s to %s, but already %s",
mtask.Arn, container.Name, event.Status.String(), containerKnownStatus.String())

// Only update container metadata when status stays RUNNING
if event.Status == containerKnownStatus && event.Status == apicontainerstatus.ContainerRunning {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we are updating the container metadata without the container state change, should we do this checking "if event.Status == containerKnownStatus" independently outside this "if" block and update the log with this change? Also if we only update container metadata when status stays RUNNING, maybe checking "event.Status == apicontainerstatus.ContainerRunning" before "event.Status == containerKnownStatus" makes more sense?

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 don't really wanna have repetitive code for logging, that's why the if is inside the block. And what's the reason behind checking "event.Status == apicontainerstatus.ContainerRunning" first? I think it does not really make a big difference.

Copy link
Contributor

@suneyz suneyz left a comment

Choose a reason for hiding this comment

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

unit test failed for arm, can you take a look?

@yumex93 yumex93 added bot/test and removed bot/test labels Apr 16, 2019
@yumex93 yumex93 merged commit c95c24d into aws:dev Apr 17, 2019
@yumex93 yumex93 added this to the 1.28.0 milestone May 8, 2019
@fenxiong fenxiong mentioned this pull request May 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants