Skip to content

fix(agent): Retry Docker check on non-200 HTTP response - #1754

Merged
henrygd merged 1 commit into
henrygd:mainfrom
ElioDiNino:main
Feb 18, 2026
Merged

henrygd merged 1 commit into
henrygd:mainfrom
ElioDiNino:main

Conversation

@ElioDiNino

Copy link
Copy Markdown
Contributor

📃 Description

The current retry behaviour only catches some errors, including inaccessible hosts, but not others, such as failed authentication (401) or service unavailability (503). This largely applies when using a socket proxy, and this change mitigates some erroneous behaviour and increases reliability.

A specific issue I am solving for my use case is wollomatic/socket-proxy#83, where the socket proxy reads Docker labels to assign socket permissions. Since the Beszel agent boots up extremely quickly, the socket proxy blocks the version check request with a 403 before receiving the Docker labels and correctly updating permissions for future requests.

Note that AI was used to help generate the tests, but the cases are my own, and I have also tested locally using the make commands. Additionally, since the retry logic is being tested in three of the test cases, 15 seconds of delay is added to the total test run time. If this is unacceptable, please let me know how you would like the delay to be shortened/skipped just for the tests (a simple change would be an additional dockerManager value, but that solution is not my favourite).

Builds on #1250

🪵 Changelog

🔧 Fixed

  • Agent now retries Docker connection initialization when a non-200 HTTP response is received

The previous behavior only caught some errors including inaccessible
hosts, but not others like failed authentication or service
unavailability. This largely applies when using a socket proxy and
having the retry mitigates some erroneous behavior.
Copilot AI review requested due to automatic review settings February 17, 2026 22:17
@ElioDiNino
ElioDiNino requested a review from henrygd as a code owner February 17, 2026 22:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request enhances the Docker version check retry logic in the Beszel agent to handle non-200 HTTP responses, not just connection errors. This addresses scenarios where a socket proxy (like wollomatic/socket-proxy) may temporarily reject requests before properly configuring permissions based on Docker labels, particularly when the agent boots up quickly.

Changes:

  • Modified retry logic to check both for errors AND non-200 HTTP status codes
  • Added differentiated debug logging for connection errors vs. HTTP status code failures
  • Added comprehensive unit tests covering all retry scenarios

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
agent/docker.go Enhanced checkDockerVersion() to retry on non-200 HTTP responses in addition to connection errors, with improved logging
agent/docker_test.go Added comprehensive test suite for checkDockerVersion() covering success, retry, and failure scenarios

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@henrygd
henrygd merged commit ef92b25 into henrygd:main Feb 18, 2026
5 of 6 checks passed
@henrygd

henrygd commented Feb 18, 2026

Copy link
Copy Markdown
Owner

Thanks very much!

ElioDiNino added a commit to ElioDiNino/Homelab that referenced this pull request Feb 21, 2026
rizkyilhampra pushed a commit to rizkyilhampra/beszel that referenced this pull request Apr 14, 2026
The previous behavior only caught some errors including inaccessible
hosts, but not others like failed authentication or service
unavailability. This largely applies when using a socket proxy and
having the retry mitigates some erroneous behavior.
xiaoran7 pushed a commit to xiaoran7/beszel that referenced this pull request Oct 17, 2026
The previous behavior only caught some errors including inaccessible
hosts, but not others like failed authentication or service
unavailability. This largely applies when using a socket proxy and
having the retry mitigates some erroneous behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants