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

Task state change logging: use logger.Fields instead of plain strings #3674

Merged
merged 1 commit into from
May 5, 2023

Conversation

sparrc
Copy link
Contributor

@sparrc sparrc commented May 4, 2023

Summary

Refactor log messages for sending state changes to ECS to use logger.Fields and make container state change strings more readable.

In addition to refactoring the format, have also added the container runtime ID(s) and essential status.

from this:
level=info time=2023-05-03T21:47:39Z msg="Sending state change to ECS" eventType="task" eventData="TaskChange: [arn:aws:ecs:us-west-2:039193556298:task/usw2/53669439b60a420dbbf59d2ecaf5206f -> STOPPED, Known Sent: RUNNING, PullStartedAt: 2023-05-03 21:44:48.851603466 +0000 UTC, PullStoppedAt: 2023-05-03 21:44:50.425831882 +0000 UTC, ExecutionStoppedAt: 2023-05-03 21:47:39.738389362 +0000 UTC m=+1.237742685, container change: arn:aws:ecs:us-west-2:039193556298:task/usw2/53669439b60a420dbbf59d2ecaf5206f main -> STOPPED, Exit 137, , Known Sent: RUNNING] sent: false"

to this:
level=info time=2023-05-04T22:48:12Z msg="Sending state change to ECS" eventType="TaskStateChange" taskStatus="STOPPED" reason="" taskPullStartedAt="2023-05-04T21:56:30Z" taskExecutionStoppedAt="2023-05-04T22:48:12Z" containerChange-0="containerName=main containerStatus=STOPPED containerExitCode=137 containerKnownSentStatus=RUNNING containerRuntimeID=32745980a9121de4a8a39d91ceb35ff74a77737f25ce1de9b8a8dead166306cc containerIsEssential=true" taskArn="arn:aws:ecs:us-west-2:039193556298:task/usw2/8d73d245d6794ff695b1fcf14f8934da" taskKnownSentStatus="RUNNING" taskPullStoppedAt="2023-05-04T21:56:32Z"

Testing

make release

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 4, 2023 23:17
@@ -223,29 +224,43 @@ func NewAttachmentStateChangeEvent(eniAttachment *apieni.ENIAttachment) Attachme
}
}

func (c *ContainerStateChange) ToFields() logger.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 function is somewhat moot since we don't send container state changes anymore, but added it just for consistency with TaskStateChange code

@sparrc sparrc added the bot/test label May 4, 2023
@sparrc sparrc added the bot/test label May 5, 2023
@sparrc sparrc force-pushed the task-state-change-log branch 2 times, most recently from 3ba3c24 to 237e129 Compare May 5, 2023 16:55
@sparrc sparrc added the bot/test label May 5, 2023
@sparrc sparrc changed the title Task state change logging refactor Task state change logging: use logger.Fields instead of plain strings May 5, 2023
@sparrc sparrc merged commit a15af5b into aws:dev May 5, 2023
@Realmonia Realmonia mentioned this pull request May 9, 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