You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(api): a server and the replicas it runs (part of #264) - #416
Part of #264 (step 2 of #413). This is the API half; the page follows in its own pull request.
What changed
Two read routes for a server's page.
GET /organizations/{organizationId}/nodes/{nodeId}
Returns one server, removed ones included, in the same shape as the list.
FleetAdministration.getNode serves it.
GET /organizations/{organizationId}/nodes/{nodeId}/replicas
Returns the replicas placed on that server: at most 200, by application name then replica, with truncated when there are more.
Each replica carries:
its application, project and environment (id and name);
the CPU and memory reserved for it;
when it was placed;
what the agent last saw (state, stopReason, observedAt), as for an application's replicas.
The deployments module serves it, since it owns allocations and observations:
DeploymentCommands.nodeReplicas;
ObservationStore.onNode;
a small NodeReplicasController.
The generated openapi.json, API client and route and role matrix are updated, and SPEC describes both routes.
Why
#264 replaces the preview at /servers/sample with a page on real data: the server's facts, labels and heartbeat, and what runs on it. No route exposed the allocations of one server.
How it was tested
Integration, against real PostgreSQL (node-replicas-http.integration.spec.ts):
an administrator reads the server and its two replicas, with names, reservations and the running state the agent reported;
a replica on another server is not listed, and a stopped replica disappears;
member, projectAdmin, environmentViewer and outsider get 404 on both routes;
the foreign organization's path and an unknown server get 404, and a malformed id gets 400;
an API token with node.manage gets 401 on both routes, while the same token is accepted by a route open to such tokens.
Full suites:
unit: 681 passed;
integration: all passed except the 3 known PostgreSQL 18 differences (fleet-tenant ×2, tenant-schema; CI runs PostgreSQL 17).
Lint and typecheck: green.
Security considerations
Both routes need node.manage on the organization. Only owners and admins hold it, and they read every environment of the organization, so listing application names leaks nothing to them.
Both routes accept a browser session only, like the server list and the server metrics. An API token scoped to manage servers cannot use them to learn the names of applications, projects and environments.
Reads run in the tenant transaction (row-level security). A server outside the organization answers 404, with no existence leak.
No write path, so no audit event.
Summary by CodeRabbit
New Features
Added an organization-scoped endpoint to retrieve server details, including removed servers.
Added an endpoint to list placed replicas on a server, with application, project, environment, resource allocation, placement time, and latest observed status.
Replica listings are limited to 200 results and indicate when additional replicas are available. Both endpoints require server-management permission and return not found when the server is outside the organization or does not exist.
Documentation
Updated the node-management specification to describe the new endpoints and their responses.
Reviewing files that changed from the base of the PR and between e7309be and 50cc129.
Files ignored due to path filters: 3
apps/api/openapi.json is excluded by !apps/api/openapi.json
docs/generated/route-role-matrix.md is excluded by !**/generated/**, !docs/generated/**
packages/api-client/src/gen/openapi.ts is excluded by !**/gen/**, !packages/api-client/src/gen/**
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
Adds tenant-scoped endpoints to retrieve node details and list placed replicas. Replica results include placement, resource, related-entity, and observation details, with a 200-item limit and a truncation flag.
Adds an organization-scoped replica query and endpoint. Results are ordered, limited to 200, and include a truncation flag. Integration tests cover returned details, authorization, validation, and token behavior.
sequenceDiagram
participant Client
participant NodeReplicasController
participant DeploymentCommands
participant PrismaObservationStore
participant Database
Client->>NodeReplicasController: GET node replicas
NodeReplicasController->>DeploymentCommands: Request replicas for organization and node
DeploymentCommands->>PrismaObservationStore: Query up to 201 replicas
PrismaObservationStore->>Database: Check node and fetch placed allocations
Database-->>PrismaObservationStore: Node and allocation data
PrismaObservationStore-->>DeploymentCommands: Ordered replicas or undefined
DeploymentCommands-->>NodeReplicasController: Up to 200 replicas and truncation flag
NodeReplicasController-->>Client: Replica list DTO
Loading
Possibly related issues
shipkeepdev/shipkeep#264 — The issue calls for a server detail page with live facts and replicas. This PR adds the API endpoints for those details.
shipkeepdev/shipkeep#413 — The listed release scope includes the server detail work in issue 264. This PR delivers the API portion of that work.
Possibly related PRs
shipkeepdev/shipkeep#365 — Adds the replica stop-reason field that this PR includes in replica responses.
Merge Risk: Minimal · previous review e7309
This change adds two read-only endpoints for server details and the replicas placed on a server, with permission checks and a 200-item cap. No merge-blocking risk was found.
Security architecture risk: Minimal · up to e7309
The new read endpoints preserve the organization-owner and administrator boundary, reject API tokens, and explicitly scope database reads to the requested organization. No introduced or worsened security or state-ownership failure was established in the inspected change.
Retained concerns
No architecture-level concerns identified.
Security review details
Security Blast Radius
inferred — The new read authority covers one requested node and its placed-replica metadata across projects and environments within the authorized organization. It exposes fleet and deployment metadata, not a new execution, secret-management, or infrastructure-administration capability.
Trust Boundaries and Controls
observed — Both routes require organization-scoped node.manage. Live membership resolution requires an active, email-verified account; the permission policy permits organization owners and administrators but rejects ordinary members regardless of project bindings. Neither route declares API-token access, and the bearer guard rejects a token when its route permission is undeclared.
observed — Authorization uses canonical route parameters and live membership rather than body-supplied role hints. Permission denial and missing-resource handling use the same resource-not-found error path. Explicit organization predicates independently constrain the new node and allocation lookups.
Resilience and Maintainability Implications
observed — The new reads reuse the existing tenant unit of work. Its scope handling rejects conflicting nested contexts, clears transaction-local identity context on success, attempts cleanup on failure, and fails the operation if successful-work cleanup fails. These are existing containment controls reused by the new callers.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "feat(api): a server and the replicas it runs (part of #264)" matches the main change. The PR adds two read routes for a server detail page: one returns a node (server) and one lists the rep…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "feat(api): a server and the replicas it runs (part of #264)" matches the main change. The PR adds two read routes for a server detail page: one returns a node (server) and one lists the replicas placed on it. The title names the API scope and the subject, and it notes that the PR is part of #264. It does not name the specific routes, and the phrasing is slightly awkward, but it is related to the main change and specific enough for a teammate scanning history.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Closes#264 (step 2 of #413). The API it reads was merged in #416.
## What changed
Screen 12 of the design, built on real data. It replaces the preview at
`/servers/sample`; the preview screen and its sample data are removed.
**`/orgs/:organizationId/servers/:nodeId` (`fleet/server-page.ts`)**
- The header has the name, the status, the agent version, and the
hostname, OS and architecture as reported.
- **General:**
- CPU cores, memory, disk used of its total, and replicas with their
number of applications;
- on a single-machine installation, what is reserved for the control
plane;
- the machine as reported (hostname, OS, kernel, architecture, Docker,
Caddy), its placement labels, public addresses and enrolment date;
- the existing metrics charts for this server.
- **Agent:**
- last heartbeat, epoch and version;
- a note that the agent log is not shown yet.
- **Resources:**
- the replicas placed on the server, each linking to its application,
with project and environment, the CPU and memory reserved and the state
the agent last saw;
- a note when the list stops at 200.
- Terminal and Drain stay where the design puts them and say they are
not available yet.
- Anything the agent did not report reads "Not reported" or "—", never
sample data.
- An unknown server, or one of another organization, shows "Server not
found".
- The page reads the server again every 30 seconds.
**Other changes**
- `fleet/server-view.ts`: a pure function from the node and its replicas
to what the page shows. Measured and typed values go through `raw()`, so
they are never looked up for translation.
- `dashboard/format.ts`: `replicaStatus()` now holds the rule for what
an agent saw of a replica (running, exited, stopped for its disk limit).
The application's Instances table reuses it.
- The servers table links each server's name to its page.
- `fr.ts`: French for the new texts. Fractions of a core take the French
decimal comma (0,25).
Compared with the mockup on desktop and mobile, the page keeps its type,
side menu, stat cards and table style. It leaves out the sections that
have no backend yet, so the menu shows only these three:
- proxy and certificates;
- WireGuard;
- Cloudflare Tunnel;
- Docker images and cleanup;
- registries;
- log export, security, transfer and danger zone;
- the agent's stream, certificate, CA fingerprint and log.
## How it was tested
- **Unit:**
- `server-view.spec.ts`: capacity, reservation, missing facts, disk
warning, replica numbers, disk-limit stop.
- `server-page.spec.ts`, through the real router: page content and
links, French with names untranslated and the decimal comma, "Server not
found", and the link from the list.
- Web suite: 293 passed. Lint and typecheck green.
- **Browser** (`tenant.browser.spec.ts`, Chromium, production build,
production CSP):
- a server is enrolled as an agent would;
- its three sections pass axe (WCAG 2.2 AA) with no console or CSP
problem;
- the list's link opens the page;
- another organization's owner gets 404 on it.
- The check runs last in the file. Three more full page loads inside the
accessibility loop pushed the owner over the API budget (300 requests a
minute), and the audit export test then hit "Too many attempts".
- **Lab** (a fresh Ubuntu container with a real agent and three deployed
applications): captures on desktop in English and mobile in French, next
to the mockup, with no horizontal overflow and no failed API call after
sign-in.
## Security considerations
- Read-only: no new write, no new audit event.
- The routes from #416 need `node.manage` and a browser session. Members
get "Server not found", the same answer as for a server of another
organization.
- No inline style, so the strict CSP is unchanged; the browser test runs
under it.
- Server, application, project and environment names are shown as typed
and never translated.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **New Features**
* Added server detail pages with general, agent, and resource sections,
including hardware information, replica status, and resource usage.
* Server names in the list now link to their detail pages. Pages refresh
automatically, show when replica results are truncated, and provide
clear loading and error states.
* Added French translations for server details, resource labels, and
related statuses.
* **Bug Fixes**
* Placement tables now show agent-reported replica status, with clearer
labels for disk-limit stops and unreported status.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Signed-off-by: samuel mbabhazi <[email protected]>
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
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.
Part of #264 (step 2 of #413). This is the API half; the page follows in its own pull request.
What changed
Two read routes for a server's page.
GET /organizations/{organizationId}/nodes/{nodeId}FleetAdministration.getNodeserves it.GET /organizations/{organizationId}/nodes/{nodeId}/replicastruncatedwhen there are more.state,stopReason,observedAt), as for an application's replicas.DeploymentCommands.nodeReplicas;ObservationStore.onNode;NodeReplicasController.The generated
openapi.json, API client and route and role matrix are updated, and SPEC describes both routes.Why
#264 replaces the preview at
/servers/samplewith a page on real data: the server's facts, labels and heartbeat, and what runs on it. No route exposed the allocations of one server.How it was tested
node-replicas-http.integration.spec.ts):member,projectAdmin,environmentViewerandoutsiderget 404 on both routes;node.managegets 401 on both routes, while the same token is accepted by a route open to such tokens.fleet-tenant×2,tenant-schema; CI runs PostgreSQL 17).Security considerations
node.manageon the organization. Only owners and admins hold it, and they read every environment of the organization, so listing application names leaks nothing to them.Summary by CodeRabbit