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

Structured logging for docker image manager #3696

Merged
merged 3 commits into from
May 16, 2023

Conversation

sparrc
Copy link
Contributor

@sparrc sparrc commented May 12, 2023

Summary

Make the docker image manager logs more readable and traceable by using structured logging and adding fields with consistent metadata about the image in each log line.

Also moved a few redundant log messages from INFO to DEBUG

Description for the changelog

NA

Licensing

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

@sparrc sparrc requested a review from a team as a code owner May 12, 2023 21:28
@sparrc sparrc force-pushed the image-manager-logging branch from e4f87a5 to 70df265 Compare May 12, 2023 21:30
@@ -272,7 +273,7 @@ func (imageManager *dockerImageManager) removeImageState(imageStateToBeRemoved *
for i, imageState := range imageManager.imageStates {
if imageState.Image.ImageID == imageStateToBeRemoved.Image.ImageID {
// Image State found; hence remove it
seelog.Infof("Removing Image State: [%s] from Image Manager", imageState.String())
logger.Debug("Image Manager: removing image state", imageState.Fields())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is not removing the image state from the instance, only from the agent's internal tracking object. This seems confusing to have as a public INFO message so making it debug

// no image states present in image manager
return nil
}
var imagesForDeletion []*image.ImageState
for _, imageState := range imageManager.imageStatesConsideredForDeletion {
if imageManager.isImageOldEnough(imageState) && imageState.HasNoAssociatedContainers() {
seelog.Infof("Candidate image for deletion: [%s]", imageState.String())
logger.Debug("Candidate image for deletion", imageState.Fields())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

these messages are logged multiple times when the image is actually removed, and then again on each "removal" loop, so making it debug

danehlim
danehlim previously approved these changes May 15, 2023
chienhanlin
chienhanlin previously approved these changes May 15, 2023
Copy link
Contributor

@chienhanlin chienhanlin left a comment

Choose a reason for hiding this comment

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

Thanks!

@sparrc sparrc merged commit 88847ca into aws:dev May 16, 2023
@sparrc sparrc deleted the image-manager-logging branch May 16, 2023 17:40
Realmonia pushed a commit to Realmonia/amazon-ecs-agent that referenced this pull request May 16, 2023
* Structured logging for docker image manager

* Add some reused fields to logger/field/constants.go

* Add missing 'imageTag' field from err message
RichaGangwar pushed a commit to RichaGangwar/amazon-ecs-agent that referenced this pull request May 18, 2023
* Structured logging for docker image manager

* Add some reused fields to logger/field/constants.go

* Add missing 'imageTag' field from err message
Realmonia pushed a commit to Realmonia/amazon-ecs-agent that referenced this pull request May 21, 2023
* Structured logging for docker image manager

* Add some reused fields to logger/field/constants.go

* Add missing 'imageTag' field from err message
@ubhattacharjya ubhattacharjya mentioned this pull request May 24, 2023
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