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

After container restart register printer consumer #12158

Merged
merged 1 commit into from
Sep 24, 2024

Conversation

jhrotko
Copy link
Contributor

@jhrotko jhrotko commented Sep 24, 2024

What I did
When a container restarts, the value for its id is set to false from containers - meaning it is no longer attached (line 113). However, when the container starts and it is going to be attached, this container id exists in containers with false value but we never set it back to true leading to the events being ignored in line 107.

case api.ContainerEventAttach:
if _, ok := containers[id]; ok {
continue
}
containers[id] = true
p.consumer.Register(container)
case api.ContainerEventExit, api.ContainerEventStopped, api.ContainerEventRecreated:
if !aborting && containers[id] {
p.consumer.Status(container, fmt.Sprintf("exited with code %d", event.ExitCode))
if event.Type == api.ContainerEventRecreated {
p.consumer.Status(container, "has been recreated")
}
}
containers[id] = false
if !event.Restarting {
delete(containers, id)
}

Related issue

(not mandatory) A picture of a cute animal, if possible in relation to what you did
image

Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
@jhrotko jhrotko self-assigned this Sep 24, 2024
Copy link
Contributor

@glours glours left a comment

Choose a reason for hiding this comment

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

LGTM, good catch @jhrotko 👍

@glours glours merged commit 8b9fe89 into docker:main Sep 24, 2024
28 checks passed
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.

[BUG] (maybe) missing "[container] exited with code [code]" messages during attach
3 participants