Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: add timeouts to Docker API calls and reduce redundant requests#315

Merged
clangenb merged 2 commits into
mainfrom
fix/docker-api-timeouts-and-efficiency
Mar 27, 2026
Merged

fix: add timeouts to Docker API calls and reduce redundant requests#315
clangenb merged 2 commits into
mainfrom
fix/docker-api-timeouts-and-efficiency

Conversation

@eldara-cruncher
Copy link
Copy Markdown
Collaborator

Summary

  • Add 10s timeouts to all Docker API calls in docker/info.go (previously context.Background() with no timeout — hangs indefinitely through slow proxies)
  • Add GetSwarmResourceUsage() that collects CPU+memory stats in a single pass (1 ContainerList + N ContainerStats) instead of two separate passes (2 ContainerList + 2N ContainerStats)
  • Derive node capacity from cached snapshot in LoadStatus() instead of making 2 fresh NodeList calls
  • Parallelize GetContainerCount + GetServiceCount in LoadStatus()
  • Reduces Docker API calls per 8s systeminfo cycle from 5+2N to 1+N

Test plan

  • go test -race -count=1 ./... — all 30 packages pass
  • go build ./... — compiles clean
  • Manual: verify systeminfo header updates correctly in dev mode

Ref: Eldara-Tech/swarmcli-be#53

🤖 Generated with Claude Code

eldara-cruncher and others added 2 commits March 27, 2026 07:37
Docker API calls in info.go used context.Background() with no timeout,
causing indefinite hangs when Docker is behind a slow proxy (e.g. RBAC
proxy in BE deployments). Additionally, the 8-second systeminfo cycle
made 5+2N API calls per cycle due to duplicate NodeList and separate
CPU/memory stats passes.

Changes:
- Add 10s timeout to all 9 Docker API calls in info.go
- Add GetSwarmResourceUsage() that collects CPU+memory in a single pass
  (1 ContainerList + N ContainerStats instead of 2+2N)
- Derive node capacity from cached snapshot in LoadStatus() instead of
  making 2 fresh NodeList calls
- Parallelize GetContainerCount + GetServiceCount in LoadStatus()

Reduces API calls per 8s cycle from 5+2N to 1+N.

Ref: Eldara-Tech/swarmcli-be#53

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@eldara-cruncher eldara-cruncher force-pushed the fix/docker-api-timeouts-and-efficiency branch from 11845ff to 90514fe Compare March 27, 2026 07:38
@clangenb clangenb merged commit d106c18 into main Mar 27, 2026
11 checks passed
@eldara-cruncher eldara-cruncher deleted the fix/docker-api-timeouts-and-efficiency branch June 5, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants