Миграция оркестратора на Debian 13: platform layer, preflight, status/diagnostics и structured logging
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import type { ReconfigureContext, ReconfigureOptions } from "../types/context";
|
||||
import { exists, readText, writeText } from "../lib/fs";
|
||||
import { info, step } from "../lib/log";
|
||||
import { info, setOperationContext, step, stepDone } from "../lib/log";
|
||||
import { parseRuntimeEnv, renderRuntimeEnv } from "../config/env";
|
||||
import { preflight } from "../steps/preflight";
|
||||
import { generateConfig } from "../steps/config";
|
||||
@@ -79,6 +79,7 @@ async function warnBootstrapDrift(nextConfigRaw: string): Promise<void> {
|
||||
}
|
||||
|
||||
export async function reconfigure(options: ReconfigureOptions): Promise<void> {
|
||||
setOperationContext(`reconfigure-${Date.now().toString(36)}`);
|
||||
const configRaw = await readText(options.sourceConfigPath);
|
||||
const config = parseRuntimeEnv(configRaw);
|
||||
|
||||
@@ -94,8 +95,10 @@ export async function reconfigure(options: ReconfigureOptions): Promise<void> {
|
||||
|
||||
step("preflight");
|
||||
await preflight(context);
|
||||
stepDone("preflight");
|
||||
step("install state marker");
|
||||
await ensureInstallStateExists();
|
||||
stepDone("install state marker");
|
||||
await warnBootstrapDrift(configRaw);
|
||||
|
||||
if (options.dryRun) {
|
||||
@@ -110,23 +113,30 @@ export async function reconfigure(options: ReconfigureOptions): Promise<void> {
|
||||
|
||||
step("backup");
|
||||
await backupCurrentState();
|
||||
stepDone("backup");
|
||||
|
||||
try {
|
||||
step("config generation");
|
||||
await generateConfig(context);
|
||||
stepDone("config generation");
|
||||
step("systemd units");
|
||||
await deploySystemd(context);
|
||||
stepDone("systemd units");
|
||||
step("firewall");
|
||||
await applyFirewall(context);
|
||||
stepDone("firewall");
|
||||
step("write env artifacts");
|
||||
await writeText(options.runtimeConfigPath, renderRuntimeEnv(config), 0o600);
|
||||
await runVisible`chown root:root ${options.runtimeConfigPath}`;
|
||||
await runVisible`chmod 0600 ${options.runtimeConfigPath}`;
|
||||
await writePostInstallEnv(context);
|
||||
stepDone("write env artifacts");
|
||||
step("smoke checks");
|
||||
await smoke(context);
|
||||
stepDone("smoke checks");
|
||||
step("finalize firewall rollback guard");
|
||||
await cancelFirewallRollback(context);
|
||||
stepDone("finalize firewall rollback guard");
|
||||
} catch (error) {
|
||||
info("reconfigure failed, rollback in progress");
|
||||
await rollbackFirewallNow(context);
|
||||
|
||||
Reference in New Issue
Block a user