Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

bug: agent bootstrap script can't overwrite in-use coder binary (curl error 23 / ETXTBSY)

Đang mở Phù hợp với người mới
#25,975 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
76/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
shell
Lĩnh vực
devops, infrastructure

Hướng nghiên cứu

Bắt đầu với provisionersdk/scripts/bootstrap_linux.sh và kiểm tra vòng lặp tải xuống cùng các nhánh curl, wget và busybox wget của nó. Tái hiện trường hợp BINARY_DIR persistent với một binary coder đang được sử dụng, sau đó xác minh rằng bootstrap khôi phục sau lỗi tải xuống thay vì thử lại vô thời hạn.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Summary

When the agent bootstrap script runs against a BINARY_DIR that persists across workspace restarts (notably envbox, which sets BINARY_DIR=$HOME/.coder — see envbox/cli/docker.go), curl can fail to overwrite the existing coder binary if anything still holds a reference to it. This produces curl: (23) Failure writing output to destination and the bootstrap loop never recovers.

Reproduction
  1. Run a workspace using envbox (sysbox-based). Inner-container workload doesn't strictly matter, but heavy/leaky workloads such as a kind cluster running Argo/Grafana/Loki/Mimir/Tempo make it much more likely to trigger.
  2. Force-delete the workspace pod without graceful shutdown (e.g. kubectl delete pod ... --force --grace-period=0), simulating a stuck/unresponsive workspace.
  3. Restart the workspace.
  4. The bootstrap script enters the curl retry loop and never recovers:
+ curl -fsSL --compressed https://<access-url>/bin/coder-linux-amd64 -o coder
curl: (23) Failure writing output to destination
+ status=23
+ echo error: failed to download coder agent
+ echo    command returned: 23
+ echo Trying again in 30 seconds...
+ sleep 30
Root cause

provisionersdk/scripts/bootstrap_linux.sh does:

curl -fsSL --compressed "${BINARY_URL}" -o "${BINARY_NAME}" && break

without first removing the existing destination file. When BINARY_DIR persists and the old coder binary still has an open reference (e.g. ETXTBSY — "text file busy" — from a process the orphaned/force-killed pod left behind), the kernel refuses to overwrite the running executable and curl returns 23 indefinitely.

The workaround that resolves it is manually running rm -f $HOME/.coder/coder inside the inner container before retrying.

Suggested fix

In bootstrap_linux.sh, before the download loop, either:

  • rm -f "${BINARY_NAME}", or
  • download to a temp filename and mv into place (atomic replace, also avoids partial-download issues).

The same treatment should be applied to the wget / busybox wget branches.

Impact

Workspaces relying on a persistent BINARY_DIR (envbox is the main case) can become permanently stuck in the bootstrap retry loop after any unclean shutdown, with no actionable error surfaced in the UI. The only recovery today is exec-ing into the inner container and removing the binary by hand.

Created on behalf of @ericpaulsen.

Ngôn ngữ chính
Go
Star
16.6k
Fork
1.6k
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
543

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của coder/coder

Tất cả issue của coder/coder

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.