aiinfra-tools 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +268 -0
- package/README.md +27 -3
- package/bin/aiinfra.mjs +5 -2
- package/bin/report.mjs +177 -0
- package/fleetops/README.md +33 -1
- package/fleetops/deploy/shadow-gate/argo-analysistemplate.yaml +34 -0
- package/fleetops/deploy/shadow-gate/argo-rollout-example.yaml +38 -0
- package/fleetops/deploy/shadow-gate/flagger-canary.yaml +34 -0
- package/fleetops/deploy/shadow-gate/judge.yaml +51 -0
- package/fleetops/deploy/shadow-gate/llmd-canary-example.yaml +35 -0
- package/fleetops/deploy/shadow-gate/podmonitor-vllm.yaml +20 -0
- package/fleetops/deploy/shadow-live/README.md +41 -0
- package/fleetops/deploy/shadow-live/kit.yaml +123 -0
- package/fleetops/deploy/shadow-live/load-canary.yaml +26 -0
- package/fleetops/deploy/shadow-live/run.sh +53 -0
- package/fleetops/docs/ADMISSION.md +9 -9
- package/fleetops/docs/FABRIC-STORAGE.md +1 -1
- package/fleetops/docs/SERVING.md +11 -1
- package/fleetops/docs/SHADOW.md +250 -0
- package/fleetops/docs/SIGNALS.md +5 -2
- package/fleetops/docs/WORKLOADS.md +1 -1
- package/fleetops/package.json +7 -4
- package/fleetops/src/adapters/fabric.mjs +19 -7
- package/fleetops/src/adapters/live.mjs +38 -5
- package/fleetops/src/adapters/logs.mjs +10 -7
- package/fleetops/src/adapters/nvsentinel.mjs +95 -0
- package/fleetops/src/adapters/topology.mjs +53 -1
- package/fleetops/src/admission.mjs +26 -18
- package/fleetops/src/api.mjs +2 -1
- package/fleetops/src/bundle.mjs +3 -0
- package/fleetops/src/calibrate.mjs +1 -1
- package/fleetops/src/detect.mjs +1 -1
- package/fleetops/src/export.mjs +5 -1
- package/fleetops/src/goodput.mjs +0 -2
- package/fleetops/src/incidents.mjs +1 -2
- package/fleetops/src/ingest.mjs +10 -3
- package/fleetops/src/inject.mjs +2 -2
- package/fleetops/src/live.mjs +2 -1
- package/fleetops/src/llmd.mjs +7 -3
- package/fleetops/src/optimize.mjs +1 -1
- package/fleetops/src/power.mjs +7 -7
- package/fleetops/src/procure.mjs +67 -0
- package/fleetops/src/rca.mjs +1 -1
- package/fleetops/src/rollout.mjs +1 -1
- package/fleetops/src/schema.mjs +3 -2
- package/fleetops/src/security.mjs +1 -1
- package/fleetops/src/serving.mjs +32 -10
- package/fleetops/src/shadow-canary.mjs +74 -0
- package/fleetops/src/shadow-gate.mjs +49 -0
- package/fleetops/src/shadow-prom.mjs +205 -0
- package/fleetops/src/shadow-replay.mjs +147 -0
- package/fleetops/src/shadow.mjs +291 -0
- package/fleetops/src/stats.mjs +14 -0
- package/fleetops/src/traces.mjs +0 -5
- package/fleetops/tests/fixtures/real/README.md +5 -0
- package/fleetops/tools/admit-node.sh +51 -16
- package/fleetops/tools/amd-admit.py +111 -0
- package/fleetops/tools/cmd/calibrate.mjs +61 -0
- package/fleetops/tools/cmd/capacity.mjs +116 -0
- package/fleetops/tools/cmd/common.mjs +32 -0
- package/fleetops/tools/cmd/data.mjs +343 -0
- package/fleetops/tools/cmd/help.mjs +243 -0
- package/fleetops/tools/cmd/incidents.mjs +216 -0
- package/fleetops/tools/cmd/rollout.mjs +122 -0
- package/fleetops/tools/cmd/server.mjs +122 -0
- package/fleetops/tools/cmd/serving.mjs +95 -0
- package/fleetops/tools/cmd/shadow.mjs +204 -0
- package/fleetops/tools/cmd/training.mjs +79 -0
- package/fleetops/tools/collect.sh +6 -1
- package/fleetops/tools/fleetops.mjs +18 -1308
- package/fleetops/tools/loop-demo.mjs +1 -1
- package/fleetops/tools/workload-profile.mjs +0 -1
- package/fleetscope/README.md +5 -1
- package/fleetscope/build.mjs +4 -0
- package/fleetscope/dist/index.html +1013 -28
- package/fleetscope/docs/AGENTIC.md +89 -0
- package/fleetscope/docs/PLANNING.md +4 -2
- package/fleetscope/docs/VALIDATION-AGENTIC.md +37 -0
- package/fleetscope/package.json +4 -3
- package/fleetscope/src/agentic.js +288 -0
- package/fleetscope/src/ask.js +0 -1
- package/fleetscope/src/cluster-ui.js +1 -0
- package/fleetscope/src/engine.js +29 -13
- package/fleetscope/src/index.src.html +15 -5
- package/fleetscope/src/inference-ui.js +1 -0
- package/fleetscope/src/ingest.js +89 -3
- package/fleetscope/src/optimize.js +11 -5
- package/fleetscope/src/plan.js +1 -1
- package/fleetscope/src/training-ui.js +1 -0
- package/fleetscope/tools/agentic.mjs +148 -0
- package/fleetscope/tools/tracelab-data.mjs +27 -0
- package/gpu-health/README.md +13 -2
- package/gpu-health/docs/CONFIG.md +29 -1
- package/gpu-health/package.json +7 -4
- package/gpu-health/src/actions.mjs +16 -3
- package/gpu-health/src/analyze.mjs +3 -0
- package/gpu-health/src/config.mjs +3 -0
- package/gpu-health/src/executors.mjs +9 -4
- package/gpu-health/src/health.mjs +1 -1
- package/gpu-health/src/ingest.mjs +27 -3
- package/gpu-health/src/platforms.mjs +109 -0
- package/gpu-health/src/vendors.mjs +12 -5
- package/gpu-health/tools/gpu-health.mjs +6 -4
- package/gpu-ledger/README.md +3 -1
- package/gpu-ledger/package.json +12 -4
- package/gpu-ledger/src/adapters.mjs +3 -2
- package/gpu-ledger/src/cloud.mjs +104 -0
- package/gpu-ledger/src/core.mjs +12 -10
- package/gpu-ledger/tools/ledger.mjs +8 -2
- package/harness-ledger/README.md +152 -0
- package/harness-ledger/docs/FORMATS.md +114 -0
- package/harness-ledger/docs/METHOD.md +133 -0
- package/harness-ledger/docs/VALIDATION-ECONOMICS.md +59 -0
- package/harness-ledger/docs/VALIDATION-SWEBENCH.md +26 -0
- package/harness-ledger/docs/VALIDATION-TRACELAB.md +56 -0
- package/harness-ledger/package.json +19 -0
- package/harness-ledger/src/demo.mjs +115 -0
- package/harness-ledger/src/economics.mjs +184 -0
- package/harness-ledger/src/gpu.mjs +80 -0
- package/harness-ledger/src/html.mjs +63 -0
- package/harness-ledger/src/importers.mjs +247 -0
- package/harness-ledger/src/ledger.mjs +128 -0
- package/harness-ledger/src/opencost.mjs +55 -0
- package/harness-ledger/src/outcomes.mjs +67 -0
- package/harness-ledger/src/prices.mjs +75 -0
- package/harness-ledger/src/record.mjs +52 -0
- package/harness-ledger/src/waste.mjs +136 -0
- package/harness-ledger/tools/harness-ledger.mjs +199 -0
- package/harness-ledger/tools/validate-economics.mjs +69 -0
- package/harness-ledger/tools/validate-swebench.mjs +57 -0
- package/harness-ledger/tools/validate-tracelab.mjs +74 -0
- package/hybrid-tracing/package.json +4 -3
- package/hybrid-tracing/tools/fix-skew.mjs +1 -1
- package/inference-sizer/README.md +5 -1
- package/inference-sizer/build.mjs +1 -0
- package/inference-sizer/dist/index.html +299 -31
- package/inference-sizer/docs/ACCELERATORS.md +62 -0
- package/inference-sizer/docs/CATALOG.md +71 -0
- package/inference-sizer/docs/METHOD.md +1 -1
- package/inference-sizer/docs/VALIDATION-INFERENCEX.md +37 -0
- package/inference-sizer/package.json +4 -3
- package/inference-sizer/src/accelerators.js +194 -0
- package/inference-sizer/src/catalog.js +55 -22
- package/inference-sizer/src/fit-ui.js +1 -1
- package/inference-sizer/src/index.src.html +3 -0
- package/inference-sizer/src/model.js +45 -7
- package/inference-sizer/src/ui.js +1 -1
- package/inference-sizer/tools/validate-agentx.mjs +116 -0
- package/inference-sizer/tools/validate-inferencex.mjs +132 -0
- package/mcp/README.md +6 -1
- package/mcp/server.mjs +34 -0
- package/package.json +10 -6
- package/schemas/README.md +3 -0
- package/schemas/aiinfra.report.schema.json +474 -0
- package/schemas/commands.mjs +14 -0
- package/schemas/fleetops.shadow.canary.schema.json +96 -0
- package/schemas/fleetops.shadow.compare.schema.json +266 -0
- package/schemas/fleetops.shadow.prom.schema.json +354 -0
- package/schemas/harness-ledger.economics.schema.json +567 -0
- package/schemas/sizer.list.schema.json +15 -2
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
// fleetops CLI: help (see ../fleetops.mjs for the entry point and dispatch)
|
|
2
|
+
|
|
3
|
+
export const HELP = `fleetops — shared data layer for AIInfraTools
|
|
4
|
+
|
|
5
|
+
fleetops data import SOURCE FILE... [--store DIR] [options] load records into the store
|
|
6
|
+
fleetops data import bundle FILE.tar.gz|DIR a trace bundle (tools/collect.sh): every file, by its
|
|
7
|
+
manifest entry or by content
|
|
8
|
+
fleetops send FILE.tar.gz|DIR --to URL [--token T] upload a bundle to a fleetops server (POST /v1/bundle)
|
|
9
|
+
fleetops procure aws-blocks --gpu H100 --gpus 64 --days 7 the read-only AWS command listing Capacity Blocks on offer
|
|
10
|
+
fleetops procure gcp-calendar --gpu H200 --gpus 64 --days 7 --region us-central1 the read-only GCP calendar-mode advice
|
|
11
|
+
fleetops data summary [--store DIR] records per kind, time range and sources
|
|
12
|
+
fleetops data query KIND [--from T] [--to T] [--where k=v]... [--limit N]
|
|
13
|
+
fleetops data node NODE [--from T] [--to T] versions, shared switch/rack/PDU, log faults, changes
|
|
14
|
+
fleetops data requests [--from T] [--to T] per-request records (stages, replica) from stored spans
|
|
15
|
+
fleetops data rollup [--steps 60,3600] minute and hour device rollups (rollup-60/, rollup-3600/)
|
|
16
|
+
fleetops data compact [--raw-days 7] [--apply] drop old raw device/request/span days after rolling up,
|
|
17
|
+
keeping incident windows at full resolution (keep/)
|
|
18
|
+
fleetops data migrate [--apply] bring the store to the current schema version
|
|
19
|
+
fleetops serve [--port 9400] [--host 127.0.0.1] [--tokens FILE] [--on-prem [HOSTS]] [--site S] [--max-queue 200000]
|
|
20
|
+
ingest (remote_write, OTLP over HTTP: protobuf or JSON) and serve the read API (/api/…); tokens scope reads to a tenant; every API read
|
|
21
|
+
is audited in <store>/audit/api.jsonl; request content is redacted at ingest; --on-prem refuses outbound calls
|
|
22
|
+
to hosts not listed (also FLEETOPS_EGRESS_ALLOW)
|
|
23
|
+
fleetops token create --tokens FILE --name N [--roles read,ingest,admin] [--namespaces a,b] [--pools p] [--clusters c] [--infra]
|
|
24
|
+
fleetops token list --tokens FILE
|
|
25
|
+
fleetops data export gpu-health --out DIR [--from T] [--to T] samples.jsonl, jobs.json, results.jsonl for gpu-health
|
|
26
|
+
fleetops data export fleetscope-trace --out FILE [--pool P] CSV for FleetScope's Trace replay node
|
|
27
|
+
fleetops data export gpu-ledger --out usage.jsonl [--capacity cap.json] [--cluster C] usage records for gpu-ledger (billing, waste)
|
|
28
|
+
fleetops demo --training [--days 7] [--tuned-at D] training jobs with planted badput (for goodput and tune);
|
|
29
|
+
--tuned-at applies two recommendations on day D
|
|
30
|
+
fleetops demo [--scenario NAME] [--seed N] [--list] [--now] a store with one planted cause (a benchmark scenario) to
|
|
31
|
+
try detect, diagnose and incidents without a fleet;
|
|
32
|
+
--now moves it so the incident ends now (for the agent)
|
|
33
|
+
|
|
34
|
+
Sources (SOURCE):
|
|
35
|
+
exporter DCGM / AMD / SambaNova exporter text [--vendor V] [--t EPOCH] [--site S]
|
|
36
|
+
vllm vLLM /metrics snapshot --pool P [--before FILE | --window S] [--model M] [--gpu G] [--t EPOCH]
|
|
37
|
+
prom-range Prometheus query_range JSON --field ttftP99|tpotP99|rate|kvUsage|… [--pool P]
|
|
38
|
+
k8s-nodes kubectl get nodes -o json inventory with versions; rack and zone edges
|
|
39
|
+
k8s-pods kubectl get pods -A -o json
|
|
40
|
+
slurm-nodes scontrol show node -o (kernel version from OS=)
|
|
41
|
+
nvidia-smi-q nvidia-smi -q [--node N] (default: file name) versions, serials, PCI → GPU map
|
|
42
|
+
nvidia-topo nvidia-smi topo -m [--node N] NVLink and NIC affinity
|
|
43
|
+
amd-smi-static amd-smi static --json [--node N] [--rocm V] versions, IFWI, PCI → GPU map
|
|
44
|
+
amd-smi-topology amd-smi topology --json [--node N] XGMI and PCIe peer links
|
|
45
|
+
cloud-monitoring Google Cloud Monitoring timeSeries JSON [--site S] GKE node / TPU VM accelerator metrics → device samples
|
|
46
|
+
ibnetdiscover ibnetdiscover host → leaf → spine (with switch port numbers)
|
|
47
|
+
perfquery perfquery [-x] LID PORT output [--switch NAME] switch port counters (errors, xmit wait, data)
|
|
48
|
+
ibqueryerrors ibqueryerrors switch ports with error counters, fabric-wide
|
|
49
|
+
ethtool ethtool -S IFACE --node N --iface I RoCE NIC counters: pause frames, discards, link errors
|
|
50
|
+
ib-sysfs grep -H . /sys/class/infiniband/*/ports/*/{counters,hw_counters}/* --node N host IB/RoCE port counters, CNPs, ECN marks
|
|
51
|
+
fabric-prom Prometheus query_range of switch counters [--map metric=field,…] UFM telemetry, SONiC, SNMP (ifInErrors, …)
|
|
52
|
+
ports JSON lines {t, switch, port, symbolErrors?, xmitWait?, pfcPause?, …}
|
|
53
|
+
lustre-jobstats lctl get_param obdfilter.*.job_stats (on an OSS) [--before FILE] [--fs NAME] [--target OST0003] per-OST I/O per job
|
|
54
|
+
mountstats /proc/self/mountstats --node N [--before FILE --window S] NFS latency per export
|
|
55
|
+
storage JSON lines {t, target, op, node?, job?, ops?, bytes?, latMs?} anything else (S3 clients, loaders)
|
|
56
|
+
racks CSV: node,rack,row,pdu,site
|
|
57
|
+
kernel-log journalctl -k -o short-iso | dmesg -T | dmesg | syslog [--node N] [--boot T] [--year Y] [--utc-offset H]
|
|
58
|
+
XID, NVLink, PCIe AER, AMD RAS, MCE, IB link, NFS/Lustre, OOM (GPU index from nvidia-smi-q / amd-smi-static imports)
|
|
59
|
+
app-log NCCL / PyTorch job output [--node N] [--job J] [--t T]
|
|
60
|
+
k8s-events kubectl get events -A -o json cordon/reboot/scale changes; NotReady/OOM/mount/evict logs
|
|
61
|
+
nvsentinel NVSentinel health events: event-exporter CloudEvents, datastore documents, kubectl get healtheventresources -o json
|
|
62
|
+
GPU faults (XIDs through gpu-health's table), what NVSentinel recommends and whether it is remediating
|
|
63
|
+
helm-history helm history REL -n NS -o json [--release R] [--namespace NS]
|
|
64
|
+
otlp-traces OTLP/JSON traces (resourceSpans) [--derive] (also write per-request records)
|
|
65
|
+
kineto PyTorch profiler trace JSON (one rank) [--job J] [--node N] [--rank R] [--t0 T] per-rank steps
|
|
66
|
+
nccl-inspector NCCL Inspector profiler-plugin JSON [--job J] (default: from the nccl-inspector-<jobid> directory)
|
|
67
|
+
step-log JSON lines {t, rank, node, step, durS, commS?, dataS?, ckptS?, mfu?, loss?, gradNorm?, n?} [--job J]
|
|
68
|
+
requests gateway or proxy request logs (LiteLLM, OpenAI-style usage, OTLP gen_ai spans, CSV with t, isl,
|
|
69
|
+
osl, ttft?, e2e?): token counts and latencies, never prompts [--pool P] [--start T]
|
|
70
|
+
auto recognize each file by its content (exporter scrapes, vLLM metrics, nvidia-smi, kubectl JSON,
|
|
71
|
+
sacct, kernel and NCCL logs, step logs, Kineto, OTLP, NCCL Inspector, request logs, …)
|
|
72
|
+
admission tools/admit-node.sh output: versions, topology, DCGM diag, NCCL bandwidth, burn-in and SDC canary of a node
|
|
73
|
+
sdc-checks JSON lines of silent-data-corruption checks: tools/sdc-canary.py output, or your trainer's
|
|
74
|
+
{t, check: param-checksum|replay|nan, node, gpu, job, step, rank, group, value, ok}
|
|
75
|
+
sacct sacct -P -X --format=JobID,JobName,State,ExitCode,Start,End,NodeList,AllocTRES
|
|
76
|
+
changes JSON lines of change events
|
|
77
|
+
git-log git log --date=unix --pretty=format:'@@%H|%ad|%an|%s' --name-only [--repo NAME]
|
|
78
|
+
gpu-health a gpu-health state directory (events.jsonl, results.jsonl)
|
|
79
|
+
philly-machines Philly cluster_machine_list
|
|
80
|
+
philly-gpu Philly cluster_gpu_util [--from T] [--to T] [--step MIN] [--machines N|m1,m2]
|
|
81
|
+
philly-jobs Philly cluster_job_log [--from T] [--to T]
|
|
82
|
+
azure-llm Azure LLM inference trace CSV [--pool P] [--limit N]
|
|
83
|
+
mlperf MLPerf mlperf_log_summary.txt files [--isl N] (the path names the system, model and scenario)
|
|
84
|
+
acme AcmeTrace job trace CSV [--cluster NAME]
|
|
85
|
+
|
|
86
|
+
Calibration (fits are stored as calibration records; profiles are JSON files the tools read):
|
|
87
|
+
fleetops calibrate benchmarks [--isl N] [--no-fleetscope] [--profile OUT]
|
|
88
|
+
fit the Inference Sizer (and FleetScope) to benchmark records; runs named *interactive* are held out and checked
|
|
89
|
+
fleetops calibrate serving --graph G [--from T] [--to T] [--holdout 0.25] [--profile OUT] [--graph-out G2] [--every SECONDS]
|
|
90
|
+
fit each FleetScope pool of a graph to its serving records; --every re-fits on a schedule
|
|
91
|
+
fleetops calibrate drift --graph G --profile P [--from T] [--to T] [--fail-on-drift]
|
|
92
|
+
simulate the latest window with the stored multipliers; outside the 10%/20% bar → a drift record
|
|
93
|
+
fleetops calibrate apply --graph G --profile P --out G2 write the multipliers into a FleetScope graph
|
|
94
|
+
|
|
95
|
+
Root-cause analysis (diagnoses are stored as incident records):
|
|
96
|
+
fleetops rca detect [--from T] [--to T] [--min-failures 20] [--targets targets.json] [--diagnose] [--format md]
|
|
97
|
+
find job-failure and latency incidents (seasonal baseline + CUSUM, grouped); --diagnose ranks causes for each
|
|
98
|
+
fleetops rca diagnose --symptom job-failures|latency|device --from T --to T [--pool P] [--nodes n1,n2] [--format md]
|
|
99
|
+
fleetops rca eval --labels FILE top-1 / top-3 accuracy on labeled incidents (JSON lines: { incident, cause })
|
|
100
|
+
fleetops rca bench [--per-cause 10] [--seed 1] [--only PREFIX] [--injections] [--labels FILE] [--weights W] [--fit OUT]
|
|
101
|
+
[--min-top1 0.8] [--min-top3 0.95]
|
|
102
|
+
accuracy per cause on synthetic scenarios (default), injected faults and/or postmortem labels; --fit writes rule
|
|
103
|
+
weights fitted on the labels (held-out accuracy reported); exit 5 below the bar
|
|
104
|
+
detect/diagnose/bench take --weights W. detect: --method cusum (default) | threshold, --bin S, --group-gap S, --where k=v
|
|
105
|
+
|
|
106
|
+
Incidents (lifecycle as incident_event records; paging is a dry run unless --live):
|
|
107
|
+
fleetops incidents open [--from T] [--to T] detect, diagnose, open the new ones (severity from the symptom's size)
|
|
108
|
+
fleetops incidents list [--status open|acknowledged|mitigated|resolved]
|
|
109
|
+
fleetops incidents ack|mitigate|resolve|reopen|assign|severity|note ID --by NAME [--note TEXT] [--owner O]
|
|
110
|
+
[--severity sev1..sev4] [--cause RULE --component X] (resolve --cause stores the confirmed cause as a label)
|
|
111
|
+
fleetops incidents show ID | timeline ID [--out FILE.html] | postmortem ID [--out FILE.md]
|
|
112
|
+
fleetops incidents page ID --to pagerduty|opsgenie|webhook --action trigger|ack|resolve [--key K] [--url U] [--live]
|
|
113
|
+
rca bench --from-incidents score root-cause analysis on resolved incidents' confirmed causes
|
|
114
|
+
|
|
115
|
+
Real labels from a real fleet:
|
|
116
|
+
fleetops pull --from T [--to T] --prom URL [--loki URL] [--loki-query Q]… [--step 60] [--header 'Authorization: Bearer X']
|
|
117
|
+
a window of DCGM/AMD/vLLM/NCCL-Inspector series and kernel/NCCL logs from the fleet's own monitoring
|
|
118
|
+
fleetops backtest --labels postmortems.jsonl --prom URL [--loki URL] [--lookback 26h] [--weights W]
|
|
119
|
+
pull each confirmed incident's window and score root-cause analysis on it (misses name the incident)
|
|
120
|
+
fleetops gameday PLAN.json --allow FILE [--live] [--cooldown 900] [--prom URL --loki URL]
|
|
121
|
+
run injections one after another on a TEST cluster (dry run unless --live), then score detection and diagnosis
|
|
122
|
+
|
|
123
|
+
Goodput (where training GPU-hours went; checkpoint interval advice):
|
|
124
|
+
fleetops goodput [--from T] [--to T | --days 7] [--job J] [--targets targets.json] [--format md|html] [--out FILE]
|
|
125
|
+
allocated GPU-hours per job, team and day split into productive, slow steps, data stalls, checkpoint saves,
|
|
126
|
+
lost work, restarts, startup and idle; the fleet's interruption rate; the best checkpoint interval per job
|
|
127
|
+
|
|
128
|
+
Tuning (what to change, the expected effect, and afterwards whether it worked):
|
|
129
|
+
fleetops tune [--from T] [--to T | --days 7] [--targets targets.json] [--pools pools.json] [--format md|json] [--out F]
|
|
130
|
+
ranked changes for training (checkpoint interval, input pipeline, slow nodes, restarts, communication),
|
|
131
|
+
inference (KV cache, pool size and autoscaling with the Inference Sizer) and the fleet (flaky nodes, idle GPUs),
|
|
132
|
+
each with its evidence, knobs, expected effect and its basis (measured, model, upper bound)
|
|
133
|
+
pools.json: { "chat": { "model": "llama33-70b", "gpu": "H100", "gpus": 32 } } (fleetops tune models lists ids)
|
|
134
|
+
fleetops tune apply ID --by NAME [--at T] [--note TEXT] record that a recommendation was applied
|
|
135
|
+
fleetops tune verify [ID] [--before 7d] [--after 7d] the metric before and after, a 95% interval, a verdict
|
|
136
|
+
fleetops tune list applied recommendations and their verdicts
|
|
137
|
+
fleetops tune holdout --from T --split T --to T recommend on [from, split), check on [split, to) that
|
|
138
|
+
the problem each names is still there (before changing anything)
|
|
139
|
+
|
|
140
|
+
Power (budgets per rack, PDU and site; which jobs a cap slows; caps planned and applied through approval):
|
|
141
|
+
fleetops power report --budgets b.json [--from T --to T] IT kW (p99, peak) per rack/PDU/row/site vs budget, headroom in nodes
|
|
142
|
+
fleetops power jobs each job's draw, how compute-bound it is, time at the limit, steps per kWh
|
|
143
|
+
fleetops power predict --cap 70% | --cap 500W [--job J] predicted slowdown and kW saved per job under a cap
|
|
144
|
+
fleetops power fit measure how clocks follow the power limit on your GPUs (α)
|
|
145
|
+
fleetops power plan --budgets b.json [--save-kw N] [--max-slowdown 0.05] [--protect training] --out plan.json
|
|
146
|
+
the caps that bring each group under budget at the least slowdown, queued for approval; then
|
|
147
|
+
fleetops optimize advance --plan plan.json (applies, bakes, rolls back on a guard breach)
|
|
148
|
+
fleetops power verify --plan plan.json measured kW saved and step slowdown against the prediction
|
|
149
|
+
fleetops power demo two racks, one over budget
|
|
150
|
+
|
|
151
|
+
Node admission and safe rollouts (a bad node or version stopped before it reaches a production job):
|
|
152
|
+
tools/admit-node.sh [--burn-in 6h] --out admit.jsonl on the node: versions, topology, DCGM diag, NCCL, SDC canary
|
|
153
|
+
fleetops data import admission admit.jsonl
|
|
154
|
+
fleetops admit pending new nodes, nodes back from quarantine or repair
|
|
155
|
+
fleetops admit check NODE [--policy p.json] [--record] pass / fail / missing per check → admit, reject or incomplete
|
|
156
|
+
fleetops admit apply NODE [--live] admit-node (needs approval) or reject-node (automatic), dry run unless --live
|
|
157
|
+
fleetops rollout plan --field driver --version V [--canary 2] [--waves 25%,100%] [--bake 6h] [--nodes REGEX] [--sku S]
|
|
158
|
+
[--apply "ansible-playbook driver.yml -l {node} -e v={version}"] [--rollback "…"] --out rollout.json
|
|
159
|
+
canary across racks, then waves, each queued for approval
|
|
160
|
+
fleetops rollout advance --plan rollout.json [--live] after each bake: new version vs old on failures, hard faults,
|
|
161
|
+
NCCL bandwidth, step compute in the same jobs, TTFT; a regression rolls the wave back and halts
|
|
162
|
+
fleetops rollout check --field driver --version V [--from T --to T] the same comparison, ad hoc
|
|
163
|
+
fleetops rollout status --plan rollout.json · fleetops rollout demo [--good]
|
|
164
|
+
|
|
165
|
+
Shadow upgrades (an infra change measured against the baseline at matched load before it ships; docs/SHADOW.md):
|
|
166
|
+
fleetops shadow plan --baseline-config b.json --candidate-config c.json [--trace FILE | --baseline SEL --from T --to T]
|
|
167
|
+
[--effect 0.03] [--rps R] --out plan.json predicted effect (Inference Sizer) and requests needed to see it
|
|
168
|
+
fleetops shadow replay --trace FILE|profile.json --baseline URL --candidate URL [--model M] [--speed 1] [--max-requests N]
|
|
169
|
+
[--duration S] [--max-isl N --max-osl N] [--max-inflight 64] [--api-key-env VAR] [--out results.jsonl] [--live]
|
|
170
|
+
the same requests to both endpoints at the same moments (dry run unless --live); results go to the store
|
|
171
|
+
fleetops shadow answers --baseline URL --candidate URL [--prompts FILE] [--model M] [--live] --out answers.json
|
|
172
|
+
greedy decoding on both: identical tokens, first divergence, log-probability drift
|
|
173
|
+
fleetops shadow compare --results FILE | --baseline SEL --candidate SEL [--from T --to T]
|
|
174
|
+
[--plan plan.json] [--answers answers.json] [--baseline-gpus N --baseline-rate R --candidate-gpus N --candidate-rate R]
|
|
175
|
+
[--baseline-nodes RE --candidate-nodes RE] [--gates gates.json] matched-load verdict: promote, roll back, extend
|
|
176
|
+
with --plan: a prediction off by more than 15% refits the candidate's sizer efficiencies into
|
|
177
|
+
<store>/calibration/sizer.json (--calibration F; --no-recalibrate to skip), which plan, inference-sizer --calibration
|
|
178
|
+
and harness-ledger economics --calibration read; a promoted change is recorded in <store>/shadow/promoted.jsonl
|
|
179
|
+
fleetops shadow baseline save --name NAME --select SEL [--from T --to T] · fleetops shadow baseline list
|
|
180
|
+
fleetops shadow watch --name NAME --select SEL [--from T --to T] drift of a service against its saved baseline
|
|
181
|
+
fleetops shadow demo a candidate that looks faster and isn't
|
|
182
|
+
SEL: field=value or field~regex, comma-separated (variant=candidate, replica~vllm-new, pool=chat)
|
|
183
|
+
From a canary's own metrics (vLLM in Prometheus: llm-d controlled deployments, Argo Rollouts, Flagger):
|
|
184
|
+
fleetops shadow prom --prom URL --baseline 'M' --candidate 'M' [--select 'M'] [--lookback 3600 | --from T --to T]
|
|
185
|
+
[--baseline-lookback S] [--step 60] [--prom-token-env VAR] [--save FILE] [--gates g.json]
|
|
186
|
+
| --file saved.json | --demo per-version windows judged at matched load (load per engine, prompt, cache)
|
|
187
|
+
fleetops shadow serve --prom URL [--select 'M' --baseline 'M' --candidate 'M'] [--lookback 900] [--baseline-lookback 21600]
|
|
188
|
+
[--port 9410] [--host H --tokens FILE | --no-auth] the judge for Argo Rollouts (POST /verdict) and Flagger
|
|
189
|
+
(POST /flagger/rollout, /flagger/confirm-promotion); deploy/shadow-gate/ has the manifests
|
|
190
|
+
M: Prometheus label matchers, e.g. llm_isvc_name="chat-v2" or rollouts_pod_template_hash="6b9f",namespace="llm"
|
|
191
|
+
An llm-d canary (two LLMInferenceServices in one routing group) stepped by the judge:
|
|
192
|
+
fleetops shadow canary start --name N --namespace NS --group G --baseline ISVC --candidate ISVC [--steps 1,5,25,50,100]
|
|
193
|
+
[--bake 600] [--live] the first weights (printed, or written with --live)
|
|
194
|
+
fleetops shadow canary advance --name N --prom URL | --judge URL [--live] rollback → weight 0 at once (with --live);
|
|
195
|
+
promote → the next step is queued for a person; it is written by the next advance --live after approval
|
|
196
|
+
fleetops shadow canary approve --name N --by NAME a person approves the queued step · canary status --name N
|
|
197
|
+
|
|
198
|
+
Serving (Inference Sizer both ways, and a one-command vLLM deployment on Kubernetes):
|
|
199
|
+
fleetops serving models | gpus the catalog (ids, sizes, Hugging Face repos; GPU types)
|
|
200
|
+
fleetops serving fit --gpu H100 --nodes 2 [--rate R] [--isl 2000 --osl 400] [--ttft 2 --tpot 0.05] [--rank largest|throughput]
|
|
201
|
+
which models fit on that hardware, and how much load each carries within the targets
|
|
202
|
+
fleetops serving capacity --model M --gpu G --nodes N | --gpus N [workload, targets]
|
|
203
|
+
the most a model carries on given hardware: req/s (production and edge), concurrency, longest prompt, layout
|
|
204
|
+
fleetops serving deploy --model M --gpu G (--nodes N | --gpus N | --rate R) [--name N] [--namespace serving]
|
|
205
|
+
[--hf-secret SECRET] [--cache-pvc PVC] [--image IMG] [--autoscale [--prometheus URL]] [--create-namespace]
|
|
206
|
+
[--from-pool P] [--out FILE] [--apply [--endpoint URL] [--wait 2400]] [--mode agg|disagg|auto]
|
|
207
|
+
--mode disagg (or auto, when the sizer finds it smaller): prefill and decode pools on llm-d (DisaggregatedSet,
|
|
208
|
+
NIXL KV transfer, the llm-d router chart); needs LeaderWorkerSet ≥ 0.11.1 and the InferencePool CRDs
|
|
209
|
+
plan → Deployment or LeaderWorkerSet + Service (+ KEDA) → preflight; with --apply: apply, wait, smoke test, and
|
|
210
|
+
register the pool for tune and the agent (<store>/serving/pools.json, targets.json). Without --apply: a dry run.
|
|
211
|
+
fleetops serving delete NAME [--namespace serving] [--apply]
|
|
212
|
+
|
|
213
|
+
Silent data corruption (GPUs that compute wrong answers without an error):
|
|
214
|
+
fleetops sdc [--from T] [--to T | --days 7] [--format md]
|
|
215
|
+
replicas that disagree, failed canaries and replays, the first rank to go non-finite, gradient outliers →
|
|
216
|
+
suspect GPUs, and for each job the checkpoint to resume from; run tools/sdc-canary.py on nodes to confirm
|
|
217
|
+
|
|
218
|
+
Live agent and dashboard (actions are dry runs unless --live AND the gpu-health policy has dryRun: false):
|
|
219
|
+
fleetops agent [--interval 30] [--window 3600] [--state DIR] [--config gpu-health.json] [--agent-config agent.json]
|
|
220
|
+
[--targets targets.json] [--prom URL [--loki URL]] [--page-to pagerduty|opsgenie|webhook --page-key K --page-url U]
|
|
221
|
+
[--live] [--once]
|
|
222
|
+
watch training and inference, diagnose what goes wrong, mitigate within the policy, verify, page when it can't
|
|
223
|
+
fleetops agent status | log [--limit 50] | pause --by NAME | resume --by NAME | approve ID --by NAME | reject ID --by NAME
|
|
224
|
+
fleetops serve --agent [agent options] ingest, run the agent in-process, and serve the dashboard at /live
|
|
225
|
+
(state defaults to <store>/agent; approving from the page needs a token with the approve role)
|
|
226
|
+
|
|
227
|
+
Fault injection on a TEST cluster (dry-run unless --live; every target must be in the --allow file):
|
|
228
|
+
fleetops inject list
|
|
229
|
+
fleetops inject FAULT --allow FILE [--for S] [--live] [--expect RULE] --param value … writes an injection label
|
|
230
|
+
|
|
231
|
+
Optimization with safe execution (rollback is automatic; applying a stage always needs approval):
|
|
232
|
+
fleetops optimize candidates [--from T] [--to T] [--price 4] [--max-attempts 2] [--graph G [--trace-pool P [--trace-from T --trace-to T]] [--target 0.99]] [--out cands.json]
|
|
233
|
+
candidate changes from gpu-health (right-size, scale-in, reclaim), rca (retry storms) and FleetScope (pool sizes)
|
|
234
|
+
fleetops optimize plan --candidates cands.json --out plan.json [--save-pct 20] [--baseline-weekly $] [--max-risk medium]
|
|
235
|
+
[--guards guards.json] [--deployments deploy.json] [--bake 1800] [--state DIR]
|
|
236
|
+
pick a set that meets the goal, stage it, and queue every stage for approval in gpu-health's queue
|
|
237
|
+
fleetops optimize advance --plan plan.json [--state DIR] [--config gpu-health.json] [--live]
|
|
238
|
+
check the last stage's SLO guard (regression → roll back, no approval needed), then run the next approved stage
|
|
239
|
+
fleetops optimize verify --plan plan.json [--days 7] before/after GPU-hours and guard breaches → an optimization record
|
|
240
|
+
Approve a stage with: gpu-health actions approve ID --by NAME --state DIR (DIR defaults to <store>/rollouts/state)
|
|
241
|
+
|
|
242
|
+
Times (T) are ISO dates or epoch seconds. Common: --store DIR (default ./fleet-data), --backend jsonl|parquet (new stores;
|
|
243
|
+
parquet needs \`npm install --no-save @duckdb/node-api@2.0.1-r.1\` in fleetops/), --json.`;
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
// fleetops CLI: incidents (see ../fleetops.mjs for the entry point and dispatch)
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import { whereFrom } from '../../src/store.mjs';
|
|
4
|
+
import * as Inc from '../../src/incidents.mjs';
|
|
5
|
+
import * as Pull from '../../src/pull.mjs';
|
|
6
|
+
import * as RCA from '../../src/rca.mjs';
|
|
7
|
+
import * as Detect from '../../src/detect.mjs';
|
|
8
|
+
import * as Bench from '../../src/bench.mjs';
|
|
9
|
+
import * as Inject from '../../src/inject.mjs';
|
|
10
|
+
import { J, OUT, say, read, time, fmt, hdrs, lokiQueries, dur } from './common.mjs';
|
|
11
|
+
import { HELP } from './help.mjs';
|
|
12
|
+
|
|
13
|
+
export async function rca(store, cmd, o) {
|
|
14
|
+
const show = list => {
|
|
15
|
+
if (J) { OUT.incidents = list; return; }
|
|
16
|
+
if (o.format === 'md') { console.log(list.map(d => RCA.markdown(d)).join('\n')); return; }
|
|
17
|
+
for (const d of list) {
|
|
18
|
+
say(`${d.id} [${d.confidence}]`);
|
|
19
|
+
d.hypotheses.slice(0, 3).forEach((h, i) => say(` ${i + 1}. ${h.title} (${h.rule}, ${h.score.toFixed(2)})`));
|
|
20
|
+
say(` ${d.narrative}`);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const weights = o.weights && o.weights !== true ? JSON.parse(read(o.weights)) : undefined;
|
|
24
|
+
if (cmd === 'detect') {
|
|
25
|
+
const from = time(o.from), to = time(o.to), targets = o.targets && o.targets !== true ? JSON.parse(read(o.targets)) : {};
|
|
26
|
+
const where = whereFrom(o.where);
|
|
27
|
+
let incs;
|
|
28
|
+
if (o.method === 'threshold') incs = [...RCA.detectJobFailureSpikes(store, { from, to, minFailures: o['min-failures'] ? +o['min-failures'] : 50, ratio: o.ratio ? +o.ratio : 4 }), ...RCA.detectServingRegressions(store, { from, to, targets })];
|
|
29
|
+
else incs = Detect.groupIncidents([...Detect.detectJobFailures(store, { from, to, binS: o.bin ? +o.bin : 600, minFailures: o['min-failures'] ? +o['min-failures'] : 20, where }), ...Detect.detectServing(store, { from, to, targets }), ...Detect.detectTraining(store, { from, to })], { gapS: o['group-gap'] ? +o['group-gap'] : 1800 });
|
|
30
|
+
if (!o.diagnose) {
|
|
31
|
+
if (J) { OUT.incidents = incs; return; }
|
|
32
|
+
for (const i of incs) say(`${i.id} ${i.symptom.startsWith('training') ? `${i.job || i.nodes.join(',')}${i.peak != null ? ` step ${i.peak.toFixed(3)} s vs ${i.baseline.toFixed(3)} s` : ''}` : i.failures != null ? `${i.failures} failures` : `${i.metric} peak ${i.peak.toFixed(3)}${i.limit ? ` > ${i.limit.toFixed(3)}` : i.baseline != null ? ` vs ${i.baseline.toFixed(3)}` : ''}`}${i.alarmAt ? `, alarm ${Math.round((i.alarmAt - i.from) / 60)} min after onset` : ''}, ${((i.to - i.from) / 3600).toFixed(1)} h${i.merged ? `, ${i.merged.length + 1} merged` : ''}${i.related ? `; related: ${i.related.join(', ')}` : ''}`);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const ds = incs.map(i => RCA.diagnose(store, i, { weights }));
|
|
36
|
+
store.append('incident', ds);
|
|
37
|
+
return show(ds);
|
|
38
|
+
}
|
|
39
|
+
if (cmd === 'diagnose') {
|
|
40
|
+
if (!o.symptom || !o.from || !o.to) throw new Error('--symptom job-failures|latency|device --from T --to T');
|
|
41
|
+
const inc = { symptom: o.symptom, from: time(o.from), to: time(o.to), pool: o.pool !== true ? o.pool : undefined, nodes: o.nodes && o.nodes !== true ? String(o.nodes).split(',') : undefined, metric: o.metric };
|
|
42
|
+
const d = RCA.diagnose(store, inc, { weights });
|
|
43
|
+
store.append('incident', [d]);
|
|
44
|
+
return show([d]);
|
|
45
|
+
}
|
|
46
|
+
if (cmd === 'eval') {
|
|
47
|
+
if (!o.labels || o.labels === true) throw new Error('--labels FILE');
|
|
48
|
+
const labeled = read(o.labels).split(/\r?\n/).filter(l => l.trim()).map(l => JSON.parse(l)).map(l => Object.assign(l, { incident: Object.assign({}, l.incident, { from: time(l.incident.from), to: time(l.incident.to) }) }));
|
|
49
|
+
const r = RCA.evaluate(store, labeled);
|
|
50
|
+
if (J) { OUT.evaluation = r; return; }
|
|
51
|
+
say(`${r.incidents} labeled incidents: top-1 ${(r.top1 * 100).toFixed(0)}%, top-3 ${(r.top3 * 100).toFixed(0)}%`);
|
|
52
|
+
for (const x of r.rows) say(` ${x.id}: labeled ${x.cause}, ranked ${x.rank ?? 'not found'} (${x.got.join(', ')})`);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (cmd === 'bench') return bench(store, o, weights);
|
|
56
|
+
throw new Error(`unknown: rca ${cmd}\n\n${HELP}`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// The root-cause benchmark: synthetic scenarios (default), injected faults (--injections), postmortem labels (--labels).
|
|
60
|
+
export async function bench(store, o, weights) {
|
|
61
|
+
const pct = v => (v == null ? '–' : `${(v * 100).toFixed(1)}%`);
|
|
62
|
+
const rows = [], parts = [];
|
|
63
|
+
const useSynth = !o.injections && !o.labels && !o['from-incidents'] || o.synthetic;
|
|
64
|
+
if (useSynth) { const r = Bench.run(Bench.generate({ perCause: o['per-cause'] ? +o['per-cause'] : 10, seed: o.seed ? +o.seed : 1, only: o.only && o.only !== true ? String(o.only).split(',') : undefined }), { weights }); rows.push(...r.rows); parts.push('synthetic'); }
|
|
65
|
+
let inj = null;
|
|
66
|
+
if (o.injections) { inj = Bench.evalInjections(store, { weights, from: time(o.from), to: time(o.to) }); rows.push(...inj.rows.filter(r => r.cause)); parts.push('injected'); }
|
|
67
|
+
if (o['from-incidents']) { rows.push(...Bench.evalLabels(store, Inc.labelsFromIncidents(store), { weights }).map(r => Object.assign(r, { source: 'incident', scenario: `confirmed: ${r.cause}` }))); parts.push('confirmed incidents'); }
|
|
68
|
+
if (o.labels && o.labels !== true) {
|
|
69
|
+
const labeled = read(o.labels).split(/\r?\n/).filter(l => l.trim()).map(l => JSON.parse(l)).map(l => Object.assign(l, { incident: Object.assign({}, l.incident, { from: time(l.incident.from), to: time(l.incident.to) }) }));
|
|
70
|
+
rows.push(...Bench.evalLabels(store, labeled, { weights })); parts.push('postmortem');
|
|
71
|
+
}
|
|
72
|
+
let sum = Bench.summarize(rows), fitted = null;
|
|
73
|
+
if (o.fit && o.fit !== true) {
|
|
74
|
+
// fit on half, report the other half; then fit on all for the file
|
|
75
|
+
const train = rows.filter((_, i) => i % 2 === 0), test = rows.filter((_, i) => i % 2 === 1);
|
|
76
|
+
const wHalf = Bench.fitWeights(train), testBefore = Bench.summarize(test), testAfter = Bench.applyWeights(test, wHalf);
|
|
77
|
+
const w = Bench.fitWeights(rows), perCause = {};
|
|
78
|
+
for (const r of rows) perCause[r.cause] = (perCause[r.cause] || 0) + 1;
|
|
79
|
+
const thin = Object.entries(perCause).filter(([, n]) => n < 5).map(([c]) => c);
|
|
80
|
+
fitted = { rules: w, fittedOn: { sources: parts, incidents: rows.length, perCause }, heldOut: { top1Before: testBefore.top1, top1After: testAfter.top1 },
|
|
81
|
+
warnings: [...(parts.every(p => p === 'synthetic') ? ['fitted on synthetic scenarios only: these weights learn the generator, not your fleet; fit on injected or postmortem labels before using them'] : []), ...(thin.length ? [`fewer than 5 labeled incidents for: ${thin.join(', ')}`] : [])] };
|
|
82
|
+
fs.writeFileSync(o.fit, JSON.stringify(fitted, null, 1));
|
|
83
|
+
}
|
|
84
|
+
if (J) { Object.assign(OUT, { benchmark: { sources: parts, top1: sum.top1, top3: sum.top3, lenientTop1: sum.lenientTop1, componentTop1: sum.componentTop1, byScenario: sum.byScenario, misses: sum.misses.map(m => ({ id: m.id, cause: m.cause, top: m.top, rank: m.rank })) }, injections: inj && { injections: inj.injections, detected: inj.detected, delayP50: inj.delayP50, delayP90: inj.delayP90, rows: inj.rows.map(({ hyps, ...r }) => r) }, fitted }); }
|
|
85
|
+
else {
|
|
86
|
+
say(`${sum.incidents} labeled incidents (${parts.join(' + ')}): top-1 ${pct(sum.top1)}, top-3 ${pct(sum.top3)}${sum.lenientTop1 !== sum.top1 ? `, top-1 counting equivalent causes ${pct(sum.lenientTop1)}` : ''}${sum.componentTop1 != null ? `, component named ${pct(sum.componentTop1)}` : ''}`);
|
|
87
|
+
for (const [k, b] of Object.entries(sum.byScenario)) say(` ${(b.top1 + '/' + b.n).padStart(7)} ${k}${b.top1 < b.n ? ` ranked first: ${Object.entries(b.tops).map(([r, n]) => `${r} ${n}`).join(', ')}` : ''}`);
|
|
88
|
+
if (inj) say(`injected faults: ${inj.injections}, detected ${pct(inj.detected)}, alarm after ${inj.delayP50 != null ? Math.round(inj.delayP50 / 60) : '–'} min (p50) / ${inj.delayP90 != null ? Math.round(inj.delayP90 / 60) : '–'} min (p90)`);
|
|
89
|
+
if (inj) for (const r of inj.rows) say(` ${r.id}: ${r.detected ? `detected after ${Math.round(r.delayS / 60)} min` : 'not detected'}; ${r.cause ? `expected ${r.cause}, ranked ${r.rank ?? 'not found'} (top: ${r.top || 'none'})` : `top: ${r.top || 'none'} (detection only)`}`);
|
|
90
|
+
if (fitted) { say(`weights written to ${o.fit}: ${Object.entries(fitted.rules).filter(([, v]) => v !== 1).map(([k, v]) => `${k} ×${v}`).join(', ') || 'all 1'}; held-out top-1 ${pct(fitted.heldOut.top1Before)} → ${pct(fitted.heldOut.top1After)}`); for (const w of fitted.warnings) say(` warning: ${w}`); }
|
|
91
|
+
}
|
|
92
|
+
const minT1 = o['min-top1'] ? +o['min-top1'] : null, minT3 = o['min-top3'] ? +o['min-top3'] : null;
|
|
93
|
+
if ((minT1 != null && sum.top1 < minT1) || (minT3 != null && sum.top3 < minT3)) { console.error(`below the bar: top-1 ${pct(sum.top1)} (min ${pct(minT1)}), top-3 ${pct(sum.top3)} (min ${pct(minT3)})`); process.exitCode = 5; }
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Pull a window from Prometheus and/or Loki into the store.
|
|
97
|
+
export async function pull(store, cmd, o) {
|
|
98
|
+
const from = time(o.from), to = time(o.to) ?? Math.floor(Date.now() / 1000);
|
|
99
|
+
if (from == null) throw new Error('pull needs --from (and --to, default now)');
|
|
100
|
+
const out = {};
|
|
101
|
+
if (o.prom && o.prom !== true) out.prometheus = await Pull.pullPrometheus(store, o.prom, { from, to, step: o.step ? +o.step : 60, headers: hdrs(o) });
|
|
102
|
+
if (o.loki && o.loki !== true) out.loki = await Pull.pullLoki(store, o.loki, lokiQueries(o), { from, to, headers: hdrs(o) });
|
|
103
|
+
if (!out.prometheus && !out.loki) throw new Error('pull --prom URL and/or --loki URL');
|
|
104
|
+
if (J) { OUT.pulled = out; return; }
|
|
105
|
+
if (out.prometheus) say(`Prometheus: ${out.prometheus.device} device samples, ${out.prometheus.serving} serving rows, ${out.prometheus.collective} NCCL collective rows (${out.prometheus.unmapped} unmapped series samples)`);
|
|
106
|
+
if (out.loki) say(`Loki: ${out.loki.lines} lines → ${out.loki.logs} classified log records (${out.loki.unmatched} not matched)`);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Backtest: pull each labeled incident's window from the fleet's own monitoring and score root-cause analysis on it.
|
|
110
|
+
export async function backtest(store, o) {
|
|
111
|
+
if (!o.labels || o.labels === true) throw new Error('backtest --labels postmortems.jsonl --prom URL [--loki URL]');
|
|
112
|
+
const labels = read(o.labels).split(/\r?\n/).filter(l => l.trim()).map(l => JSON.parse(l)).map(l => Object.assign(l, { incident: Object.assign({}, l.incident, { from: time(l.incident.from), to: time(l.incident.to) }) }));
|
|
113
|
+
const lookback = dur(o.lookback) ?? 26 * 3600, pulled = [];
|
|
114
|
+
for (const l of labels) {
|
|
115
|
+
const w = { from: l.incident.from - lookback, to: l.incident.to + 3600 }, got = { id: l.incident.id || `${l.cause}@${l.incident.from}` };
|
|
116
|
+
if (o.prom && o.prom !== true) got.prometheus = await Pull.pullPrometheus(store, o.prom, Object.assign({ step: o.step ? +o.step : 60, headers: hdrs(o) }, w));
|
|
117
|
+
if (o.loki && o.loki !== true) got.loki = await Pull.pullLoki(store, o.loki, lokiQueries(o), Object.assign({ headers: hdrs(o) }, w));
|
|
118
|
+
pulled.push(got);
|
|
119
|
+
if (!J) say(` pulled ${got.id}: ${got.prometheus ? `${got.prometheus.device} device, ${got.prometheus.serving} serving` : ''}${got.loki ? `, ${got.loki.logs} log records` : ''}`);
|
|
120
|
+
}
|
|
121
|
+
const weights = o.weights && o.weights !== true ? JSON.parse(read(o.weights)) : undefined;
|
|
122
|
+
const rows = Bench.evalLabels(store, labels, { weights }), sum = Bench.summarize(rows);
|
|
123
|
+
if (J) { Object.assign(OUT, { backtest: { incidents: rows.length, top1: sum.top1, top3: sum.top3, componentTop1: sum.componentTop1, rows: rows.map(({ hyps, ...r }) => Object.assign(r, { ranked: hyps.slice(0, 3) })) }, pulled }); return; }
|
|
124
|
+
const pc = v => (v == null ? '–' : `${(v * 100).toFixed(1)}%`);
|
|
125
|
+
say(`backtest on ${rows.length} confirmed incidents: top-1 ${pc(sum.top1)}, top-3 ${pc(sum.top3)}${sum.componentTop1 != null ? `, component ${pc(sum.componentTop1)}` : ''}`);
|
|
126
|
+
for (const r of rows) say(` ${r.rank === 1 ? 'ok ' : 'MISS'} ${r.id}: confirmed ${r.cause}${r.component ? ` (${r.component})` : ''}; ranked ${r.rank ?? 'not found'}${r.rank !== 1 ? `, top: ${r.top || 'none'} ${r.hyps[0] ? r.hyps[0].score.toFixed(2) : ''}` : ''}`);
|
|
127
|
+
if (sum.misses.length) say('A miss usually means a signal the store didn\'t get (no logs for that window, no topology) or a rule gap: check `fleetops data node` for the component and the window.');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Game day: run a plan of injections on a test cluster one after another, then score them.
|
|
131
|
+
export async function gameday(store, cmd, o) {
|
|
132
|
+
const planFile = cmd && cmd !== true ? cmd : o.plan;
|
|
133
|
+
if (!planFile) throw new Error('gameday PLAN.json --allow FILE [--live] [--cooldown 900] [--prom URL --loki URL]');
|
|
134
|
+
const plan = JSON.parse(read(planFile)), allow = Inject.loadAllow(o.allow && o.allow !== true ? o.allow : process.env.FLEETOPS_INJECT_ALLOW);
|
|
135
|
+
const steps = plan.steps || plan, cool = o.cooldown ? +o.cooldown : plan.cooldownS ?? 900, live = !!o.live;
|
|
136
|
+
const preps = steps.map(st => { const { fault, forS: _forS, ...params } = st; return { st, prep: Inject.prepare(fault, params, { allow }) }; }); // check every step before running any
|
|
137
|
+
const done = [];
|
|
138
|
+
for (const [i, { st, prep }] of preps.entries()) {
|
|
139
|
+
if (!J) say(`step ${i + 1}/${preps.length}: ${prep.fault} on ${prep.nodes.join(', ') || prep.params.release || prep.params.host} for ${st.forS || 300} s (expect ${prep.expect || 'detection only'})`);
|
|
140
|
+
const r = await Inject.run(prep, { live, forS: st.forS || 300, store, log: J ? () => {} : l => say(' ' + l.trim()) });
|
|
141
|
+
done.push(r);
|
|
142
|
+
if (live && i < preps.length - 1) { if (!J) say(` cooling down ${cool} s`); await new Promise(res => setTimeout(res, cool * 1000)); }
|
|
143
|
+
}
|
|
144
|
+
if (!live) { if (!J) say('dry run: nothing was run. Add --live on a test cluster.'); else OUT.gameday = { dryRun: true, steps: preps.length }; return; }
|
|
145
|
+
if (o.prom || o.loki) { const lo = Math.min(...done.map(d => d.from)) - 26 * 3600, hi = Math.max(...done.map(d => d.to || d.from)) + 3600; if (o.prom && o.prom !== true) await Pull.pullPrometheus(store, o.prom, { from: lo, to: hi, headers: hdrs(o) }); if (o.loki && o.loki !== true) await Pull.pullLoki(store, o.loki, lokiQueries(o), { from: lo, to: hi, headers: hdrs(o) }); }
|
|
146
|
+
const r = Bench.evalInjections(store, { from: Math.min(...done.map(d => d.from)) - 1, to: Math.max(...done.map(d => d.to || d.from)) + 1 });
|
|
147
|
+
if (J) { OUT.gameday = { injections: r.injections, detected: r.detected, delayP50: r.delayP50, delayP90: r.delayP90, top1: r.diagnosis.top1, rows: r.rows.map(({ hyps, ...x }) => x) }; return; }
|
|
148
|
+
say(`game day: ${r.injections} injections, detected ${(r.detected * 100).toFixed(0)}%, alarm after ${r.delayP50 != null ? Math.round(r.delayP50 / 60) : '–'} min (p50); diagnosis top-1 ${r.diagnosis.incidents ? (r.diagnosis.top1 * 100).toFixed(0) + '%' : '–'}`);
|
|
149
|
+
for (const x of r.rows) say(` ${x.id}: ${x.detected ? `detected after ${Math.round(x.delayS / 60)} min` : 'not detected'}; ${x.cause ? `expected ${x.cause}, ranked ${x.rank ?? 'not found'}` : `top ${x.top}`}`);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// The incident workflow: open from detection, lifecycle, paging, timeline, postmortem.
|
|
153
|
+
export async function incidents(store, cmd, rest, o) {
|
|
154
|
+
const opt = k => (o[k] && o[k] !== true ? o[k] : undefined), id = rest[0];
|
|
155
|
+
if (!cmd || cmd === 'list') {
|
|
156
|
+
const all = Inc.state(store).filter(s => !opt('status') || s.status === o.status);
|
|
157
|
+
if (J) { OUT.incidents = all.map(({ events, diagnosis, ...s }) => Object.assign(s, { top: diagnosis && diagnosis.hypotheses[0] && diagnosis.hypotheses[0].title })); return; }
|
|
158
|
+
for (const s of all) say(`${s.severity} ${s.status.padEnd(12)} ${s.id}${s.owner ? ` @${s.owner}` : ''}${s.cause ? ` cause: ${s.cause}` : s.diagnosis && s.diagnosis.hypotheses[0] ? ` likely: ${s.diagnosis.hypotheses[0].rule}` : ''}`);
|
|
159
|
+
if (!all.length) say('no incidents');
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (cmd === 'open') {
|
|
163
|
+
// detect in the window, diagnose each, open the new ones
|
|
164
|
+
const from = time(o.from), to = time(o.to), weights = opt('weights') ? JSON.parse(read(o.weights)) : undefined;
|
|
165
|
+
const incs = Detect.groupIncidents([...Detect.detectJobFailures(store, { from, to, binS: o.bin ? +o.bin : 600, minFailures: o['min-failures'] ? +o['min-failures'] : 20, where: whereFrom(o.where) }), ...Detect.detectServing(store, { from, to }), ...Detect.detectTraining(store, { from, to })]);
|
|
166
|
+
const opened = [];
|
|
167
|
+
for (const i of incs) { const d = RCA.diagnose(store, i, { weights }); if (!store.query('incident', { where: x => x.id === d.id }).length) store.append('incident', [d]); const e = Inc.open(store, d, { by: opt('by') || 'fleetops' }); if (e) opened.push(e); }
|
|
168
|
+
if (J) { OUT.opened = opened; return; }
|
|
169
|
+
say(`${incs.length} incident(s) detected, ${opened.length} new`); for (const e of opened) say(` ${e.severity} ${e.id} ${e.summary}`);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (!id) throw new Error(`incidents ${cmd} ID`);
|
|
173
|
+
if (['acknowledge', 'ack', 'mitigate', 'resolve', 'reopen', 'assign', 'severity', 'note'].includes(cmd)) {
|
|
174
|
+
const e = Inc.transition(store, id, cmd === 'ack' ? 'acknowledge' : cmd, { by: opt('by'), note: opt('note'), owner: opt('owner'), severity: opt('severity'), cause: opt('cause'), component: opt('component') });
|
|
175
|
+
if (J) { OUT.event = e; return; }
|
|
176
|
+
say(`${id}: ${e.event}${e.cause ? ` (confirmed cause ${e.cause}${e.component ? `, ${e.component}` : ''}: stored as a label for rca bench --from-incidents)` : ''}`);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (cmd === 'show') {
|
|
180
|
+
const s = Inc.state(store, id); if (!s) throw new Error(`no incident ${id}`);
|
|
181
|
+
if (J) { OUT.incident = s; return; }
|
|
182
|
+
say(`${s.id} ${s.severity} · ${s.status}${s.owner ? ` · @${s.owner}` : ''}${s.cause ? ` · cause ${s.cause}` : ''}`);
|
|
183
|
+
for (const e of s.events) say(` ${fmt(e.t)} ${e.event} by ${e.by}${e.note ? `: ${e.note}` : ''}`);
|
|
184
|
+
if (s.diagnosis) { say(' ranked causes:'); s.diagnosis.hypotheses.slice(0, 3).forEach((h, i) => say(` ${i + 1}. ${h.title} (${h.rule}, ${h.score.toFixed(2)})`)); }
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (cmd === 'timeline' || cmd === 'postmortem') {
|
|
188
|
+
const out = cmd === 'timeline' ? Inc.timelineHtml(store, id) : Inc.postmortem(store, id);
|
|
189
|
+
if (opt('out')) { fs.writeFileSync(o.out, out); say(`written to ${o.out}`); } else console.log(out);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
if (cmd === 'page') {
|
|
193
|
+
const provider = opt('to') || 'pagerduty', key = opt('key') || process.env[provider === 'opsgenie' ? 'OPSGENIE_API_KEY' : 'PAGERDUTY_ROUTING_KEY'];
|
|
194
|
+
const r = await Inc.page(store, id, provider, opt('action') || 'trigger', { live: !!o.live, key, url: opt('url'), by: opt('by') || 'fleetops' });
|
|
195
|
+
if (J) { OUT.page = r; return; }
|
|
196
|
+
if (r.dryRun) { say(`dry run (--live to send): POST ${r.request.url}`); say(JSON.stringify(Object.assign({}, r.request.body, r.request.body.routing_key ? { routing_key: '…' } : {}), null, 1)); }
|
|
197
|
+
else say(`${provider} ${o.action || 'trigger'}: HTTP ${r.status}${r.ok ? '' : ' (failed)'}`);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
throw new Error(`unknown: incidents ${cmd}`);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Fault injection on a test cluster (dry-run unless --live; targets must be in the --allow file).
|
|
204
|
+
export async function inject(store, cmd, o) {
|
|
205
|
+
if (!cmd || cmd === 'list') {
|
|
206
|
+
if (J) { OUT.faults = Object.fromEntries(Object.entries(Inject.FAULTS).map(([k, f]) => [k, { what: f.what, params: Object.keys(f.params), expect: f.expect, undo: !!f.revert, note: f.note }])); return; }
|
|
207
|
+
for (const [k, f] of Object.entries(Inject.FAULTS)) say(` ${k.padEnd(13)} ${f.what}\n --${Object.keys(f.params).join(' --')}${f.revert ? ' [--for S]' : ''} expect: ${f.expect || 'detection only'}${f.note ? `\n ${f.note}` : ''}`);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const allowFile = o.allow && o.allow !== true ? o.allow : process.env.FLEETOPS_INJECT_ALLOW;
|
|
211
|
+
if (!allowFile) throw new Error('--allow FILE (or FLEETOPS_INJECT_ALLOW): the test-cluster targets injection may touch, one per line');
|
|
212
|
+
const params = Object.fromEntries(Object.entries(o).filter(([k]) => !['_', 'where', 'store', 'allow', 'live', 'for', 'json'].includes(k)));
|
|
213
|
+
const prep = Inject.prepare(cmd, params, { allow: Inject.loadAllow(allowFile) });
|
|
214
|
+
const r = await Inject.run(prep, { live: !!o.live, forS: o.for ? +o.for : 300, store, log: J ? () => {} : console.log });
|
|
215
|
+
if (J) OUT.injection = r; else if (!r.dryRun) say(`${r.id}: ${r.applied ? 'applied' : 'FAILED to apply'}${r.reverted != null ? `, reverted ${r.reverted ? 'ok' : 'with errors'}` : ''}; label written to the store (expect ${r.expect || 'detection only'})`);
|
|
216
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// fleetops CLI: rollout (see ../fleetops.mjs for the entry point and dispatch)
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import * as Sec from '../../src/security.mjs';
|
|
5
|
+
import { postWebhook } from '../../../gpu-health/src/executors.mjs';
|
|
6
|
+
import { toFleetScopeTrace } from '../../src/export.mjs';
|
|
7
|
+
import * as Opt from '../../src/optimize.mjs';
|
|
8
|
+
import * as RO from '../../src/rollout.mjs';
|
|
9
|
+
import { loadConfig as ghConfig } from '../../../gpu-health/src/config.mjs';
|
|
10
|
+
import { FSIN, J, OUT, say, read, time, pc, money } from './common.mjs';
|
|
11
|
+
import { HELP } from './help.mjs';
|
|
12
|
+
import { baselineWeekly } from './capacity.mjs';
|
|
13
|
+
|
|
14
|
+
export async function rolloutCmd(store, cmd, o) {
|
|
15
|
+
const opt = k => (o[k] && o[k] !== true ? o[k] : undefined), now = o.now ? +o.now : Math.floor(Date.now() / 1000), json = k => (opt(k) ? JSON.parse(read(opt(k))) : undefined);
|
|
16
|
+
const state = opt('state') || path.join(store.dir, 'rollouts', 'state'), cfg = ghConfig(json('config'));
|
|
17
|
+
const hours = s => (s == null ? undefined : /h$/.test(s) ? parseFloat(s) * 3600 : /m$/.test(s) ? parseFloat(s) * 60 : +s);
|
|
18
|
+
if (cmd === 'demo') {
|
|
19
|
+
const d = RO.synth({ bad: !o.good }); for (const [k, rs] of Object.entries(d.records)) store.append(k, rs);
|
|
20
|
+
if (J) { OUT.demo = { canary: d.canary, canaryAt: d.canaryAt, end: d.end, old: d.old, new: d.neu, bad: !o.good }; return; }
|
|
21
|
+
return say(`demo fleet in ${store.dir}: 24 H100 nodes on driver ${d.old}; ${d.canary.join(' and ')} moved to ${d.neu} on ${new Date(d.canaryAt * 1000).toISOString().slice(0, 16)}${o.good ? '' : ' (a bad driver)'}\ntry: fleetops rollout check --field driver --version ${d.neu} --from ${d.canaryAt} --to ${d.end} --store ${store.dir}`);
|
|
22
|
+
}
|
|
23
|
+
if (cmd === 'check') {
|
|
24
|
+
if (!opt('field') || !opt('version')) throw new Error('--field driver --version V [--from T] [--to T]');
|
|
25
|
+
const to = time(opt('to')) ?? now, g = RO.compare(store, { field: opt('field'), version: opt('version'), since: time(opt('from')) ?? to - 7 * 86400, now: to, policy: json('policy') });
|
|
26
|
+
if (J) { OUT.comparison = g; if (g.ok === false) process.exitCode = 4; return; }
|
|
27
|
+
say(`${opt('field')} ${opt('version')} on ${(g.treated || []).length} node(s) vs ${g.control ?? 0} on other versions: ${g.ok === false ? 'REGRESSION' : g.ok ? 'no regression' : 'not enough data yet'}`);
|
|
28
|
+
for (const m of g.metrics) say(` ${m.regression ? 'WORSE' : 'ok '} ${m.name}: ×${m.ratio.toFixed(2)}${m.p != null ? ` (p ${m.p < 1e-4 ? '<1e-4' : m.p.toFixed(4)})` : ''} ${m.detail}`);
|
|
29
|
+
if (g.ok == null) say(` ${g.note}`);
|
|
30
|
+
if (g.ok === false) process.exitCode = 4;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (cmd === 'plan') {
|
|
34
|
+
if (!opt('out')) throw new Error('--out rollout.json');
|
|
35
|
+
const tmpl = k => (opt(k) ? [opt(k).split(' ').filter(Boolean)] : undefined); // "ansible-playbook driver.yml -l {node} -e v={version}"
|
|
36
|
+
const p = RO.plan(store, { field: opt('field'), version: opt('version'), nodes: opt('nodes'), sku: opt('sku'), canary: opt('canary') ?? 2, waves: opt('waves') ? opt('waves').split(',') : undefined, bakeS: hours(opt('bake')), apply: tmpl('apply'), rollback: tmpl('rollback'), id: opt('id'), now, policy: json('policy') });
|
|
37
|
+
p.state = state; const ids = RO.enqueue(p, state, now); fs.writeFileSync(opt('out'), JSON.stringify(p, null, 1));
|
|
38
|
+
if (J) { OUT.plan = p; OUT.queued = ids; return; }
|
|
39
|
+
say(`${p.id}: ${p.field} ${p.from} → ${p.version} on ${p.stages.reduce((a, s) => a + s.nodes.length, 0)} node(s), ${p.stages.length} wave(s), each queued for approval in ${state}:`);
|
|
40
|
+
for (const s of p.stages) say(` ${s.n}. ${s.title}: ${s.nodes.slice(0, 6).join(', ')}${s.nodes.length > 6 ? ` … +${s.nodes.length - 6}` : ''} (bake ${(s.bakeS / 3600).toFixed(1)} h)`);
|
|
41
|
+
return say(`then: gpu-health actions approve ${ids[0]} --by NAME --state ${state}; fleetops rollout advance --plan ${opt('out')}`);
|
|
42
|
+
}
|
|
43
|
+
const planFile = opt('plan'); if (!planFile) throw new Error('fleetops rollout demo | check | plan | advance --plan FILE | status --plan FILE');
|
|
44
|
+
const p = JSON.parse(read(planFile));
|
|
45
|
+
if (cmd === 'advance') {
|
|
46
|
+
const poster = (url, text) => { Sec.checkEgress(url); return postWebhook(url, text); };
|
|
47
|
+
const r = await RO.advance(p, { store, stateDir: opt('state') || p.state || state, cfg, live: !!o.live, now, poster });
|
|
48
|
+
fs.writeFileSync(planFile, JSON.stringify(p, null, 1));
|
|
49
|
+
if (J) { OUT.plan = p; OUT.log = r.log; return; }
|
|
50
|
+
for (const l of r.log) say(l); say(`${p.id}: ${p.status}`);
|
|
51
|
+
if (p.status === 'halted') process.exitCode = 4;
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (cmd === 'status') { if (J) { OUT.plan = p; return; } say(`${p.id}: ${p.status}${p.haltReason ? ` — ${p.haltReason}` : ''}`); for (const s of p.stages) say(` ${s.n}. ${s.status.padEnd(11)} ${s.title}${s.guardResult ? ` [${s.guardResult.note}]` : ''}`); return; }
|
|
55
|
+
throw new Error(`unknown: rollout ${cmd}`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export async function optimize(store, cmd, o) {
|
|
59
|
+
const opt = k => (o[k] && o[k] !== true ? o[k] : undefined), json = k => (opt(k) ? JSON.parse(read(opt(k))) : undefined);
|
|
60
|
+
const now = o.now ? +o.now : Math.floor(Date.now() / 1000), price = o.price ? +o.price : 4;
|
|
61
|
+
const state = opt('state') || path.join(store.dir, 'rollouts', 'state');
|
|
62
|
+
const cfg = ghConfig(json('config'));
|
|
63
|
+
if (cmd === 'candidates') {
|
|
64
|
+
const from = time(o.from), to = time(o.to);
|
|
65
|
+
const cands = [...Opt.fromGpuHealth(store, { from, to, cfg }), ...Opt.fromRetryStorms(store, { from, to, price, maxAttempts: o['max-attempts'] ? +o['max-attempts'] : 2 })];
|
|
66
|
+
if (opt('graph')) {
|
|
67
|
+
// the store's requests go through the same CSV and parser as FleetScope's own --trace option
|
|
68
|
+
const rows = opt('trace-pool') ? FSIN.parseTrace(toFleetScopeTrace(store, { pool: o['trace-pool'], from: time(o['trace-from']), to: time(o['trace-to']) })).trace : null;
|
|
69
|
+
if (rows && !rows.length) throw new Error(`no request records for pool ${o['trace-pool']}`);
|
|
70
|
+
if (rows) say(`replaying ${rows.length} requests of ${o['trace-pool']} through the graph`);
|
|
71
|
+
cands.push(...Opt.fromFleetScope(json('graph'), { target: o.target ? +o.target : 0.99, traceRows: rows }));
|
|
72
|
+
}
|
|
73
|
+
const out = { from, to, price, baselineWeekly: baselineWeekly(store, from, to, price), candidates: cands.map(c => Object.assign({}, c, { graph: undefined })) };
|
|
74
|
+
if (opt('out')) fs.writeFileSync(o.out, JSON.stringify(out, null, 1));
|
|
75
|
+
if (J) { Object.assign(OUT, out); return; }
|
|
76
|
+
say(`${cands.length} candidates (fleet ≈ ${money(out.baselineWeekly)}/week at $${price}/GPU-hour)`);
|
|
77
|
+
say(' savings/week risk SLO candidate');
|
|
78
|
+
for (const c of cands.slice().sort((a, b) => b.savingsWeekly - a.savingsWeekly)) say(` ${money(c.savingsWeekly).padStart(11)} ${c.risk.padEnd(6)} ${(c.protected ? 'PROTECTED' : c.slo.impact).padEnd(24)} ${c.title}${c.realized ? ` (${c.realized})` : ''}`);
|
|
79
|
+
if (opt('out')) say(`written to ${o.out}`);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (cmd === 'plan') {
|
|
83
|
+
const c = json('candidates'); if (!c || !opt('out')) throw new Error('--candidates FILE --out plan.json');
|
|
84
|
+
const sel = Opt.select(c.candidates, { savePct: o['save-pct'] ? +o['save-pct'] : undefined, baselineWeekly: o['baseline-weekly'] ? +o['baseline-weekly'] : c.baselineWeekly, maxRisk: opt('max-risk') || 'medium' });
|
|
85
|
+
const plan = Opt.planRollout(sel, { guards: json('guards') || {}, deployments: json('deployments') || {}, bakeS: o.bake ? +o.bake : 1800, cfg });
|
|
86
|
+
plan.goal = { savePct: o['save-pct'] ? +o['save-pct'] : null, baselineWeekly: sel.baselineWeekly, savedPct: sel.savedPct, meetsGoal: sel.meetsGoal }; plan.skipped = sel.skipped; plan.state = state;
|
|
87
|
+
const ids = Opt.enqueue(plan, state, now);
|
|
88
|
+
Opt.savePlan(o.out, plan);
|
|
89
|
+
if (J) { OUT.plan = plan; OUT.queued = ids; return; }
|
|
90
|
+
say(`plan ${plan.id}: ${money(plan.totalWeekly)}/week${plan.potentialWeekly > plan.totalWeekly ? ` firm, up to ${money(plan.potentialWeekly)} if notified owners act` : ''}${sel.savedPct != null ? ` (${(sel.savedPct * 100).toFixed(1)}% of ${money(sel.baselineWeekly)})` : ''}${plan.goal.savePct ? ` — goal ${plan.goal.savePct}% ${sel.meetsGoal ? 'met' : 'NOT met'}` : ''}`);
|
|
91
|
+
const many = plan.candidates.length > 8;
|
|
92
|
+
for (const x of many ? plan.candidates.slice(0, 6) : plan.candidates) say(` + ${x.title} ${money(x.savingsWeekly)}/week, risk ${x.risk}`);
|
|
93
|
+
if (many) say(` + … ${plan.candidates.length - 6} more`);
|
|
94
|
+
for (const x of sel.skipped.slice(0, 8)) say(` - ${x.id}: ${x.why}`);
|
|
95
|
+
if (sel.skipped.length > 8) say(` - … ${sel.skipped.length - 8} more skipped`);
|
|
96
|
+
say(`${plan.stages.length} stages queued for approval in ${state}:`);
|
|
97
|
+
plan.stages.forEach((st, i) => say(` ${st.n}. ${st.title}${st.guard ? ` [guard: pool ${st.guard.pool} ${st.guard.metric} ≤ ${st.guard.limit ?? `+${Math.round((st.guard.maxRegression ?? 0.1) * 100)}%`}, bake ${st.bakeS}s]` : ''}\n approve: gpu-health actions approve ${ids[i]} --by NAME --state ${state}`));
|
|
98
|
+
say(`then: fleetops optimize advance --plan ${o.out}`);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const planFile = opt('plan'); if (!planFile) throw new Error('--plan plan.json');
|
|
102
|
+
const plan = JSON.parse(read(planFile));
|
|
103
|
+
if (cmd === 'advance') {
|
|
104
|
+
const poster = (url, text) => { Sec.checkEgress(url); return postWebhook(url, text); }; // gpu-health's webhook (Lark-aware), behind the egress allowlist
|
|
105
|
+
const r = await Opt.advance(plan, { store, stateDir: opt('state') || plan.state || state, cfg, live: !!o.live, now, poster });
|
|
106
|
+
Opt.savePlan(planFile, plan);
|
|
107
|
+
if (J) { OUT.plan = plan; OUT.log = r.log; return; }
|
|
108
|
+
for (const l of r.log) say(l);
|
|
109
|
+
say(`plan ${plan.id}: ${plan.status}`);
|
|
110
|
+
if (plan.status === 'rolled-back') process.exitCode = 4;
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (cmd === 'verify') {
|
|
114
|
+
const v = Opt.verify(plan, store, { days: o.days ? +o.days : 7, now });
|
|
115
|
+
store.append('optimization', [Object.assign({ t: now, id: plan.id, status: plan.status, expectedWeekly: plan.totalWeekly }, v)]);
|
|
116
|
+
if (J) { OUT.verification = v; return; }
|
|
117
|
+
if (!v.window) return say(v.note);
|
|
118
|
+
say(`${plan.id}: allocated GPU-hours ${v.before.gpuHours.toFixed(0)} → ${v.after.gpuHours.toFixed(0)} (${pc(v.gpuHoursChange)}) over ${(v.window / 86400).toFixed(1)} days; guard breaches ${v.before.breaches} → ${v.after.breaches}: ${v.verified ? 'verified' : 'NOT verified'}`);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
throw new Error(`unknown: optimize ${cmd}\n\n${HELP}`);
|
|
122
|
+
}
|