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

config: set recover_stopped to default to false #260

Merged
merged 1 commit into from Jun 14, 2023
Merged

Conversation

shoenig
Copy link
Member

@shoenig shoenig commented Jun 14, 2023

The use of recover_stopped may cause the Nomad agent to hang on startup
after node reboot, as the plugin tries to start an exited podman task.
Podman itself will hang forever in this state, and the http client on the
Nomad side is also unable to timeout in this case. The result is a permanently hung Nomad
agent, until someone force kills either Nomad or Podman.

Also emit a log warning that recover_stopped should not be used. We leave
it in place for compatibility.

Fixes #229

The use of recover_stopped may cause the Nomad agent to hang on startup,
as the plugin tries to start an exited podman task. Podman itself will
hang forever in this state, and the http client on the Nomad side is also
unable to timeout in this case. The result is a permenantly hung Nomad
agent, until someone force kills either Nomad or Podman.

Also emit a log warning that recover_stopped should not be used. We leave
it in place for compatability.

Fixes #229
@shoenig shoenig added this to the v0.5.0 milestone Jun 14, 2023
@shoenig
Copy link
Member Author

shoenig commented Jun 14, 2023

Spot check,

2 nodes

ubuntu@ip-172-31-25-137:~$ nomad node status
ID        Node Pool  DC   Name              Class   Drain  Eligibility  Status
ded51f46  default    dc1  ip-172-31-19-192  <none>  false  eligible     ready
faf9c60b  default    dc1  ip-172-31-24-55   <none>  false  eligible     ready

One simple redis job running

Allocations
ID        Node ID   Task Group  Version  Desired  Status    Created     Modified
6942efcd  faf9c60b  cache       0        run      running   51m1s ago   50m45s ago
ubuntu@ip-172-31-19-192:~$ sudo podman ps -a
CONTAINER ID  IMAGE       COMMAND     CREATED     STATUS      PORTS       NAMES
ubuntu@ip-172-31-24-55:~$ sudo podman ps -a
CONTAINER ID  IMAGE                      COMMAND       CREATED         STATUS             PORTS       NAMES
fc34996abfdd  docker.io/library/redis:7  redis-server  50 minutes ago  Up 50 minutes ago              redis-6942efcd-afcf-61cd-2aae-36b3ce105e17

reboot the node with the redis alloc

ubuntu@ip-172-31-24-55:~$ sudo reboot
Connection to ec2-54-236-5-125.compute-1.amazonaws.com closed by remote host.

the other node now has a new redis alloc

ubuntu@ip-172-31-19-192:~$ sudo podman ps -a
CONTAINER ID  IMAGE                      COMMAND       CREATED       STATUS            PORTS       NAMES
27c33d5ab8ad  docker.io/library/redis:7  redis-server  1 second ago  Up 2 seconds ago              redis-39ce1e95-1d40-f8f7-a8be-9386b68aba59

the other node comes back up, nomad service succesfully starts, and no lingering dead podman container exists

ubuntu@ip-172-31-24-55:~$ sudo service nomad start
ubuntu@ip-172-31-24-55:~$ sudo podman ps -a
CONTAINER ID  IMAGE       COMMAND     CREATED     STATUS      PORTS       NAMES
ubuntu@ip-172-31-24-55:~$

@shoenig shoenig marked this pull request as ready for review June 14, 2023 13:56
Copy link
Contributor

@lgfa29 lgfa29 left a comment

Choose a reason for hiding this comment

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

Ah nice find! Any clues why Podman would hang? And in your test, would recover_stopped cause the rebooted client to restart leaving two running (one on each client)?

The intention behind this feature seems to be very close to the max_client_disconnect, so we could log that as an alternative.

This was implemented very early in project (d66b48c). @towe75 have you been using this configuration without issues?

@shoenig
Copy link
Member Author

shoenig commented Jun 14, 2023

Any clues why Podman would hang?

My guess is something to do with the Go http client ignoring timeouts when talking to UDS, but I don't know.

would recover_stopped cause the rebooted client to restart leaving two running (one on each client)

No, the podman task leftover on the rebooted client would remain in the exited state.

@shoenig shoenig merged commit 0b3a626 into main Jun 14, 2023
8 checks passed
@shoenig shoenig deleted the fix-recover-hang branch June 14, 2023 14:33
jdoss added a commit to jdoss/nomad-driver-podman that referenced this pull request Jun 14, 2023
This PR just updates the README documentation for the recover_stopped setting
changes in hashicorp#260
shoenig pushed a commit that referenced this pull request Jun 14, 2023
This PR just updates the README documentation for the recover_stopped setting
changes in #260
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.

Reboot without node drain leaves exited containers preventing Nomad from starting
2 participants