-
Notifications
You must be signed in to change notification settings - Fork 0
feat: per-node maintenance mode #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6b7786b
96ebb6f
69a355a
f1ab2dc
bf6c29a
244bf50
62fecca
c81f685
75836ef
b23ff14
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| -- AlterTable | ||
| ALTER TABLE "VectorNode" ADD COLUMN "maintenanceMode" BOOLEAN NOT NULL DEFAULT false; | ||
| ALTER TABLE "VectorNode" ADD COLUMN "maintenanceModeAt" TIMESTAMP(3); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,9 +16,26 @@ export async function GET(request: Request) { | |
| // Fetch the node to check for pending actions (e.g., self-update) | ||
| const node = await prisma.vectorNode.findUnique({ | ||
| where: { id: agent.nodeId }, | ||
| select: { pendingAction: true }, | ||
| select: { pendingAction: true, maintenanceMode: true }, | ||
| }); | ||
|
|
||
| if (node?.maintenanceMode) { | ||
| const environment = await prisma.environment.findUnique({ | ||
| where: { id: agent.environmentId }, | ||
| select: { secretBackend: true }, | ||
| }); | ||
| const settings = await prisma.systemSettings.findUnique({ | ||
| where: { id: "singleton" }, | ||
| select: { fleetPollIntervalMs: true }, | ||
| }); | ||
| return NextResponse.json({ | ||
| pipelines: [], | ||
| pollIntervalMs: settings?.fleetPollIntervalMs ?? 15_000, | ||
| secretBackend: environment?.secretBackend ?? "BUILTIN", | ||
| pendingAction: node.pendingAction ?? undefined, | ||
| }); | ||
| } | ||
|
Comment on lines
+22
to
+37
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When the node is in maintenance mode, the early return fetches the environment with only // normal path
...(environment.secretBackend !== "BUILTIN"
? { secretBackendConfig: environment.secretBackendConfig }
: {}),If an environment uses Vault, AWS SM, or another external backend and the agent relies on receiving The fix is to select const environment = await prisma.environment.findUnique({
where: { id: agent.environmentId },
select: { secretBackend: true, secretBackendConfig: true },
});
// ...
return NextResponse.json({
pipelines: [],
pollIntervalMs: settings?.fleetPollIntervalMs ?? 15_000,
secretBackend: environment?.secretBackend ?? "BUILTIN",
...(environment?.secretBackend !== "BUILTIN" && environment?.secretBackendConfig
? { secretBackendConfig: environment.secretBackendConfig }
: {}),
pendingAction: node.pendingAction ?? undefined,
});Prompt To Fix With AIThis is a comment left during a code review.
Path: src/app/api/agent/config/route.ts
Line: 22-37
Comment:
**`secretBackendConfig` omitted for non-BUILTIN backends in maintenance response**
When the node is in maintenance mode, the early return fetches the environment with only `{ secretBackend: true }` and never includes `secretBackendConfig` in the response. The normal path includes it for all non-BUILTIN backends:
```ts
// normal path
...(environment.secretBackend !== "BUILTIN"
? { secretBackendConfig: environment.secretBackendConfig }
: {}),
```
If an environment uses Vault, AWS SM, or another external backend and the agent relies on receiving `secretBackendConfig` to maintain or re-initialize its connection to that backend on each config poll, it would lose that initialization data for the duration of maintenance mode. When maintenance ends, the first poll would restore the full config, but if the agent's secret-backend client has any transient state derived from that field it could fail to reconnect cleanly.
The fix is to select `secretBackendConfig` alongside `secretBackend` in the maintenance-mode environment query, and then conditionally include it in the early-return payload to match the normal path:
```ts
const environment = await prisma.environment.findUnique({
where: { id: agent.environmentId },
select: { secretBackend: true, secretBackendConfig: true },
});
// ...
return NextResponse.json({
pipelines: [],
pollIntervalMs: settings?.fleetPollIntervalMs ?? 15_000,
secretBackend: environment?.secretBackend ?? "BUILTIN",
...(environment?.secretBackend !== "BUILTIN" && environment?.secretBackendConfig
? { secretBackendConfig: environment.secretBackendConfig }
: {}),
pendingAction: node.pendingAction ?? undefined,
});
```
How can I resolve this? If you propose a fix, please make it concise. |
||
|
|
||
| const environment = await prisma.environment.findUnique({ | ||
| where: { id: agent.environmentId }, | ||
| select: { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.