Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/configurator-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ jobs:
LZC_EXECUTION_ENABLED: 'true'
LZC_APPLICATION_EXECUTION_ENABLED: 'true'
LZC_RETIREMENTS_ENABLED: ${{ vars.LZC_RETIREMENTS_ENABLED }}
LZC_RUNNER_POOL_SIZE: '2'
LZC_RUNNER_POOL_SIZE: '4'
LZC_DEPLOYMENT_ARTIFACT_KEY: ${{ secrets.LZC_DEPLOYMENT_ARTIFACT_KEY }}
- name: Login with application-space deployer
env:
Expand Down Expand Up @@ -306,7 +306,7 @@ jobs:
cf run-task landing-zone-configurator --command './runtime/bin/node apps/api/dist/check-connections.js' --name "connections-$GITHUB_RUN_ID" -m 128M -k 4096M --wait
cf run-task landing-zone-configurator --command "./runtime/bin/node apps/api/dist/check-plan-runner.js $GITHUB_RUN_ID" --name "runner-$GITHUB_RUN_ID" -m 128M -k 4096M --wait
for attempt in 1 2 3; do
if cf logs landing-zone-configurator --recent | node infra/ci/runner-evidence.mjs "$GITHUB_RUN_ID" 2; then break; fi
if cf logs landing-zone-configurator --recent | node infra/ci/runner-evidence.mjs "$GITHUB_RUN_ID" 4; then break; fi
test "$attempt" -lt 3 || exit 1
sleep 5
done
Expand Down
2 changes: 1 addition & 1 deletion docs/workflows.de.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ umetikettieren.

[Configurator Production Release](https://github.com/stackitcloud/stackit-landing-zone/actions/workflows/configurator-production.yml) · [Quelle](../.github/workflows/configurator-production.yml) veröffentlicht ein stabiles Release und deployt erst nach manueller Freigabe von `lzc-prod-release`. Eingaben: `version` (Standard `v2.1.0`), `publish` (Standard `true`), `release_run_id` (für Veröffentlichung erforderlich) und `release_mode` (Standard `skip`, alternativ `qualified`). Einen vollständig erfolgreichen **Configurator Release** von derselben `main`-Revision mit demselben Modus verwenden, unabhängig davon, ob dieser Dev deployt oder `build_only=true` genutzt hat. Ein zweiter Build ist nicht erforderlich. `skip` dokumentiert die übersprungene Assistant-Qualifikation, ohne historische Dev-only-Artefakte umzudeuten. Alle Prüfungen außerhalb der Inferenz bleiben verpflichtend.

Ein veröffentlichtes stabiles GitHub Release mit den erforderlichen quellgebundenen Assets startet den Workflow ebenfalls. Veröffentlichung über `GITHUB_TOKEN` setzt im selben Lauf fort und benötigt kein zweites Ereignis. `publish=false` deployt ein bestehendes kompatibles veröffentlichtes Release nach neuer manueller Freigabe. Pre-Releases und beliebige Artefakte werden abgelehnt. Produktion verwendet unveränderliche angehängte Anwendungs-/Runner-Assets, begrenzte CF-Zugänge und Rolling Deployment mit drei Web-Repliken.
Ein veröffentlichtes stabiles GitHub Release mit den erforderlichen quellgebundenen Assets startet den Workflow ebenfalls. Veröffentlichung über `GITHUB_TOKEN` setzt im selben Lauf fort und benötigt kein zweites Ereignis. `publish=false` deployt ein bestehendes kompatibles veröffentlichtes Release nach neuer manueller Freigabe. Pre-Releases und beliebige Artefakte werden abgelehnt. Produktion hält vier gemeinsam genutzte warme Einmal-Runner für Plattform-, Application- und Rückbauaufträge bereit. Produktion verwendet unveränderliche angehängte Anwendungs-/Runner-Assets, begrenzte CF-Zugänge und Rolling Deployment mit drei Web-Repliken.

Bootstrap, Platform und Runtime akzeptieren jetzt `environment` (Standard `lzc-dev`, alternativ `lzc-prod`). Plan-/Apply-Environments und Schreibwarteschlangen folgen der ausgewählten Stage. Prod Platform wählt die Replica-Set-Datenbank; Prod Runtime ergänzt eigene DNS-Zone, öffentliche Domain und Space-begrenzte Konten. Der lokale verschlüsselte Bootstrap `operator-project` importiert ein bestehendes Betreiberprojekt und provisioniert seine eigene projektbegrenzte Identität. Siehe [vollständiges Produktionshandbuch](../landing-zone-configurator/docs/production.de.md) für Bootstrap, Bindings, Zugangsrotation und Wiederherstellung.

Expand Down
2 changes: 1 addition & 1 deletion docs/workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ selection. A failed qualification cannot be relabeled as `skip`.

[Configurator Production Release](https://github.com/stackitcloud/stackit-landing-zone/actions/workflows/configurator-production.yml) · [source](../.github/workflows/configurator-production.yml) publishes a stable release and deploys only after manual `lzc-prod-release` approval. It accepts `version` (default `v2.1.0`), `publish` (default `true`), `release_run_id` (required for publication) and `release_mode` (`skip` by default, or `qualified`). Reuse a fully successful **Configurator Release** from the same `main` revision and mode, whether it deployed Dev or used `build_only=true`. A second build is unnecessary. `skip` records skipped Assistant qualification without reinterpreting historical Dev-only artifacts. All non-inference checks remain mandatory.

A published stable GitHub Release with the required source-bound assets also triggers this workflow. Publication with `GITHUB_TOKEN` continues within the same run, avoiding reliance on another event. `publish=false` redeploys an existing compatible published release under a fresh manual approval. Pre-releases and arbitrary artifacts are rejected. Production uses immutable attached application/Runner assets, scoped CF credentials and rolling deployment of three web replicas.
A published stable GitHub Release with the required source-bound assets also triggers this workflow. Publication with `GITHUB_TOKEN` continues within the same run, avoiding reliance on another event. `publish=false` redeploys an existing compatible published release under a fresh manual approval. Pre-releases and arbitrary artifacts are rejected. Production maintains four shared one-shot warm Runner reserves for Platform, Application and Retirement jobs. Production uses immutable attached application/Runner assets, scoped CF credentials and rolling deployment of three web replicas.

The Bootstrap, Platform and Runtime inputs now include `environment` (`lzc-dev` by default, or `lzc-prod`). Their plan/apply Environments and mutation queues follow the selected stage. Prod platform inputs select the replica-set database; Prod runtime adds the dedicated DNS zone, public domain and space-scoped identities. The local encrypted `operator-project` bootstrap imports an existing operator project and provisions its dedicated project-limited identity. See the [complete production runbook](../landing-zone-configurator/docs/production.md) for bootstrap, bindings, credential rotation and recovery.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-- A stopped, durably reconciled Retirement no longer needs its one-shot process.
-- Unresolved State recovery and mismatched app/source bindings remain protected.
CREATE FUNCTION lzc_auth.retire_completed_retirement_runners(p_space uuid,p_origin text)
RETURNS integer LANGUAGE plpgsql SECURITY DEFINER SET search_path=pg_catalog AS $$
DECLARE retired integer;
BEGIN
UPDATE lzc.runner_pool_slots slot SET status='retiring',assignment=NULL,token_hash=NULL
FROM lzc.retirement_jobs job
WHERE slot.space_id=p_space AND slot.origin=p_origin AND slot.status='consumed'
AND NOT slot.is_probe AND slot.job_id=job.id
AND slot.app_id=job.runner_app_id AND slot.source_droplet_id=job.runner_package_id
AND job.status IN ('succeeded','failed') AND job.stopped_at IS NOT NULL
AND job.finished_at IS NOT NULL
AND (job.recovery_adopted_at IS NOT NULL OR (
job.recovery_ciphertext IS NULL AND NOT coalesce((job.result->>'recoveryRequired')::boolean,false)
))
AND NOT EXISTS(SELECT 1 FROM lzc.retirement_execution_scopes scope WHERE scope.lock_run_id=job.id);
GET DIAGNOSTICS retired=ROW_COUNT;
RETURN retired;
END $$;
REVOKE ALL ON FUNCTION lzc_auth.retire_completed_retirement_runners(uuid,text) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION lzc_auth.retire_completed_retirement_runners(uuid,text) TO configurator_app;
1 change: 1 addition & 0 deletions landing-zone-configurator/app/apps/api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ if (process.env.LZC_AUTH_ENABLED === "true") {
broker: "retirement",
dropletId,
inspection: platformInspection,
...(runnerPool ? { warm: runnerPool } : {}),
});
const cloud = new StackitRetirementCloud();
retirementPreparation = new RetirementPreparation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export interface WarmRunnerDispatch {
id: string,
ticket: string,
origin: string,
broker: "platform" | "application",
broker: "platform" | "application" | "retirement",
record: (appId: string, sourceDropletId: string) => Promise<void>,
): Promise<boolean>;
remove(id: string, appId: string | null): Promise<boolean>;
Expand Down Expand Up @@ -215,14 +215,13 @@ export class CloudFoundryPlanRunner implements PlanRunner {
) {
guid(id);
if (
this.config.broker !== "retirement" &&
(await this.config.warm?.start(
await this.config.warm?.start(
id,
ticket,
origin,
this.config.broker ?? "platform",
record,
))
)
)
return;
const { call, appId } = await this.prepare(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export class RunnerPool implements WarmRunnerDispatch {
id: string,
ticket: string,
origin: string,
broker: "platform" | "application",
broker: "platform" | "application" | "retirement",
record: (appId: string, sourceDropletId: string) => Promise<void>,
probe = false,
): Promise<boolean> {
Expand Down Expand Up @@ -256,6 +256,10 @@ export class RunnerPool implements WarmRunnerDispatch {
"SELECT lzc_auth.retire_completed_application_runners($1,$2)",
[this.config.spaceId, this.config.origin],
);
await this.database.query(
"SELECT lzc_auth.retire_completed_retirement_runners($1,$2)",
[this.config.spaceId, this.config.origin],
);
await this.database.query(
"UPDATE lzc.runner_pool_slots SET status='retiring',assignment=NULL,token_hash=NULL WHERE space_id=$1 AND origin=$2 AND ((status IN ('warming','ready','reserved','assigned') AND (expires_at<=now() OR (status='ready' AND last_seen_at<now()-interval '15 seconds') OR ($3=0 AND status IN ('warming','ready')))) OR (status='consumed' AND is_probe AND expires_at<=now()))",
[this.config.spaceId, this.config.origin, this.config.size],
Expand Down
6 changes: 4 additions & 2 deletions landing-zone-configurator/app/apps/worker/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ if (
const pool =
process.env.LZC_POOL_RUNNER_ID !== undefined ||
process.env.LZC_POOL_TICKET !== undefined;
if (pool && broker === "retirement")
throw new Error("Retirement requires a dedicated cold runner");
const shutdown = new AbortController();
const stop = () => shutdown.abort();
const removeShutdownListeners = () => {
Expand All @@ -34,6 +32,10 @@ const outcome = pool
removeShutdownListeners();
return runWorker(options);
},
executeRetirement: (options) => {
removeShutdownListeners();
return runRetirementWorker(options);
},
},
).finally(removeShutdownListeners)
: broker === "retirement"
Expand Down
14 changes: 11 additions & 3 deletions landing-zone-configurator/app/apps/worker/src/warm-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
type RunnerPoolAssignment,
runnerPoolAssignmentSchema,
} from "@lzc/contracts";
import { runRetirementWorker } from "./retirement.js";
import { hostedBrokerOrigin, runWorker } from "./runner.js";

const idleLifetimeMilliseconds = 15 * 60 * 1000;
Expand All @@ -16,6 +17,7 @@ interface WarmRunnerOptions {

interface WarmRunnerDependencies {
execute?: typeof runWorker;
executeRetirement?: typeof runRetirementWorker;
now?: () => number;
wait?: (milliseconds: number, signal: AbortSignal) => Promise<void>;
}
Expand Down Expand Up @@ -104,14 +106,20 @@ export async function runWarmRunner(
throw new Error("Warm runner claim failed");
}
checkIdle();
if (claimed)
return (dependencies.execute ?? runWorker)({
if (claimed) {
const input = {
root: options.root,
id: claimed.id,
ticket: claimed.ticket,
broker: claimed.broker,
brokerOrigin,
};
if (claimed.broker === "retirement")
return (dependencies.executeRetirement ?? runRetirementWorker)(input);
return (dependencies.execute ?? runWorker)({
...input,
broker: claimed.broker,
});
}
try {
await wait(Math.min(1000, deadline - now()), options.signal);
} catch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1498,13 +1498,100 @@ it("transfers only a captured same-State scope to independent encrypted custody
},
})),
});
const warmCleanup = async (jobId: string) => {
const slotId = randomUUID(),
spaceId = randomUUID(),
origin = "https://configurator.example";
const binding = (
await admin.query(
"SELECT runner_app_id,runner_package_id FROM lzc.retirement_jobs WHERE id=$1",
[jobId],
)
).rows[0];
await admin.query(
"INSERT INTO lzc.runner_pool_slots(id,pool_key,origin,space_id,source_droplet_id,app_id,status,job_id,expires_at) VALUES($1,'retirement-fixture',$2,$3,$4,$5,'consumed',$6,now()+interval '1 hour')",
[
slotId,
origin,
spaceId,
binding.runner_package_id,
binding.runner_app_id,
jobId,
],
);
const retire = async (space = spaceId, address = origin) =>
Number(
(
await runtime.query(
"SELECT lzc_auth.retire_completed_retirement_runners($1,$2) AS count",
[space, address],
)
).rows[0].count,
);
const protectedRun = async () => expect(await retire()).toBe(0);
await protectedRun();
return {
protectedRun,
completed: async () => {
expect(await retire(randomUUID())).toBe(0);
expect(await retire(spaceId, "https://other.example")).toBe(0);
await admin.query(
"UPDATE lzc.runner_pool_slots SET source_droplet_id=$2 WHERE id=$1",
[slotId, randomUUID()],
);
await protectedRun();
await admin.query(
"UPDATE lzc.runner_pool_slots SET source_droplet_id=$2 WHERE id=$1",
[slotId, binding.runner_package_id],
);
await admin.query(
"UPDATE lzc.runner_pool_slots SET app_id=$2 WHERE id=$1",
[slotId, randomUUID()],
);
await protectedRun();
await admin.query(
"UPDATE lzc.runner_pool_slots SET app_id=$2 WHERE id=$1",
[slotId, binding.runner_app_id],
);
const previousResult = (
await admin.query(
"SELECT result FROM lzc.retirement_jobs WHERE id=$1",
[jobId],
)
).rows[0].result;
await admin.query(
"UPDATE lzc.retirement_jobs SET result=jsonb_set(coalesce(result,'{}'),'{recoveryRequired}','true') WHERE id=$1",
[jobId],
);
await protectedRun();
await admin.query(
"UPDATE lzc.retirement_jobs SET result=$2 WHERE id=$1",
[jobId, previousResult],
);
expect(await retire()).toBe(1);
expect(
(
await admin.query(
"SELECT status FROM lzc.runner_pool_slots WHERE id=$1",
[slotId],
)
).rows[0].status,
).toBe("retiring");
expect(await retire()).toBe(0);
await admin.query("DELETE FROM lzc.runner_pool_slots WHERE id=$1", [
slotId,
]);
},
};
};
const createPlan = async () => {
const job = await execution.plan(owner, entry.id, {
generation: entry.generation,
scopeId: executionScope,
}),
ticket = await waitTicket(job.id),
input = await execution.input(ticket);
const cleanup = await warmCleanup(job.id);
expect(input.key).toEqual(key);
const nativeOutput = {
text: "$ tofu init\nInitializing the backend...\n",
Expand Down Expand Up @@ -1561,7 +1648,9 @@ it("transfers only a captured same-State scope to independent encrypted custody
(j) => j.id === job.id,
)?.canApply,
).toBe(false);
await cleanup.protectedRun();
await execution.inspect(owner, entry.id, job.id, entry.generation);
await cleanup.completed();
expect(
(await execution.review(owner, entry.id)).jobs.find(
(j) => j.id === job.id,
Expand All @@ -1582,6 +1671,7 @@ it("transfers only a captured same-State scope to independent encrypted custody
}),
ticket = await waitTicket(job.id),
input = await execution.input(ticket);
const cleanup = await warmCleanup(job.id);
expect(input.plan?.sha256).toBe(artifactHash);
await execution.stage(ticket, "validating");
await execution.stage(ticket, "applying");
Expand Down Expand Up @@ -1644,7 +1734,15 @@ it("transfers only a captured same-State scope to independent encrypted custody
)
).rows[0].result,
).toBe("protected");
return execution.inspect(owner, entry.id, job.id, entry.generation);
await cleanup.protectedRun();
const inspected = await execution.inspect(
owner,
entry.id,
job.id,
entry.generation,
);
await cleanup.completed();
return inspected;
};
const applicationRetirementPlan = await createPlan();
const applicationRemoved = await runApply(applicationRetirementPlan.id, true);
Expand Down
Loading
Loading