Skip to content

fix(updates): keep healthy updates on cleanup failure, slim SSE payloads, harden self-update and operationId - #931

Merged
scttbnsn merged 4 commits into
dev/v1.7from
fix/v1.7-update-lifecycle
Aug 29, 2026
Merged

scttbnsn merged 4 commits into
dev/v1.7from
fix/v1.7-update-lifecycle

Conversation

@scttbnsn

@scttbnsn scttbnsn commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Four findings from the whole-app review of rc.6, all in the update path.

  • A failed cleanup of the renamed old container (timeout, 409 "removal in progress") used to feed the rollback path and destroy the new container that had just passed its health gate. With AutoRemove that could leave zero containers. Now the update stays succeeded, the leftover -old-<ts> container is recorded in lastError, and a throw from the terminal-row guard inside that catch can't reach rollback either.
  • dd:container-updated SSE 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 projection GET /containers uses, on the wire and in the replay ring. The UI never read those arrays off the event.
  • The self-update helper didn't inherit 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.
  • A caller-supplied operationId that 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

  • ✨ Added lazy container projections for list-compatible lifecycle payloads.
  • ✨ Added regression tests for SSE projection, self-update failures, cleanup failures, and duplicate operation IDs.
  • 🔧 Changed container lifecycle SSE events and replay data to exclude vulnerability arrays, SBOM documents, and signature documents.
  • 🔧 Changed self-update helpers to receive DD_RUN_AS_ROOT and DD_ALLOW_INSECURE_ROOT when both flags are enabled.
  • 🔧 Changed self-update handling to detect early helper exits and restore the renamed container.
  • 🐛 Fixed cleanup failures after health verification. The replacement container remains running, and the failure is recorded in lastError.
  • 🐛 Fixed duplicate caller-supplied operationId values. Conflicts now return HTTP 409 without inserting duplicate operations.
  • 🗑️ Removed duplicated container projection and security-field stripping logic from the list handler.

Concerns

  • Verify that the new helper watchdog timing does not introduce provider-specific race conditions.
  • Verify that all self-update providers follow the same helper inspection and rollback conventions.

…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.
@vercel

vercel Bot commented Aug 29, 2026

Copy link
Copy Markdown

Deployment failed for project drydock-website with the following error:

Resource is limited - try again in 24 hours (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/codeswhat?upgradeToPro=build-rate-limit

@scttbnsn

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a9734767-6f51-4d9a-b7f7-ac97d176ce12

📥 Commits

Reviewing files that changed from the base of the PR and between 0caedfa and cf4093f.

⛔ Files ignored due to path filters (1)
  • CHANGELOG.md is excluded by !CHANGELOG.md
📒 Files selected for processing (13)
  • app/api/container/container-projection.test.ts
  • app/api/container/container-projection.ts
  • app/api/container/handlers/list.ts
  • app/api/sse.lifecycle-events.test.ts
  • app/api/sse.ts
  • app/api/trigger.test.ts
  • app/triggers/providers/docker/ContainerUpdateExecutor.test.ts
  • app/triggers/providers/docker/ContainerUpdateExecutor.ts
  • app/triggers/providers/docker/SelfUpdateTransitionShared.test.ts
  • app/triggers/providers/docker/SelfUpdateTransitionShared.ts
  • app/triggers/providers/docker/self-update-types.d.ts
  • app/updates/request-update.test.ts
  • app/updates/request-update.ts

📝 Walkthrough

Walkthrough

The 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: second-opinion

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/v1.7-update-lifecycle

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai

coderabbitai Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@codecov

codecov Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttbnsn

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Pull request is closed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@biggest-littlest biggest-littlest left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the four update-path fixes and their tests; gate green.

@ALARGECOMPANY ALARGECOMPANY left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the four update-path fixes and their tests; gate green.

@scttbnsn
scttbnsn merged commit 4b45422 into dev/v1.7 Aug 29, 2026
29 of 32 checks passed
@scttbnsn
scttbnsn deleted the fix/v1.7-update-lifecycle branch August 29, 2026 13:09
@coderabbitai coderabbitai Bot added the second-opinion Summon Greptile for a second-opinion review label Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

second-opinion Summon Greptile for a second-opinion review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants