Clean stale runtime state on init so containers recover from unclean shutdowns#171
Open
junkerderprovinz wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
Two supposed-to-be-ephemeral runtime locations survive an unclean container stop (host power loss, hard reboot) because they live on paths that are never wiped:
XDG_RUNTIME_DIRis pointed at$HOME/.XDG, which sits on the persistent/configvolume. On a normal shutdown the session cleans up after itself, but after an unclean stop stale sockets and session state (wayland/dbus/pipewire leftovers) are still there on the next boot and confuse the fresh session.PULSE_RUNTIME_PATHis/defaults(set in the Dockerfile), so PulseAudio'spidandnativesocket files persist too.svc-selkiesgates its sink setup onuntil [ -f /defaults/pid ], so after an unclean stop that gate passes immediately against the dead previous instance's pid file. Thepactl load-modulecalls then fail against a stale socket, but the script still rantouch /dev/shm/audio.lock, which permanently skips sink setup for the rest of that boot, leaving the session without its sinks.This PR makes the runtime state actually ephemeral and the readiness gate meaningful again:
init-selkies-config: after the existing$HOME/.XDGhandling, wipe the directory contents on every boot (find "$HOME/.XDG" -mindepth 1 -delete) and remove stale/defaults/pidand/defaults/nativeso the pulse pid file only exists once the current PulseAudio instance has written it.svc-selkies: onlytouch /dev/shm/audio.lockwhen bothpactl load-modulecalls actually succeeded, so a failed sink setup can retry on service restart instead of being skipped for the whole boot.Both changes are under
root/, which is shared byDockerfileandDockerfile.aarch64, so both arches are covered with no Dockerfile changes.Out of scope: after a power loss PulseAudio's own database files under
/config/.config/pulse(*.tdb) can also end up corrupt; pulse generally recovers from those itself and handling them would mean deleting user-owned config, so this PR deliberately leaves them alone.Benefits of this PR and context:
Fixes #166. Users reported that after an unexpected host restart, over half of their selkies containers came up broken (endless wss reconnects in the WebUI, failing http resources) until they manually deleted the non-app data in
/config. With this change a fresh boot no longer inherits stale runtime state, so containers come up clean after an unclean stop without manual intervention.How Has This Been Tested?
bash -npasses on both modified scripts./defaults/pidlets theuntilgate pass instantly whilepactlcannot connect, and previouslyaudio.lockwas still created; with this change the lock is only created after both sinks load, and a service restart retries the setup.$HOME/.XDGwipe runs after the create/chown block in the same init script, so ownership and theXDG_RUNTIME_DIRexport are unchanged; on a clean first boot the directory is simply empty and thefind/rm -fare no-ops.Source / References: