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

Add Docker ID of containers to logs #2399

Merged
merged 1 commit into from
Mar 19, 2020
Merged

Conversation

ubhattacharjya
Copy link
Contributor

@ubhattacharjya ubhattacharjya commented Mar 17, 2020

Summary

This PR adds container runtime ID to the agent log lines which do not include them for better debugging

Implementation details

Testing

Tested that the log lines pop up with docker id in agent logs

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.

@ubhattacharjya ubhattacharjya marked this pull request as ready for review March 17, 2020 17:51
@ubhattacharjya ubhattacharjya requested a review from a team March 17, 2020 17:52
@@ -1100,7 +1100,7 @@ func getFirelensLogConfig(task *apitask.Task, container *apicontainer.Container,
}

func (engine *DockerTaskEngine) startContainer(task *apitask.Task, container *apicontainer.Container) dockerapi.DockerContainerMetadata {
seelog.Infof("Task engine [%s]: starting container: %s", task.Arn, container.Name)
seelog.Infof("Task engine [%s]: starting container: %s (Docker ID: %s)", task.Arn, container.Name, container.RuntimeID)
Copy link
Contributor

Choose a reason for hiding this comment

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

how about calling it Runtime ID?

Copy link
Contributor

Choose a reason for hiding this comment

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

How about Container ID? Doesnt docker ps call it Container ID?

Copy link
Member

Choose a reason for hiding this comment

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

how about calling it Runtime ID?

Should be a quick find/replace if you agree with either sharanyad or sparrc. My vote’s for “Runtime ID” (since it’s container.RuntimeID)

Copy link
Contributor

Choose a reason for hiding this comment

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

but this is an external-facing log message. Docker doesnt externally call it "Runtime ID" anywhere. For example googling "docker runtime id" produces cryptic results. Googling "docker container id" produces exactly what we're talking about.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestions. Changed it to "Runtime ID" in order to be consistent with ECS public documentation.

@@ -1392,11 +1392,11 @@ func (engine *DockerTaskEngine) applyContainerState(task *apitask.Task, containe
}
metadata := transitionFunction(task, container)
if metadata.Error != nil {
seelog.Infof("Task engine [%s]: error transitioning container [%s] to [%s]: %v",
task.Arn, container.Name, nextState.String(), metadata.Error)
seelog.Infof("Task engine [%s]: error transitioning container [%s (Runtime ID: %s)] to [%s]: %v",
Copy link
Contributor

Choose a reason for hiding this comment

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

if there is error in transitioning, it could also have empty container ID..but don't want to add a logic to check states and log accordingly. this is just to keep in mind ID can be empty

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There can be empty runtime ID. But did not add any logic for that so that the code does not become cumbersome.

agent/engine/docker_task_engine.go Outdated Show resolved Hide resolved
@@ -1001,8 +1001,8 @@ func (mtask *managedTask) containerNextState(container *apicontainer.Container)
}
if blocked, err := dependencygraph.DependenciesAreResolved(container, mtask.Containers,
mtask.Task.GetExecutionCredentialsID(), mtask.credentialsManager, mtask.GetResources()); err != nil {
seelog.Debugf("Managed task [%s]: can't apply state to container [%s] yet due to unresolved dependencies: %v",
mtask.Arn, container.Name, err)
seelog.Debugf("Managed task [%s]: can't apply state to container [%s (Runtime ID: %s)] yet due to unresolved dependencies: %v",
Copy link
Contributor

Choose a reason for hiding this comment

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

same, can be empty runtime ID?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There can be empty runtime ID. But did not add any logic for that so that the code does not become cumbersome.

agent/engine/task_manager.go Outdated Show resolved Hide resolved
agent/engine/task_manager.go Outdated Show resolved Hide resolved
@ubhattacharjya ubhattacharjya merged commit 104ba1d into aws:dev Mar 19, 2020
@ubhattacharjya ubhattacharjya added this to the 1.38.0 milestone Mar 19, 2020
@sharanyad sharanyad mentioned this pull request Mar 19, 2020
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.

5 participants