fix: bound agentrun restart dry-run output
Pipelines as Code CI / hwlab-web-probe-sentinel-nc01- Success
Pipelines as Code CI / hwlab-web-probe-sentinel-nc01- Success
This commit is contained in:
@@ -80,9 +80,20 @@ export function parseLaneConfirmOptions(args: string[]): LaneConfirmOptions {
|
||||
const base = parseConfirmOptions(args);
|
||||
let node: string | null = null;
|
||||
let lane: string | null = null;
|
||||
let full = false;
|
||||
let raw = false;
|
||||
for (let index = 0; index < args.length; index += 1) {
|
||||
const arg = args[index];
|
||||
if (arg === "--confirm" || arg === "--dry-run") continue;
|
||||
if (arg === "--full") {
|
||||
full = true;
|
||||
continue;
|
||||
}
|
||||
if (arg === "--raw") {
|
||||
raw = true;
|
||||
full = true;
|
||||
continue;
|
||||
}
|
||||
if (arg === "--node") {
|
||||
const value = args[index + 1];
|
||||
if (value === undefined || value.startsWith("--")) throw new Error("--node requires a value");
|
||||
@@ -100,7 +111,7 @@ export function parseLaneConfirmOptions(args: string[]): LaneConfirmOptions {
|
||||
throw new Error(`unsupported control-plane option: ${arg}`);
|
||||
}
|
||||
if (node === null && lane === null) throw new Error("control-plane apply requires --node and --lane");
|
||||
return { ...base, node, lane };
|
||||
return { ...base, node, lane, full, raw };
|
||||
}
|
||||
|
||||
export function parseRefreshOptions(args: string[]): RefreshOptions {
|
||||
|
||||
@@ -128,7 +128,11 @@ export async function runAgentRunCommand(config: UniDeskConfig | null, args: str
|
||||
return options.full || options.raw ? result : renderAgentRunControlPlaneStatusSummary(result);
|
||||
}
|
||||
if (action === "secret-sync") return await secretSync(config, parseSecretSyncOptions(actionArgs));
|
||||
if (action === "restart") return await restartYamlLane(config, parseLaneConfirmOptions(actionArgs));
|
||||
if (action === "restart") {
|
||||
const options = parseLaneConfirmOptions(actionArgs);
|
||||
const result = await restartYamlLane(config, options);
|
||||
return options.full || options.raw ? result : renderAgentRunControlPlaneActionSummary(result, "AGENTRUN CONTROL-PLANE RESTART");
|
||||
}
|
||||
if (action === "expose") return await exposeAgentRun(config, parseConfirmOptions(actionArgs));
|
||||
if (action === "trigger-current") {
|
||||
const options = parseTriggerOptions(actionArgs);
|
||||
|
||||
@@ -222,7 +222,7 @@ export interface SecretSyncOptions extends ConfirmOptions {
|
||||
secretIds: string[];
|
||||
}
|
||||
|
||||
export interface LaneConfirmOptions extends ConfirmOptions {
|
||||
export interface LaneConfirmOptions extends ConfirmOptions, DisclosureOptions {
|
||||
node: string | null;
|
||||
lane: string | null;
|
||||
}
|
||||
|
||||
@@ -218,6 +218,17 @@ export function renderAgentRunControlPlaneActionSummary(result: Record<string, u
|
||||
["mutation", displayValue(result.mutation ?? "-")],
|
||||
["namespace", displayValue(result.namespace ?? runtime.namespace ?? "-")],
|
||||
];
|
||||
const plan = record(result.plan);
|
||||
const secretRefs = record(plan.secretRefs);
|
||||
const providerCredentials = Array.isArray(plan.providerCredentials) ? plan.providerCredentials.map(record) : [];
|
||||
const planRows = [
|
||||
["deployment", displayValue(plan.deployment ?? "-")],
|
||||
["annotation", displayValue(plan.annotation ?? "-")],
|
||||
["patchType", displayValue(plan.patchType ?? "-")],
|
||||
["reason", displayValue(plan.reason ?? "-")],
|
||||
["secretRefCount", displayValue(secretRefs.count ?? "-")],
|
||||
["providerCredentialCount", displayValue(providerCredentials.length === 0 ? "-" : providerCredentials.length)],
|
||||
].filter((row) => row[1] !== "-");
|
||||
const countKeys = [
|
||||
"runnerJobCount",
|
||||
"inactiveCandidateCount",
|
||||
@@ -246,6 +257,20 @@ export function renderAgentRunControlPlaneActionSummary(result: Record<string, u
|
||||
"",
|
||||
renderTable(["FIELD", "VALUE"], summaryRows),
|
||||
];
|
||||
if (planRows.length > 0) lines.push("", "PLAN", renderTable(["FIELD", "VALUE"], planRows));
|
||||
if (providerCredentials.length > 0) {
|
||||
lines.push(
|
||||
"",
|
||||
"PROVIDER CREDENTIALS",
|
||||
renderTable(["PROFILE", "NAMESPACE", "SECRET", "KEYS", "VALUES"], providerCredentials.slice(0, 8).map((credential) => [
|
||||
displayValue(credential.profile),
|
||||
displayValue(credential.namespace),
|
||||
displayValue(credential.name),
|
||||
Array.isArray(credential.keys) ? credential.keys.map(String).join(",") : "-",
|
||||
"false",
|
||||
])),
|
||||
);
|
||||
}
|
||||
if (countRows.length > 0) lines.push("", renderTable(["COUNT", "VALUE"], countRows));
|
||||
const nextLines = renderNextObjectLines(record(result.next ?? result.followUp));
|
||||
if (nextLines.length > 0) lines.push("", "NEXT", ...nextLines);
|
||||
|
||||
@@ -131,6 +131,7 @@ export function compactAgentRunLaneStatusTarget(spec: AgentRunLaneSpec): Record<
|
||||
|
||||
export async function restartYamlLane(config: UniDeskConfig, options: LaneConfirmOptions): Promise<Record<string, unknown>> {
|
||||
const { configPath, spec } = resolveAgentRunLaneTarget(options);
|
||||
const target = options.full || options.raw ? agentRunLaneSummary(spec) : compactAgentRunLaneStatusTarget(spec);
|
||||
const plan = {
|
||||
node: spec.nodeId,
|
||||
kubeRoute: spec.nodeKubeRoute,
|
||||
@@ -139,6 +140,26 @@ export async function restartYamlLane(config: UniDeskConfig, options: LaneConfir
|
||||
deployment: spec.runtime.managerDeployment,
|
||||
annotation: "kubectl.kubernetes.io/restartedAt",
|
||||
reason: "reload-lane-secrets-or-runtime-env",
|
||||
patchType: "deployment-template-annotation",
|
||||
secretRefs: {
|
||||
count: spec.secrets.length,
|
||||
items: spec.secrets.map((secret) => ({
|
||||
id: secret.id,
|
||||
namespace: secret.targetRef.namespace,
|
||||
name: secret.targetRef.name,
|
||||
key: secret.targetRef.key,
|
||||
providerCredentialProfile: secret.providerCredentialProfile,
|
||||
valuesPrinted: false,
|
||||
})),
|
||||
valuesPrinted: false,
|
||||
},
|
||||
providerCredentials: agentRunProviderCredentialRefs(spec).map((credential) => ({
|
||||
profile: credential.profile,
|
||||
namespace: credential.secretRef.namespace,
|
||||
name: credential.secretRef.name,
|
||||
keys: credential.secretRef.keys,
|
||||
valuesPrinted: false,
|
||||
})),
|
||||
valuesPrinted: false,
|
||||
};
|
||||
if (options.dryRun || !options.confirm) {
|
||||
@@ -148,11 +169,12 @@ export async function restartYamlLane(config: UniDeskConfig, options: LaneConfir
|
||||
mode: "dry-run",
|
||||
mutation: false,
|
||||
configPath,
|
||||
target: agentRunLaneSummary(spec),
|
||||
target,
|
||||
plan,
|
||||
next: {
|
||||
confirm: `bun scripts/cli.ts agentrun control-plane restart --node ${spec.nodeId} --lane ${spec.lane} --confirm`,
|
||||
status: `bun scripts/cli.ts agentrun control-plane status --node ${spec.nodeId} --lane ${spec.lane}`,
|
||||
full: `bun scripts/cli.ts agentrun control-plane restart --node ${spec.nodeId} --lane ${spec.lane} --dry-run --full`,
|
||||
},
|
||||
valuesPrinted: false,
|
||||
};
|
||||
@@ -165,12 +187,13 @@ export async function restartYamlLane(config: UniDeskConfig, options: LaneConfir
|
||||
mode: "confirmed-rollout-restart",
|
||||
mutation: true,
|
||||
configPath,
|
||||
target: agentRunLaneSummary(spec),
|
||||
target,
|
||||
plan,
|
||||
result: payload,
|
||||
capture: compactCapture(result, { full: result.exitCode !== 0, stdoutTailChars: 4000, stderrTailChars: 4000 }),
|
||||
next: {
|
||||
status: `bun scripts/cli.ts agentrun control-plane status --node ${spec.nodeId} --lane ${spec.lane}`,
|
||||
full: `bun scripts/cli.ts agentrun control-plane restart --node ${spec.nodeId} --lane ${spec.lane} --dry-run --full`,
|
||||
},
|
||||
valuesPrinted: false,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user