fix(provisionersdk/scripts): remove existing agent binary before download#26138
Draft
ericpaulsen wants to merge 1 commit into
Draft
fix(provisionersdk/scripts): remove existing agent binary before download#26138ericpaulsen wants to merge 1 commit into
ericpaulsen wants to merge 1 commit into
Conversation
…load When BINARY_DIR persists across workspace restarts (e.g. envbox sets BINARY_DIR=$HOME/.coder) and a previous agent process is still holding the executable open, curl/wget cannot overwrite it and fail with error 23 (Linux ETXTBSY, text file busy). The bootstrap loop then retries forever and the workspace never becomes available. Unlink the existing binary before entering the download loop. unlink(2) is permitted while the file is executing, the still-running process keeps its mapping to the old inode, and the next download creates a fresh inode that the new agent can exec. Fixes #25975
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.
On Linux,
bootstrap_linux.shwrites the downloaded agent directly to${BINARY_DIR}/coder. WhenBINARY_DIRpersists across workspace restarts (envbox sets it to$HOME/.coder) and a previous agent process is still holding the executable open, curl/wget cannot open the file for writing and fail withcurl: (23) Failure writing output to destination(Linux ETXTBSY, "text file busy"). The bootstrap loop then retries forever and the workspace never recovers without manualrm -f $HOME/.coder/coder.Unlink the existing binary before entering the download loop.
unlink(2)is permitted while the file is being executed, the still-running process keeps its mapping to the old inode, and the next download creates a fresh inode that the new agent can exec.bootstrap_darwin.shalways creates a freshmktemp -ddirectory, so it is unaffected.Fixes #25975
Authored by Coder Agents on behalf of @ericpaulsen.