Repository navigation
feat(api): a server's untracked containers are listed and removed on a typed name (part of #501) - #521
Conversation
…a typed name (part of #501) After a restore, servers keep running the containers of deployments the backup does not know, and nothing removed them. The control plane now keeps, per node, the managed containers its reports hold that match no placed replica, writes and audits them when that set changes, and lists as untracked those named after an application of the organization that is not being deployed. An administrator removes one on a confirmation token for the new node.container.remove action, by its name: RemoveContainer without volumes, audited. Signed-off-by: samuel mbabhazi <[email protected]>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 55 minutes. View limit details
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. |
|
@coderabbitai review |
Action not completed
|
|
CodeRabbit is rate limited (review limit reached). Self-reviewed before merge:
Lab-verified with a real |
… one on its name (closes #501) (#522) ## What changed The page part of #501, stacked on #521: a server's page lists its untracked containers and removes one on its typed name. - **`sk-untracked-containers`**: in the server page's *Resources* section, under the replicas, hidden while there are none. - Each container shows its name, its application, its release, since when it is unmatched, and its state. - **Remove** opens the existing confirm-by-name dialog (`ConfirmByName`), which says the server stops and removes the container and that its volumes stay. - Confirming issues a `node.container.remove` confirmation by the typed name, then asks for the removal. - On success the page says the server removes it within a minute, and stops offering that container. - Changing server or organization clears everything. - **API client:** `FleetApi.untrackedContainers`, `confirmContainerRemoval` and `removeUntrackedContainer`. - **French translations**, including container states that had none (exited, dead, created, restarting). ## Why Closes #501. After a restore, an administrator sees the containers left behind and removes them from the server's page. ## How it was tested - **Unit tests** in `untracked-containers.spec.ts` (4 tests): - nothing is shown while there are none; - each container is named with its application and release; - removal goes through the typed name: a partial name keeps the button disabled, both API calls carry the right arguments, the success text shows, and the container is no longer offered; - another server clears the list. - **Full web suite:** 59 files, 371 tests. Web lint and typecheck pass. - **Real lab, the issue's own scenario** (run28, this branch's image, Chromium): 1. `third` ran release 2 on `node-b`, and `./backup.sh create` saved it. 2. Deploying `third` again gave release 3. 3. `./backup.sh restore` brought the database back to release 2. 4. `node-b` reported `sk-third-8a40e589f52c-r3-0`, listed as untracked: application third, release 3, running. 5. Typing the name in the dialog and confirming removed it from the server, and the list emptied. 6. Deploying `third` again succeeded at the first attempt, reusing number 3, which used to fail on the name. The route served the new container. Screenshots are on the review page linked in the conversation. **This changes the UI: it waits for the maintainer's validation, then merges with #521 (retargeted to main first).** ## Security considerations - **No new capability.** The page calls #521's routes: `node.manage`, a single-use confirmation by the container's exact name, and an audit trail. - **Data stays.** The removal never asks for the volumes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * View untracked containers in a server’s Resources section, with status and container details. * Remove a container after confirming its exact name. The confirmation explains that removal stops the container and leaves its volumes intact. * See removal status and refresh the list; retry loading if it fails. * If the server no longer considers a container untracked, start the removal process again. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: samuel mbabhazi <[email protected]>
What changed
The control-plane part of #501, as decided: list and remove. After a restore, the servers keep running containers of deployments the backup does not know. These containers now show on the server's page as untracked, and an administrator removes them one at a time on a confirmation by name, with an audit trail. The page itself follows in a second pull request, which needs your validation. INSTALL.md already describes it, so the two merge together.
AllocationObservations):unmatched_containers, a new table under tenant RLS that cascades with the node.node.unmatched_containers_changed: by the node, with the names added and gone and the count. Names only.containerNamebuilds it, ends with the last 12 characters of exactly one application of the organization;node.manage, session only):GET /organizations/{org}/nodes/{node}/untracked-containers: name, container id, state, since when, application, project, environment, and the release and replica its name states.POST /organizations/{org}/nodes/{node}/untracked-containers/{name}/remove(202):container_not_untrackedbefore spending anything.node.container.removeconfirmation and queuesRemoveContainerwithout volumes (keyu:<confirmation id>:remove, one hour), in one tenant transaction.node.untracked_container_removal_requested. The agent's result is audited as the action's own events.node.container.remove, with permissionnode.manageand target<node id>/<container name>. The name to type is the container's, and only an untracked container resolves.container.removetoken is only forremove_volumes, which this never asks.container_name_takenmessage (fix: a create refused for a taken container name says so (part of #501) #504): it now says the lost container then shows as untracked on its server's page, where it can be removed (French updated).Why
Part of #501. A restore left containers that nothing tracked or removed, and the only advice was "remove it by hand on the server".
How it was tested
Domain (
untracked-containers.spec.ts, 9 tests):containerNamebuilds;-tasks, an environment network name;..and upper case are refused.Recorder (
allocation-observations.spec.ts): the unmatched set is written and audited once, the same report twice writes nothing, its removal empties it once, and an invalid report keeps nothing.HTTP with PostgreSQL (
untracked-containers-http.integration.spec.ts), with a real deployment placing release 1 and a report holding release 2's container, an unknown application's container andsk-postgres:removeContainer, keyu:…:remove, audited with the administrator;Suites: the full API unit suite (108 files, 934 tests),
api:lintandapi:typecheckpass. The full integration suite passes apart from its known local failures:23001files,fleet-tenantandtenant-schema;metricsands3-transfer.All four causes were checked.
Security considerations
node.manageand a single-use confirmation by the container's exact name, spent in the transaction that queues the removal.sk.managedcontainers, by name.