Repository navigation
Conversation
Signed-off-by: wangshun <96341168+xixi-box@users.noreply.github.com>
This branch has not been deployed
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.
Fixes #5868
Description
Idle Docker containers could stay alive indefinitely when users stopped sending requests. The idle sweep ran only after a sandbox was created or connected.
Register a separate five-minute Docker idle sweep that finds daemons through saved workspace configs and logs each sweep's start and result. The sweep honors the TTL already stamped by the shared Docker create path for both ordinary and skill-image containers. Older managed containers without a TTL label use the longest configured TTL for their endpoint.
Docker creation now returns a capacity error when the daemon reaches its managed-container limit. The default is 16, configurable through
WEKNORA_SANDBOX_DOCKER_MAX_CONTAINERS. Running and stopped containers both count. Each app process serializes creation per daemon address, so simultaneous creates from different replicas can temporarily exceed the threshold.Type of Change
Related Issue
Fixes #5868
Testing
Tests:
go test -count=1 -v ./internal/application/service -run '^TestSkillMaintenanceReclaimsIdleDockerSandboxes$'.Result: Base: go test ./internal/sandbox/... passed before regressions were added.
Result: Base: go test -count=1 ./internal/application/service -run '^(TestReapStuckRuns|TestReconcileSnapshots|TestPruneSupersededSnapshots|TestTenantSkillServiceStartIsIdempotent)' passed.
Result: Base: go test -count=1 -v ./internal/application/service -run '^TestSkillMaintenanceReclaimsIdleDockerSandboxes$' failed for the expected reason. No expired containers were deleted (OSSCOUT_BASE.log).
Result: Patched: go test -count=1 -v ./internal/application/service -run '^TestSkillMaintenanceReclaimsIdleDockerSandboxes$' passed and logged reclamation of two containers (OSSCOUT_PATCHED.log).
Result: go test -count=1 -v ./internal/sandbox -run '^TestDockerClientCreateEnforcesContainerLimitForSkillImages$' failed on base because creation returned no capacity error and passed on patched code (OSSCOUT_CAPACITY_BASE.log, OSSCOUT_CAPACITY_PATCHED.log).
Result: Patched: go test -count=1 ./internal/sandbox/... passed all four sandbox packages (OSSCOUT_SANDBOX.log).
Result: Patched: go test -race -tags sqlite_fts5 -count=1 ./internal/sandbox/... passed all four sandbox packages (OSSCOUT_RACE.log). The earlier run caught terminal fixture activity refresh after removing the fixture's zero TTL. Restoring that setting resolved the failures.
Result: Patched: go test -tags sqlite_fts5 -count=1 ./internal/application/service passed (OSSCOUT_SERVICE.log).
Result: Patched: go test -tags sqlite_fts5 -count=1 ./internal/handler -run '^(TestSandboxConnectionCheck|TestSandboxCheckReason|TestDeepSandboxCheck|TestRunStatelessSandboxCheck)' passed (OSSCOUT_HANDLER.log).
Result: Patched: go test -tags docker_integration ./internal/sandbox -run '^$' compiled the tagged suite (OSSCOUT_DOCKER_BUILD.log).
Regression coverage:
internal/application/service/tenant_skill_reaper_test.go.Checklist
git diff --check origin/main...HEADpassesgolangci-lint run --new-from-rev=origin/main ./...)website-docs/, Swagger annotations, etc.)Screenshots / Recordings
Backend-only change.