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

fix: container not registered after restart #5

Merged
merged 4 commits into from
Oct 23, 2024

Conversation

fho
Copy link

@fho fho commented Oct 23, 2024

When a container is started, stopped and started it is not registered again.
It isn't because it is marked as dying and dying containers are not registered again.
The dying state is only removed after ttl-dying-cleanup expires and another container was stopped in the meantime. Only when a container is stopped the dying list is cleaned up.

Remove marking container as dying, this probably exists to prevent that a
container is reregistered while it is shutting down. To prevent that this
happens only register containers that are in running or restarted state when
running the periodic sync operation, instead of first adding all and then
removing the ones that aren't in created, restarting, running or paused state.

fho added 4 commits October 22, 2024 17:48
A channel without buffer was used to receive dockerapi events.
Events are only sent to the channel if the operation does not block.
This means when registrator is still processing an event, events send to
the channel will get lost.

Make it unlikely to happen by using a channel with a buffer of 128 messages.
During Sync() registrator is registering all docker containers including
containers that aren't running.
Afterwards it unregisters all containers again aren't in status created,
restarting, running or paused.

Change it to only register containers that are running or restarting.
It's not clear why containers are registered that are not running at
all.
This will allow remove the logic to mark containers as dying, the issue
that containers can be reregistered during shutdown can not happen
anymore.
Do not mark containers as dying after they have been stopped.
The mechanic causes that when a single container is restarted it is not
registered again. The containers is marked as dying until
ttl-dying-cleanup expired. If the container is restarted before the TTL
expires it ignored and not registered again.
Containers are also only unmarked as dying when bridge.add() is called,
if this did not happen despite the TTL expires and the container was
restarted it was also not registered again.
I guess the dying state was introduced to prevent that a container is
reregistered while it is being shutdown.
Because Sync() was changed to only consider containers in running state
it can not happen anymore.

The ttl-dying-cleanup config option is removed.
@fho fho self-assigned this Oct 23, 2024
@fho fho marked this pull request as ready for review October 23, 2024 08:18
@fho fho merged commit 17c55df into master Oct 23, 2024
3 checks passed
@fho fho deleted the fix_register_after_restart branch October 23, 2024 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant