proton-bridge: clear stale gpg locks before key check#2
Merged
Conversation
A killed container leaves stale gpg lock files and agent sockets in the persisted GNUPGHOME on the data volume. On restart, `gpg --list-keys` blocks on the stale lock until it times out, so the entrypoint wrongly concludes the ProtonMailBridge key is missing and refuses to start. Clear stale locks/sockets at startup, before the key check. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Problem
When the proton-bridge container is killed (OOM, node drain, crash), it leaves stale gpg lock files (
public-keys.d/pubring.db.lock) and agent sockets (S.gpg-agent*,S.keyboxd) in the persistedGNUPGHOMEon the data volume.On restart, the entrypoint's
gpg --batch --list-keys ProtonMailBridgecheck blocks on the stale lock until it times out, sokey_exists=false. With the password store present, that hits thetrue:falsebranch and the container exits with:The key material is actually intact — gpg just can't read past the stale lock (held by a dead PID). This is self-perpetuating: every killed container leaves a fresh lock, so it crash-loops.
Fix
Clear stale gpg lock files and sockets at entrypoint startup, before the key check. Nothing gpg-related is running yet at that point, so removal is safe.
Notes
Observed in production: a bridge pod that had been down for ~2 months refused to start with the above error. Clearing the stale lock manually let it start immediately, confirming the key was fine.
🤖 Generated with Claude Code