Repository navigation
fix(updates): keep healthy updates on cleanup failure, slim SSE payloads, harden self-update and operationId - #931
Conversation
…p fails Removing the renamed old container is the last step of the Docker update strategy, after the replacement has started and cleared the health gate. It rethrew anything that was not a not-found error, so a removal timeout, a 409 'removal already in progress' or a 500 from a slow overlay unmount sent a finished update into rollback, which stopped and force-removed the verified new container. With AutoRemove on the old container, Docker may already have deleted it, so the rename back failed too and nothing was left running. Cleanup now swallows every non-not-found error: it warns that the '-old-<ts>' container is left stopped for prune, records the reason on the operation as lastError, and the operation still completes as succeeded. The two tests that used a cleanup failure to reach the rollback path were written for branch coverage, not as a product assertion; they now drive rollback through a start failure instead, and two new tests pin that a cleanup timeout and a 409 both leave the new container running.
dd:container-added/updated/removed carried the whole container record: up to 1000 vulnerabilities for the running image and another 1000 for the update candidate, plus both SBOM documents and both cosign blocks. At ~340 bytes per entry that is ~340 KB per event against a 256 KB pending budget, so a scan cycle over a few replicas disconnected every client and the reconnect replayed the same events out of the ring and tripped again. The container list endpoint already projects these fields away. That projection moves to app/api/container/container-projection.ts and the SSE lifecycle handlers now apply it before enrichment and before the ring push, so the wire and the replay carry the list shape. The result is spread into a plain object so the ring does not pin the original scan objects for its five-minute window. The UI never read those arrays off the event; it fetches vulnerabilities, SBOMs and signatures from their own endpoints and refetches security detail on dd:scan-completed.
…ch its exit The helper container is the drydock image with only Cmd overridden, so Docker.entrypoint.sh still runs as uid 0. Its env was built from scratch and carried only the DD_SELF_UPDATE_* values, so on a GID-0 socket the entrypoint refused implicit root mode and exited 1 even when the parent had DD_RUN_AS_ROOT and DD_ALLOW_INSECURE_ROOT set. dockerode's start() resolves on exec rather than exit, so nothing noticed: the transition reported success with the old container left renamed -old-<ts>, the new one never started, and the next attempt tripping the cascade guard. Both variables are now forwarded from the parent's inspected Config.Env when both read true, and only when both do, since either alone is still refused. Reading the spec rather than process.env keeps an agent-side spawn working. A post-start watchdog inspects the helper after three poll intervals. Not running, or gone under AutoRemove, force-removes the new container, renames the old one back and throws with the exit code, matching what the spawn-failure path already did. An inspect failure that is not a 404 is treated as inconclusive and changes nothing.
Both trigger routes accept an operationId in the body so the controller can thread its id to an agent-local route, and it went straight into insertOperation. The store's data.id is a plain index, not a unique constraint, so a reused id left two rows: findOne returns the newest, so status writes stamped the duplicate while the original stayed queued and held its container's gate for the 30 minute active TTL, and when the orphan's queue turn came it resolved to the other container's row and overwrote it. The active-operation gate does not cover this because it only looks up operations for the target container. createAcceptedContainerUpdateRequest now rejects an existing id with UpdateRequestError(409) before inserting, which both routes already map to a 409 response. Only a caller-supplied id is checked; a generated UUID is not. Multi-container batches are unaffected, since they already ignore the supplied id.
|
Deployment failed for project drydock-website with the following error: |
|
@coderabbitai review |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (13)
📝 WalkthroughWalkthroughThe pull request adds shared proxy-based projections for container security data and applies them to list and SSE lifecycle payloads, including replay and backpressure tests. It rejects duplicate caller-supplied update operation IDs. Docker update cleanup errors are recorded without rolling back completed updates. Docker self-update helpers receive validated root environment variables and undergo early-exit detection with rollback handling. Suggested labels: ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@coderabbitai review |
|
biggest-littlest
left a comment
There was a problem hiding this comment.
Reviewed the four update-path fixes and their tests; gate green.
ALARGECOMPANY
left a comment
There was a problem hiding this comment.
Reviewed the four update-path fixes and their tests; gate green.
Four findings from the whole-app review of rc.6, all in the update path.
succeeded, the leftover-old-<ts>container is recorded inlastError, and a throw from the terminal-row guard inside that catch can't reach rollback either.dd:container-updatedSSE events carried the full vulnerability and SBOM arrays (up to ~342 KB per container against the 256 KB backpressure cap), so a scan cycle on a few replicas disconnected every client and looped on replay. Lifecycle events now go through the same projectionGET /containersuses, on the wire and in the replay ring. The UI never read those arrays off the event.DD_RUN_AS_ROOT/DD_ALLOW_INSECURE_ROOT, so on a root-mode host the helper exited 1 and the old container stayed renamed. The helper now gets the pair when both are set, and an early helper exit rolls the rename back with a clear error.operationIdthat already existed was inserted again. Both trigger routes now return 409 and leave one row.Each fix has a test that fails when the change is reverted. Full pre-push gate green, app coverage still 100%.
Changelog
DD_RUN_AS_ROOTandDD_ALLOW_INSECURE_ROOTwhen both flags are enabled.lastError.operationIdvalues. Conflicts now return HTTP 409 without inserting duplicate operations.Concerns