fix(daemonless): correctly track and clean up buildkitd/rootlesskit in daemonless script#6360
Open
robko23 wants to merge 1 commit intomoby:masterfrom
Open
fix(daemonless): correctly track and clean up buildkitd/rootlesskit in daemonless script#6360robko23 wants to merge 1 commit intomoby:masterfrom
robko23 wants to merge 1 commit intomoby:masterfrom
Conversation
…n daemonless script When running buildctl-daemonless.sh outside of a container (e.g., locally), the script often failed to shut down the ephemeral buildkitd instance on exit. This left rootlesskit/buildkitd processes orphaned and reparented to PID 1. In some cases the script would also hang indefinitely during cleanup, requiring the user to abort with Ctrl+C. The root cause was that the script stored the PID of the `tee` process (the log pipe) instead of the PID of the actual rootlesskit/buildkitd supervisor. As a result, the EXIT trap was killing the wrong process and the daemon continued running in the background. This patch fixes the PID tracking by redirecting buildkitd logs to a file and spawning a separate `tail -F` process for live output. The PID file now contains the correct supervisor PID. The cleanup trap was also improved: it now reliably terminates the correct process, and falls back to SIGKILL if the daemon does not shut down after SIGTERM. Signed-off-by: Robin Ilyk <contact@robko.cz>
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.
When running buildctl-daemonless.sh outside of a container (e.g., locally), the script often failed to shut down the ephemeral buildkitd instance on exit. This left rootlesskit/buildkitd processes orphaned and reparented to PID 1. In some cases the script would also hang indefinitely during cleanup, requiring the user to abort with Ctrl+C.
The root cause was that the script stored the PID of the
teeprocess (the log pipe) instead of the PID of the actual rootlesskit/buildkitd supervisor. As a result, the EXIT trap was killing the wrong process and the daemon continued running in the background.This patch fixes the PID tracking by redirecting buildkitd logs to a file and spawning a separate
tail -Fprocess for live output. The PID file now contains the correct supervisor PID.The cleanup trap was also improved: it now reliably terminates the correct process, and falls back to SIGKILL if the daemon does not shut down after SIGTERM.