@rocket.chat/houston 0.27.0-next.3 → 2.1.9
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/LICENSE +1 -1
- package/README.md +109 -15
- package/bin/houston +62 -0
- package/data/docs/ARCHITECTURE.md +387 -0
- package/data/docs/automation.md +107 -0
- package/data/docs/e2ee.md +76 -0
- package/data/docs/eks.md +258 -0
- package/data/docs/gui.md +282 -0
- package/data/docs/guide.md +642 -0
- package/data/docs/kubernetes.md +138 -0
- package/data/docs/loadtest.md +264 -0
- package/data/docs/troubleshooting.md +203 -0
- package/data/docs/upgrading.md +84 -0
- package/data/docs/voice.md +253 -0
- package/data/iam/engineer-policy.json +11 -0
- package/data/iam/engineer-rbac.yaml +42 -0
- package/data/iam/operator-policy.json +211 -0
- package/data/loadtest/badbot.js +22 -0
- package/data/loadtest/common.js +170 -0
- package/data/loadtest/custom.js +20 -0
- package/data/loadtest/journey.js +58 -0
- package/data/loadtest/login.js +18 -0
- package/data/loadtest/messages.js +13 -0
- package/data/loadtest/mixed.js +57 -0
- package/data/loadtest/read.js +12 -0
- package/data/loadtest/webhook.js +20 -0
- package/data/monitoring/houston-logs.json +98 -0
- package/data/monitoring/k6-loadtest.json +610 -0
- package/data/monitoring/mongodb-exporter.json +3007 -0
- package/data/monitoring/node-exporter-full.json +16114 -0
- package/data/monitoring/rocketchat-metrics.json +6471 -0
- package/data/presets/airgapped.yaml +16 -0
- package/data/presets/default.yaml +9 -0
- package/data/seed/avatar-0.png +0 -0
- package/data/seed/avatar-1.png +0 -0
- package/data/seed/avatar-2.png +0 -0
- package/data/seed/avatar-3.png +0 -0
- package/data/seed/avatar-4.png +0 -0
- package/data/seed/avatar-5.png +0 -0
- package/data/seed/avatar-6.png +0 -0
- package/data/seed/avatar-7.png +0 -0
- package/data/seed/seed-metrics.csv +3 -0
- package/data/seed/seed-preview.png +0 -0
- package/data/seed/seed-report.pdf +32 -0
- package/data/seed/seed-runbook.txt +3 -0
- package/data/skill/SKILL.md +399 -0
- package/data/versions.yaml +55 -0
- package/data/voice/freeswitch/drachtio.xml +52 -0
- package/data/voice/freeswitch/public.xml +87 -0
- package/data/webui/app.css +2003 -0
- package/data/webui/index.html +678 -0
- package/data/webui/js/api.js +561 -0
- package/data/webui/js/boot.js +44 -0
- package/data/webui/js/clusters-tail.js +1377 -0
- package/data/webui/js/clusters.js +896 -0
- package/data/webui/js/create.js +276 -0
- package/data/webui/js/detail.js +507 -0
- package/data/webui/js/jobs.js +636 -0
- package/data/webui/js/logs.js +634 -0
- package/data/webui/js/main.js +14 -0
- package/data/webui/js/options.js +408 -0
- package/data/webui/js/people.js +438 -0
- package/data/webui/js/perf.js +303 -0
- package/data/webui/js/render.js +438 -0
- package/data/webui/js/shared.js +3 -0
- package/data/webui/js/state.js +583 -0
- package/data/webui/js/theme.js +123 -0
- package/data/webui/js/util.js +584 -0
- package/dist/cli/app.js +593 -0
- package/dist/cli/capabilities.js +76 -0
- package/dist/cli/cell-widths.js +495 -0
- package/dist/cli/entry.js +10 -0
- package/dist/cli/error-panel.js +492 -0
- package/dist/cli/handlers/actor.js +84 -0
- package/dist/cli/handlers/https.js +614 -0
- package/dist/cli/handlers/prompt.js +299 -0
- package/dist/cli/handlers/users.js +226 -0
- package/dist/cli/handlers.js +3694 -0
- package/dist/cli/help.js +183 -0
- package/dist/cli/index.js +15 -0
- package/dist/cli/perf.js +814 -0
- package/dist/cli/render.js +254 -0
- package/dist/cli/serve.js +858 -0
- package/dist/cli/spec-data.js +2599 -0
- package/dist/cli/spec-types.js +8 -0
- package/dist/cli/usage-error.js +520 -0
- package/dist/cli/wire.js +70 -0
- package/dist/core/audit.js +346 -0
- package/dist/core/backup-compat.js +85 -0
- package/dist/core/backup.js +1639 -0
- package/dist/core/cluster.js +1398 -0
- package/dist/core/configimport.js +345 -0
- package/dist/core/data.js +267 -0
- package/dist/core/database-of.js +82 -0
- package/dist/core/diagnose.js +159 -0
- package/dist/core/doctor.js +1518 -0
- package/dist/core/edge/acme.js +338 -0
- package/dist/core/edge/engine.js +500 -0
- package/dist/core/edge/networks.js +174 -0
- package/dist/core/edge/paths.js +107 -0
- package/dist/core/edge/routes.js +251 -0
- package/dist/core/edge/routeyml.js +195 -0
- package/dist/core/edge/runtime.js +493 -0
- package/dist/core/edge/spec.js +305 -0
- package/dist/core/edge/types.js +202 -0
- package/dist/core/eks-docs.js +135 -0
- package/dist/core/eks.js +2240 -0
- package/dist/core/envvars.js +562 -0
- package/dist/core/eventlog.js +541 -0
- package/dist/core/firstrun.js +153 -0
- package/dist/core/journal.js +694 -0
- package/dist/core/kube/ask.js +231 -0
- package/dist/core/kube/capabilities.js +269 -0
- package/dist/core/kube/certmanager.js +452 -0
- package/dist/core/kube/chart.js +413 -0
- package/dist/core/kube/cluster.js +196 -0
- package/dist/core/kube/context.js +545 -0
- package/dist/core/kube/endpoints.js +448 -0
- package/dist/core/kube/exec.js +195 -0
- package/dist/core/kube/forward.js +732 -0
- package/dist/core/kube/grafana-ingress.js +110 -0
- package/dist/core/kube/ingress.js +218 -0
- package/dist/core/kube/manifests.js +361 -0
- package/dist/core/kube/monitoring.js +768 -0
- package/dist/core/kube/names.js +237 -0
- package/dist/core/kube/namespace.js +678 -0
- package/dist/core/kube/operator.js +941 -0
- package/dist/core/kube/probe.js +202 -0
- package/dist/core/kube/reachability.js +163 -0
- package/dist/core/kube/release.js +439 -0
- package/dist/core/kube/replicaset.js +180 -0
- package/dist/core/kube/scale.js +398 -0
- package/dist/core/kube/status.js +633 -0
- package/dist/core/kube/tools.js +238 -0
- package/dist/core/kube/transfer.js +173 -0
- package/dist/core/kube/workspace.js +423 -0
- package/dist/core/lifecycle/admin.js +64 -0
- package/dist/core/lifecycle/create-docker.js +1549 -0
- package/dist/core/lifecycle/create-k8s.js +960 -0
- package/dist/core/lifecycle/destroy.js +339 -0
- package/dist/core/lifecycle/inspect.js +636 -0
- package/dist/core/lifecycle/naming.js +298 -0
- package/dist/core/lifecycle/notes.js +862 -0
- package/dist/core/lifecycle/ownership.js +313 -0
- package/dist/core/lifecycle/payload.js +401 -0
- package/dist/core/lifecycle/ports.js +388 -0
- package/dist/core/lifecycle/preconditions.js +367 -0
- package/dist/core/lifecycle/pruning.js +551 -0
- package/dist/core/lifecycle/ready.js +818 -0
- package/dist/core/lifecycle/request.js +510 -0
- package/dist/core/lifecycle/seeding.js +281 -0
- package/dist/core/lifecycle/sizing.js +392 -0
- package/dist/core/lifecycle/state.js +286 -0
- package/dist/core/lifecycle/tlsplan.js +704 -0
- package/dist/core/lifecycle/types.js +232 -0
- package/dist/core/loadtest.js +1051 -0
- package/dist/core/migrate.js +612 -0
- package/dist/core/monitor.js +494 -0
- package/dist/core/postready.js +976 -0
- package/dist/core/promote.js +804 -0
- package/dist/core/rcapi.js +1336 -0
- package/dist/core/recovery.js +75 -0
- package/dist/core/runner/engine.js +394 -0
- package/dist/core/runner/host.js +298 -0
- package/dist/core/runner/locks.js +129 -0
- package/dist/core/runner/paths.js +173 -0
- package/dist/core/runner/ports.js +172 -0
- package/dist/core/runner/queries.js +612 -0
- package/dist/core/runner/record.js +563 -0
- package/dist/core/scaleseed.js +271 -0
- package/dist/core/seed-db.js +208 -0
- package/dist/core/sessions.js +472 -0
- package/dist/core/skill.js +326 -0
- package/dist/core/sso-identities.js +172 -0
- package/dist/core/sso.js +703 -0
- package/dist/core/tls-local.js +311 -0
- package/dist/core/tls.js +878 -0
- package/dist/core/topology.js +482 -0
- package/dist/core/upgrade.js +877 -0
- package/dist/core/users.js +739 -0
- package/dist/lib/audit.js +100 -0
- package/dist/lib/close-matches.js +238 -0
- package/dist/lib/compose.js +672 -0
- package/dist/lib/config.js +1398 -0
- package/dist/lib/context.js +18 -0
- package/dist/lib/errors.js +305 -0
- package/dist/lib/events.js +208 -0
- package/dist/lib/float-text.js +126 -0
- package/dist/lib/format.js +1320 -0
- package/dist/lib/home.js +325 -0
- package/dist/lib/journal.js +122 -0
- package/dist/lib/json-text.js +733 -0
- package/dist/lib/jsonout.js +382 -0
- package/dist/lib/lock.js +516 -0
- package/dist/lib/login-name.js +202 -0
- package/dist/lib/map-limit.js +29 -0
- package/dist/lib/mkdir-parents.js +90 -0
- package/dist/lib/mongo-kernel.js +67 -0
- package/dist/lib/monitoring.js +492 -0
- package/dist/lib/platform-name.js +59 -0
- package/dist/lib/presets/common.js +390 -0
- package/dist/lib/presets/composite.js +326 -0
- package/dist/lib/presets/e2ee.js +143 -0
- package/dist/lib/presets/email.js +172 -0
- package/dist/lib/presets/guides.js +27 -0
- package/dist/lib/presets/index.js +490 -0
- package/dist/lib/presets/keycloak.js +371 -0
- package/dist/lib/presets/ldap.js +1285 -0
- package/dist/lib/presets/livechat.js +220 -0
- package/dist/lib/presets/multi-instance.js +124 -0
- package/dist/lib/presets/oidc.js +161 -0
- package/dist/lib/presets/public.js +496 -0
- package/dist/lib/presets/registry.js +64 -0
- package/dist/lib/presets/s3-minio.js +300 -0
- package/dist/lib/presets/saml.js +149 -0
- package/dist/lib/presets/scenario.js +51 -0
- package/dist/lib/presets/types.js +86 -0
- package/dist/lib/presets/voice-pbx.js +320 -0
- package/dist/lib/presets/voice.js +345 -0
- package/dist/lib/presets/webhooks.js +182 -0
- package/dist/lib/redact.js +106 -0
- package/dist/lib/seed-options.js +68 -0
- package/dist/lib/seed-profiles.js +59 -0
- package/dist/lib/targz.js +1383 -0
- package/dist/lib/teammode.js +25 -0
- package/dist/lib/tempdir.js +162 -0
- package/dist/lib/unicode-tables.js +2335 -0
- package/dist/lib/version-spec.js +357 -0
- package/dist/lib/versions.js +463 -0
- package/dist/lib/yaml-dump.js +1361 -0
- package/dist/perf/baseline.js +168 -0
- package/dist/perf/constrain.js +299 -0
- package/dist/perf/k6.js +235 -0
- package/dist/perf/mongoprof.js +171 -0
- package/dist/perf/rcmetrics.js +191 -0
- package/dist/perf/report.js +386 -0
- package/dist/perf/resources.js +236 -0
- package/dist/perf/slo.js +111 -0
- package/dist/perf/timeline.js +187 -0
- package/dist/perf/timings.js +85 -0
- package/dist/perf/verdict.js +201 -0
- package/dist/seams/aws-cli.js +126 -0
- package/dist/seams/docker-cli.js +280 -0
- package/dist/seams/exec.js +861 -0
- package/dist/seams/fs/lock.js +528 -0
- package/dist/seams/kubectl.js +83 -0
- package/dist/seams/rc-http.js +921 -0
- package/dist/seed/apply.js +190 -0
- package/dist/seed/assets.js +76 -0
- package/dist/seed/check.js +391 -0
- package/dist/seed/client.js +172 -0
- package/dist/seed/executor.js +726 -0
- package/dist/seed/history.js +281 -0
- package/dist/seed/kinds.js +91 -0
- package/dist/seed/plan.js +432 -0
- package/dist/seed/receipt.js +339 -0
- package/dist/seed/repairs.js +75 -0
- package/dist/seed/verification.js +363 -0
- package/dist/seed/wording.js +248 -0
- package/dist/web/app.js +326 -0
- package/dist/web/jobs.js +510 -0
- package/dist/web/route-deps.js +211 -0
- package/dist/web/route-table.js +213 -0
- package/dist/web/routes/backup.js +244 -0
- package/dist/web/routes/clusters.js +303 -0
- package/dist/web/routes/data.js +187 -0
- package/dist/web/routes/edge.js +82 -0
- package/dist/web/routes/index.js +63 -0
- package/dist/web/routes/jobs.js +95 -0
- package/dist/web/routes/logs.js +297 -0
- package/dist/web/routes/meta.js +191 -0
- package/dist/web/routes/people.js +151 -0
- package/dist/web/routes/perf.js +95 -0
- package/dist/web/routes/repros.js +550 -0
- package/dist/web/routes/session.js +361 -0
- package/dist/web/routes/spa.js +198 -0
- package/dist/web/security.js +475 -0
- package/dist/web/signin.js +246 -0
- package/package.json +70 -32
- package/.eslintrc +0 -94
- package/.swcrc +0 -18
- package/dist/bin.js +0 -3
- package/dist/cli.js +0 -184
- package/dist/commands/createBranch.js +0 -194
- package/dist/outputCI.js +0 -59
- package/src/bin.js +0 -4
- package/src/cli.ts +0 -25
- package/src/commands/createBranch.ts +0 -28
- package/src/outputCI.ts +0 -12
- package/src-old/logs.js +0 -323
- package/src-old/md.js +0 -191
- package/src-old/release-table.js +0 -60
- package/src-old/set-version.js +0 -614
- package/src-old/utils.js +0 -15
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.prunable = prunable;
|
|
37
|
+
exports.orphanContext = orphanContext;
|
|
38
|
+
exports.reclaimCluster = reclaimCluster;
|
|
39
|
+
exports.orphanNamespaces = orphanNamespaces;
|
|
40
|
+
exports.sweepOrphanNamespaces = sweepOrphanNamespaces;
|
|
41
|
+
exports.pruneKubernetes = pruneKubernetes;
|
|
42
|
+
exports.removeOneWorkspace = removeOneWorkspace;
|
|
43
|
+
exports.removeEachWorkspace = removeEachWorkspace;
|
|
44
|
+
exports.prune = prune;
|
|
45
|
+
/**
|
|
46
|
+
* What is safe to remove in bulk, and removing it.
|
|
47
|
+
*
|
|
48
|
+
* Tier 4. `prunable` decides and `prune` acts, kept apart so the GUI can show what WOULD go
|
|
49
|
+
* before anything does.
|
|
50
|
+
*/
|
|
51
|
+
const fs = __importStar(require("node:fs"));
|
|
52
|
+
const config = __importStar(require("../../lib/config"));
|
|
53
|
+
const errors_1 = require("../../lib/errors");
|
|
54
|
+
const events_1 = require("../../lib/events");
|
|
55
|
+
const audit_1 = require("../audit");
|
|
56
|
+
const routes_1 = require("../edge/routes");
|
|
57
|
+
const networks_1 = require("../edge/networks");
|
|
58
|
+
const journal_1 = require("../journal");
|
|
59
|
+
const capabilities_1 = require("../kube/capabilities");
|
|
60
|
+
const cluster_1 = require("../kube/cluster");
|
|
61
|
+
const context_1 = require("../kube/context");
|
|
62
|
+
const names_1 = require("../kube/names");
|
|
63
|
+
const namespace_1 = require("../kube/namespace");
|
|
64
|
+
const operator_1 = require("../kube/operator");
|
|
65
|
+
const monitoring_1 = require("../kube/monitoring");
|
|
66
|
+
const status_1 = require("../kube/status");
|
|
67
|
+
const docker_cli_1 = require("../../seams/docker-cli");
|
|
68
|
+
const engine = __importStar(require("../runner/engine"));
|
|
69
|
+
const locks_1 = require("../runner/locks");
|
|
70
|
+
const paths = __importStar(require("../runner/paths"));
|
|
71
|
+
const record_1 = require("../runner/record");
|
|
72
|
+
const queries_1 = require("../runner/queries");
|
|
73
|
+
const topology = __importStar(require("../topology"));
|
|
74
|
+
const ownership = __importStar(require("./ownership"));
|
|
75
|
+
const preconditions = __importStar(require("./preconditions"));
|
|
76
|
+
const ready_1 = require("./ready");
|
|
77
|
+
const state_1 = require("./state");
|
|
78
|
+
function bag(value) {
|
|
79
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
80
|
+
? value
|
|
81
|
+
: {};
|
|
82
|
+
}
|
|
83
|
+
function isTruthy(value) {
|
|
84
|
+
if (value === null || value === undefined || value === false)
|
|
85
|
+
return false;
|
|
86
|
+
if (typeof value === 'string')
|
|
87
|
+
return value !== '';
|
|
88
|
+
if (typeof value === 'number')
|
|
89
|
+
return value !== 0;
|
|
90
|
+
if (Array.isArray(value))
|
|
91
|
+
return value.length > 0;
|
|
92
|
+
if (typeof value === 'object')
|
|
93
|
+
return Object.keys(value).length > 0;
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Names of repros that are safe to prune: not pinned and with no containers (a plain
|
|
98
|
+
* `down`). Raises DockerError if docker can't be queried -- deleting on that ambiguity
|
|
99
|
+
* would be destructive.
|
|
100
|
+
*
|
|
101
|
+
* DOCKER ONLY IF THERE IS A COMPOSE WORKSPACE TO ASK ABOUT. `requireDocker()` ran
|
|
102
|
+
* unconditionally at the top, so `prune` was refused outright on a host that uses only
|
|
103
|
+
* an adopted cluster and has no Docker at all -- while the loop below has asked
|
|
104
|
+
* Kubernetes about Kubernetes workspaces for a while. The gate contradicted the runtime
|
|
105
|
+
* it was gating.
|
|
106
|
+
*/
|
|
107
|
+
async function prunable() {
|
|
108
|
+
const me = (0, audit_1.actor)();
|
|
109
|
+
const candidates = [];
|
|
110
|
+
for (const meta of await (0, record_1.listMeta)()) {
|
|
111
|
+
if (await mayPrune(meta, me))
|
|
112
|
+
candidates.push(meta);
|
|
113
|
+
}
|
|
114
|
+
let states = null;
|
|
115
|
+
if (candidates.some((meta) => topology.ofMeta(meta) !== topology.KUBERNETES)) {
|
|
116
|
+
states = await composeStates();
|
|
117
|
+
}
|
|
118
|
+
const out = [];
|
|
119
|
+
for (const meta of candidates) {
|
|
120
|
+
if (await isDown(meta, states))
|
|
121
|
+
out.push(meta.name);
|
|
122
|
+
}
|
|
123
|
+
return out;
|
|
124
|
+
}
|
|
125
|
+
/** Not pinned, and `me` may destroy it. */
|
|
126
|
+
async function mayPrune(meta, me) {
|
|
127
|
+
// `pinned` by `isTruthy`: a hand-edited `"pinned": []` or `{}` is not a pin, and NaN is.
|
|
128
|
+
// JavaScript's truthiness kept the list and the mapping and pruned the NaN.
|
|
129
|
+
if (isTruthy(meta.pinned))
|
|
130
|
+
return false;
|
|
131
|
+
const [allowed] = await ownership.mayDestroy(meta.name, me);
|
|
132
|
+
return allowed;
|
|
133
|
+
}
|
|
134
|
+
/** Every compose project's state, or a refusal: prune deletes nothing on a guess. */
|
|
135
|
+
async function composeStates() {
|
|
136
|
+
await preconditions.requireDocker();
|
|
137
|
+
const states = await (0, queries_1.projectStates)();
|
|
138
|
+
if (states === null) {
|
|
139
|
+
throw new errors_1.DockerError("couldn't query docker compose projects - not pruning (is Docker healthy?)");
|
|
140
|
+
}
|
|
141
|
+
return states;
|
|
142
|
+
}
|
|
143
|
+
/** Whether the workspace is down; `states` is every compose project's, for a Compose one. */
|
|
144
|
+
async function isDown(meta, states) {
|
|
145
|
+
if (topology.ofMeta(meta) === topology.KUBERNETES) {
|
|
146
|
+
// NEVER, with Docker containers left under the record by 2.1.1: "down" was asked of the
|
|
147
|
+
// cluster alone, so their running containers lost their data. `down --volumes` takes both.
|
|
148
|
+
if ((0, state_1.hasComposeLeftovers)(meta.name))
|
|
149
|
+
return false;
|
|
150
|
+
// ASK KUBERNETES, not Docker. "Is it down" was decided by whether a compose PROJECT
|
|
151
|
+
// was running, and a Kubernetes workspace never has one -- so every Kubernetes
|
|
152
|
+
// workspace looked down, including a healthy one serving traffic.
|
|
153
|
+
const context = isTruthy(bag(meta.extra)[config.EXTRA_CONTEXT])
|
|
154
|
+
? String(bag(meta.extra)[config.EXTRA_CONTEXT])
|
|
155
|
+
: names_1.CONTEXT;
|
|
156
|
+
try {
|
|
157
|
+
return !(await (0, status_1.workloadExists)(meta.name, { context }));
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
if (!(error instanceof errors_1.DockerError))
|
|
161
|
+
throw error;
|
|
162
|
+
// NOT PRUNABLE, rather than "down". `workloadExists` refuses to guess when the
|
|
163
|
+
// cluster cannot be asked, and the safe reading of "I could not tell" is to leave
|
|
164
|
+
// the workspace alone -- this list is a delete list. Skipped rather than raised so
|
|
165
|
+
// one unreadable workspace does not stop the others being pruned.
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return states !== null && !Object.hasOwn(states, meta.project);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Whether `name` may still be pruned, asked again under its lock. The list was made before
|
|
173
|
+
* any lock was taken, and Kubernetes deletions take minutes each: a workspace pinned, started
|
|
174
|
+
* or handed over meanwhile was deleted with its data all the same.
|
|
175
|
+
*/
|
|
176
|
+
async function stillPrunable(name) {
|
|
177
|
+
let meta;
|
|
178
|
+
try {
|
|
179
|
+
meta = await (0, record_1.readMeta)(name);
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
return false; // gone already
|
|
183
|
+
}
|
|
184
|
+
if (!(await mayPrune(meta, (0, audit_1.actor)())))
|
|
185
|
+
return false;
|
|
186
|
+
// ASKED AFRESH: `compose ls` is cached for a moment, and the cached answer was the one the
|
|
187
|
+
// list was made from -- so a workspace another command had started meanwhile still read
|
|
188
|
+
// as down here, and lost its data to the `down -v` below.
|
|
189
|
+
(0, docker_cli_1.invalidateQueries)();
|
|
190
|
+
const states = topology.ofMeta(meta) === topology.KUBERNETES ? null : await composeStates();
|
|
191
|
+
return await isDown(meta, states);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Which cluster to look for orphaned namespaces in.
|
|
195
|
+
*
|
|
196
|
+
* `CONTEXT` was hardcoded here, which meant that on a box using a cluster houston did not
|
|
197
|
+
* create -- the whole point of the k3s path -- `prune --orphans` looked for strays in a
|
|
198
|
+
* kind cluster that may not even exist, and reported none.
|
|
199
|
+
*/
|
|
200
|
+
async function orphanContext() {
|
|
201
|
+
try {
|
|
202
|
+
return (await (0, context_1.planCluster)()).context;
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
// no cluster at all: nothing to sweep
|
|
206
|
+
return names_1.CONTEXT;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Give back houston's own cluster once nothing of ours is left in it.
|
|
211
|
+
*
|
|
212
|
+
* Only ever OUR cluster: `deleteCluster` takes no parameter, needs the `kind` binary, and
|
|
213
|
+
* refuses while any workspace namespace remains -- so a cluster somebody else supplied
|
|
214
|
+
* cannot be reached from here at all.
|
|
215
|
+
*
|
|
216
|
+
* Best-effort: a cluster that will not go is not a failed prune.
|
|
217
|
+
*/
|
|
218
|
+
async function reclaimCluster(emit = events_1.nullEmit) {
|
|
219
|
+
try {
|
|
220
|
+
return await (0, cluster_1.deleteCluster)({ emit });
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
if (error instanceof errors_1.ReproError) {
|
|
224
|
+
(0, events_1.warn)(emit, `the cluster was left alone: ${error.message}`, { phase: 'done' });
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
// never let cleanup fail a successful prune
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Namespaces labelled ours that NO local record can explain.
|
|
233
|
+
*
|
|
234
|
+
* A workspace whose `repro.json` is gone leaves its namespace, its pods and its
|
|
235
|
+
* PersistentVolumeClaim running with nothing able to remove them. One was found holding
|
|
236
|
+
* 8Gi and five CrashLoopBackOff pods with no way to reach it short of `kubectl delete
|
|
237
|
+
* namespace` by hand.
|
|
238
|
+
*
|
|
239
|
+
* Reported, never swept automatically. On a shared cluster an unrecorded namespace may be
|
|
240
|
+
* a COLLEAGUE's workspace created from their own home.
|
|
241
|
+
*/
|
|
242
|
+
/** The directory names under the repros directory: every workspace, whether or not it reads. */
|
|
243
|
+
function workspaceDirectories() {
|
|
244
|
+
try {
|
|
245
|
+
return fs
|
|
246
|
+
.readdirSync(config.reprosDir(), { withFileTypes: true })
|
|
247
|
+
.filter((entry) => entry.isDirectory())
|
|
248
|
+
.map((entry) => entry.name);
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
if (error.code === 'ENOENT')
|
|
252
|
+
return [];
|
|
253
|
+
throw error; // could not list them: sweeping nothing beats sweeping on a guess
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
async function orphanNamespaces(context = '') {
|
|
257
|
+
const ctx = context || (await orphanContext());
|
|
258
|
+
let found;
|
|
259
|
+
try {
|
|
260
|
+
found = await (0, capabilities_1.workspaceNamespaces)(ctx);
|
|
261
|
+
}
|
|
262
|
+
catch {
|
|
263
|
+
// no cluster is not an error here
|
|
264
|
+
return [];
|
|
265
|
+
}
|
|
266
|
+
if (found === null) {
|
|
267
|
+
// Could not ask. Sweeping nothing is the safe answer.
|
|
268
|
+
return [];
|
|
269
|
+
}
|
|
270
|
+
const known = new Set();
|
|
271
|
+
for (const meta of await (0, record_1.listMeta)())
|
|
272
|
+
known.add(await (0, namespace_1.namespaceFor)(meta.name));
|
|
273
|
+
// AND EVERY WORKSPACE DIRECTORY, its record readable or not. `listMeta` skips a record it
|
|
274
|
+
// cannot read, so a workspace whose repro.json was hand-edited into broken JSON read as a
|
|
275
|
+
// stray here -- marked as this home's and owned by its caller -- and `prune --orphans`
|
|
276
|
+
// deleted its namespace and PersistentVolumeClaim without --force.
|
|
277
|
+
for (const dir of workspaceDirectories())
|
|
278
|
+
known.add((0, names_1.mintNamespace)(dir));
|
|
279
|
+
return found.filter((ns) => !known.has(ns) && ns !== operator_1.OPERATOR_NAMESPACE).sort();
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Namespaces whose workspace record is gone. Separate from the workspaces themselves
|
|
283
|
+
* because one is removing what houston knows about and the other is removing what it has
|
|
284
|
+
* lost track of.
|
|
285
|
+
*/
|
|
286
|
+
async function sweepOrphanNamespaces(emit, force, stray) {
|
|
287
|
+
const swept = [];
|
|
288
|
+
// HOISTED, and that is the fix. The sweep below resolved the context properly and the
|
|
289
|
+
// wait further down used the hardcoded `CONTEXT` -- so on any cluster houston did not
|
|
290
|
+
// create the two disagreed and the wait read the failure as "gone".
|
|
291
|
+
const ctx = await orphanContext();
|
|
292
|
+
if (stray.length > 0) {
|
|
293
|
+
const me = (0, audit_1.actor)();
|
|
294
|
+
for (const ns of stray) {
|
|
295
|
+
// THE LABEL IS READ, and it is the only evidence there is. A stray is by definition
|
|
296
|
+
// a namespace no LOCAL record explains -- which on a shared cluster is exactly what
|
|
297
|
+
// a colleague's workspace looks like.
|
|
298
|
+
const owner = await (0, namespace_1.namespaceOwner)(ns, { context: ctx });
|
|
299
|
+
if (owner === null && !force) {
|
|
300
|
+
(0, events_1.warn)(emit, `cannot read who namespace ${ns} belongs to, so it is ` +
|
|
301
|
+
'left alone — `--force` sweeps it unread', { phase: 'done' });
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
// NO OWNER IS NOBODY'S, NOT YOURS. A namespace made with no accounts and no
|
|
305
|
+
// HOUSTON_USER carries an empty owner, and so does the caller in the same setup -- so
|
|
306
|
+
// '' matched '' and another home's LIVE workspace was swept, PVC and all, without
|
|
307
|
+
// --force. It cannot be attributed, which is what --force is for.
|
|
308
|
+
if (owner === '' && !force) {
|
|
309
|
+
(0, events_1.warn)(emit, `namespace ${ns} records no owner, so it may be another home's workspace — ` +
|
|
310
|
+
'left alone. `--force` sweeps it', { phase: 'done' });
|
|
311
|
+
continue;
|
|
312
|
+
}
|
|
313
|
+
if (owner !== null && owner !== '' && owner !== me && !force) {
|
|
314
|
+
(0, events_1.warn)(emit, `namespace ${ns} belongs to '${owner}', not to you — left ` +
|
|
315
|
+
`alone. Ask ${owner}, or \`--force\` to sweep it anyway`, { phase: 'done' });
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
// NOR IS YOUR NAME ON IT PROOF THAT THIS HOME MADE IT: a laptop and the server share
|
|
319
|
+
// an account name, and this swept the other home's live workspace, PVC and all.
|
|
320
|
+
if (!force && !(await (0, namespace_1.madeHere)(ns, { context: ctx }))) {
|
|
321
|
+
(0, events_1.warn)(emit, `namespace ${ns} is not marked as made by this houston home (or its mark could not ` +
|
|
322
|
+
"be read), so it may be another home's workspace — left alone. `--force` sweeps it", { phase: 'done' });
|
|
323
|
+
continue;
|
|
324
|
+
}
|
|
325
|
+
// BOUND TO WHAT WAS JUDGED: the same owner and this home's mark, on the one read the
|
|
326
|
+
// delete then names by UID, so a namespace made in its place since is not the one that goes.
|
|
327
|
+
let res;
|
|
328
|
+
try {
|
|
329
|
+
res = await (0, namespace_1.deleteStray)(ns, {
|
|
330
|
+
context: ctx,
|
|
331
|
+
stillStray: (labels) => force ||
|
|
332
|
+
((labels[names_1.OWNER_OF_LABEL] ?? '') === owner && labels[names_1.HOME_LABEL] === config.homeId()),
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
catch (error) {
|
|
336
|
+
res = { deleted: false, why: error instanceof Error ? error.message : String(error) };
|
|
337
|
+
}
|
|
338
|
+
if (res.deleted) {
|
|
339
|
+
swept.push(ns);
|
|
340
|
+
(0, events_1.info)(emit, `removed orphaned namespace ${ns}`, { phase: 'done' });
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
(0, events_1.warn)(emit, `could not remove orphaned namespace ${ns}: ${res.why.slice(0, 160)}`, {
|
|
344
|
+
phase: 'done',
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
// THE SWEEP USED `--wait=false`, AND THE RECLAIM RAN IMMEDIATELY AFTER. So
|
|
350
|
+
// `deleteCluster` refused -- correctly -- because the namespaces prune had just deleted
|
|
351
|
+
// were still Terminating, and reclaiming the cluster took a SECOND prune twenty seconds
|
|
352
|
+
// later.
|
|
353
|
+
if (swept.length > 0) {
|
|
354
|
+
for (const ns of swept) {
|
|
355
|
+
// SAID, when it does not go. The cluster reclaim below refuses while any workspace
|
|
356
|
+
// namespace remains, so dropping this answer turned the single-pass prune back into
|
|
357
|
+
// the two-run behaviour it was fixed for -- silently.
|
|
358
|
+
if (!(await (0, namespace_1.waitNamespaceGone)(ns, { context: ctx, emit }))) {
|
|
359
|
+
(0, events_1.warn)(emit, `namespace ${ns} is still terminating, so the cluster is ` +
|
|
360
|
+
'left alone this pass — `houston prune` again once ' +
|
|
361
|
+
'`kubectl get ns` is clear.', { phase: 'done' });
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return swept;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* The same dispatch `teardown` makes, for the same reason.
|
|
369
|
+
*
|
|
370
|
+
* `prune` called `docker compose down` on a workspace that has no compose project, which
|
|
371
|
+
* always failed -- so a Kubernetes workspace could be listed for pruning and never
|
|
372
|
+
* actually pruned, and its namespace and PersistentVolumeClaim stayed on the cluster.
|
|
373
|
+
*/
|
|
374
|
+
async function pruneKubernetes(name, emit, removed) {
|
|
375
|
+
const meta = await (0, record_1.readMeta)(name);
|
|
376
|
+
const extra = bag(meta.extra);
|
|
377
|
+
const context = isTruthy(extra[config.EXTRA_CONTEXT])
|
|
378
|
+
? String(extra[config.EXTRA_CONTEXT])
|
|
379
|
+
: names_1.CONTEXT;
|
|
380
|
+
const ns = await (0, namespace_1.namespaceFor)(name);
|
|
381
|
+
const forwards = bag(extra.scenario_forwards);
|
|
382
|
+
for (const uiPid of Object.values(forwards)) {
|
|
383
|
+
try {
|
|
384
|
+
await (0, ready_1.stopPortForward)(Number(uiPid), { namespace: ns });
|
|
385
|
+
}
|
|
386
|
+
catch {
|
|
387
|
+
// malformed recorded pid
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
const pid = extra.port_forward_pid;
|
|
391
|
+
if (isTruthy(pid))
|
|
392
|
+
await (0, ready_1.stopPortForward)(Number(pid), { namespace: ns });
|
|
393
|
+
// THE ANSWER IS READ, exactly as `teardown` reads it. This discarded it and then
|
|
394
|
+
// removed the local record and reported the workspace pruned regardless.
|
|
395
|
+
if (!(await (0, namespace_1.deleteNamespace)(name, { context, volumes: true, emit }))) {
|
|
396
|
+
(0, events_1.warn)(emit, `'${name}' was NOT pruned: its namespace is not ` +
|
|
397
|
+
'confirmed gone, so the record is kept. ' +
|
|
398
|
+
`\`kubectl get ns ${ns}\`, then prune again.`, { phase: 'done' });
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
// Same route the Kubernetes branch of `teardown` now drops, for the same reason: `prune`
|
|
402
|
+
// bypasses `teardown()` entirely, so it has to do this itself or the edge is left
|
|
403
|
+
// pointing at a namespace that no longer exists.
|
|
404
|
+
if (isTruthy(extra.tls))
|
|
405
|
+
await (0, monitoring_1.removeGrafanaIngress)(name, { context, emit });
|
|
406
|
+
const grafanaPid = extra.grafana_pid;
|
|
407
|
+
if (isTruthy(grafanaPid))
|
|
408
|
+
await (0, ready_1.stopPortForward)(Number(grafanaPid), { namespace: monitoring_1.MONITORING_NAMESPACE });
|
|
409
|
+
if (isTruthy(extra.monitoring))
|
|
410
|
+
await (0, monitoring_1.removeMonitoring)({ context, excluding: ns, emit });
|
|
411
|
+
(0, routes_1.deregister)(name);
|
|
412
|
+
await paths.remove(name);
|
|
413
|
+
// Its repair notes with it, as `teardown` does: see `journal.WORKSPACE_KINDS`.
|
|
414
|
+
(0, journal_1.clearWorkspace)(name);
|
|
415
|
+
await (0, state_1.clearDefaultIf)(name);
|
|
416
|
+
removed.push(name);
|
|
417
|
+
(0, events_1.info)(emit, `pruned '${name}'`, { phase: 'done' });
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* One workspace, and the reason a failure on it must not stop the rest.
|
|
421
|
+
*
|
|
422
|
+
* `prune` is a bulk operation somebody runs to reclaim a box, so a single workspace that
|
|
423
|
+
* will not come down has to be reported and stepped over -- stopping there would leave
|
|
424
|
+
* the rest of the list untouched.
|
|
425
|
+
*/
|
|
426
|
+
async function removeOneWorkspace(name, emit, removed) {
|
|
427
|
+
// THE CALLBACK'S `return` IS NOT THE FUNCTION'S. The removal returns from the FUNCTION
|
|
428
|
+
// on its Kubernetes branch, on a failed `down`, and on both caught errors; only the
|
|
429
|
+
// Compose success path falls through to clearing the default, `removed.push` and
|
|
430
|
+
// `pruned`. Written first as bare returns inside the `reproLock` callback, every path
|
|
431
|
+
// that did not throw still reported a prune -- one line after warning that the namespace
|
|
432
|
+
// is not confirmed gone and the record is being KEPT.
|
|
433
|
+
// `finished` says the locked block ran to its end, made explicit.
|
|
434
|
+
let finished;
|
|
435
|
+
try {
|
|
436
|
+
finished = await (0, locks_1.reproLock)(name, async () => {
|
|
437
|
+
if (!(await stillPrunable(name))) {
|
|
438
|
+
(0, events_1.warn)(emit, `'${name}' may no longer be pruned (pinned, started, handed over or gone since the list was made, or its cluster could not be asked) — left alone`, {
|
|
439
|
+
phase: 'done',
|
|
440
|
+
});
|
|
441
|
+
return false;
|
|
442
|
+
}
|
|
443
|
+
if ((await topology.ofRepro(name)) === topology.KUBERNETES) {
|
|
444
|
+
// `pruneKubernetes` does its own reporting: it knows whether the namespace is
|
|
445
|
+
// confirmed gone and says so on the path that keeps the record.
|
|
446
|
+
await pruneKubernetes(name, emit, removed);
|
|
447
|
+
return false;
|
|
448
|
+
}
|
|
449
|
+
// Close the backend's pooled edge connections before removing its endpoint,
|
|
450
|
+
// just as teardownCompose does. A failed stop must leave this project attached.
|
|
451
|
+
if ((await engine.stop(name)) !== 0) {
|
|
452
|
+
(0, events_1.warn)(emit, `could not stop '${name}' - skipping`, { phase: 'done' });
|
|
453
|
+
return false;
|
|
454
|
+
}
|
|
455
|
+
// Detach BEFORE `down`: compose cannot remove a network that still has an active
|
|
456
|
+
// endpoint, and the attached edge is one.
|
|
457
|
+
await (0, networks_1.detach)(name);
|
|
458
|
+
if ((await engine.down(name, { volumes: true })) !== 0) {
|
|
459
|
+
(0, events_1.warn)(emit, `could not clean up '${name}' - skipping`, { phase: 'done' });
|
|
460
|
+
return false;
|
|
461
|
+
}
|
|
462
|
+
// prune bypasses teardown(), so it drops the route itself or the edge is left
|
|
463
|
+
// pointing at nothing.
|
|
464
|
+
(0, routes_1.deregister)(name);
|
|
465
|
+
await paths.remove(name);
|
|
466
|
+
if (await paths.exists(name)) {
|
|
467
|
+
(0, events_1.warn)(emit, `'${name}''s containers and data volume are gone but its record could not be ` +
|
|
468
|
+
`removed: remove ${paths.workspace(name)} by hand`, { phase: 'done' });
|
|
469
|
+
}
|
|
470
|
+
// Under the lock, like the removal: see `journal.clearWorkspace`.
|
|
471
|
+
(0, journal_1.clearWorkspace)(name);
|
|
472
|
+
return true;
|
|
473
|
+
}, { timeoutMs: 5000 });
|
|
474
|
+
}
|
|
475
|
+
catch (error) {
|
|
476
|
+
if (error instanceof errors_1.ConflictError) {
|
|
477
|
+
(0, events_1.warn)(emit, `'${name}' is in use by another operation - skipping`, { phase: 'done' });
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
if (error instanceof errors_1.DockerError) {
|
|
481
|
+
// ONE UNREADABLE WORKSPACE MUST NOT END THE SWEEP. `deleteNamespace` raises
|
|
482
|
+
// DockerError when the cluster cannot be asked, and only ConflictError was caught --
|
|
483
|
+
// so the first unreadable workspace aborted prune entirely.
|
|
484
|
+
(0, events_1.warn)(emit, `'${name}' could not be removed (${error.message}) - skipping`, {
|
|
485
|
+
phase: 'done',
|
|
486
|
+
});
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
throw error;
|
|
490
|
+
}
|
|
491
|
+
if (!finished)
|
|
492
|
+
return;
|
|
493
|
+
await (0, state_1.clearDefaultIf)(name);
|
|
494
|
+
removed.push(name);
|
|
495
|
+
(0, events_1.info)(emit, `pruned '${name}'`, { phase: 'done' });
|
|
496
|
+
}
|
|
497
|
+
async function removeEachWorkspace(emit, removed, targets) {
|
|
498
|
+
for (const name of targets) {
|
|
499
|
+
await removeOneWorkspace(name, emit, removed);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Delete every `down` workspace. `only` narrows it to a list already shown.
|
|
504
|
+
*
|
|
505
|
+
* THE CONFIRMATION AND THE ACTION HAD DIFFERENT TARGET LISTS. `cli.prune` computed
|
|
506
|
+
* `prunable()` to print the prompt and this recomputed it after the answer, so on a
|
|
507
|
+
* shared box a workspace that went `down` while somebody read the prompt was deleted
|
|
508
|
+
* without ever appearing on screen.
|
|
509
|
+
*/
|
|
510
|
+
async function prune({ confirm = false, orphans = false, force = false, only = null, onlyStray = null, emit = events_1.nullEmit, } = {}) {
|
|
511
|
+
let targets = await prunable();
|
|
512
|
+
if (only !== null) {
|
|
513
|
+
const shown = new Set(only);
|
|
514
|
+
const appeared = targets.filter((target) => !shown.has(target));
|
|
515
|
+
targets = targets.filter((target) => shown.has(target));
|
|
516
|
+
for (const target of appeared) {
|
|
517
|
+
(0, events_1.warn)(emit, `'${target}' became prunable after the list was shown and is left ` +
|
|
518
|
+
'alone — run prune again to include it', { phase: 'done' });
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
let stray = orphans ? await orphanNamespaces() : [];
|
|
522
|
+
// As the workspaces are: what was shown and confirmed, and no namespace that turned up
|
|
523
|
+
// after the prompt -- under --force that one was swept without ever being on screen.
|
|
524
|
+
if (onlyStray !== null) {
|
|
525
|
+
const shown = new Set(onlyStray);
|
|
526
|
+
for (const ns of stray.filter((candidate) => !shown.has(candidate))) {
|
|
527
|
+
(0, events_1.warn)(emit, `namespace ${ns} turned up after the list was shown and is left alone`, {
|
|
528
|
+
phase: 'done',
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
stray = stray.filter((candidate) => shown.has(candidate));
|
|
532
|
+
}
|
|
533
|
+
if (targets.length === 0 && stray.length === 0) {
|
|
534
|
+
// Still worth asking about the CLUSTER. With every workspace gone, houston's own kind
|
|
535
|
+
// cluster is a 514 MiB control plane holding nothing -- and both the README and the
|
|
536
|
+
// agent skill said `prune` reclaims it, which nothing did.
|
|
537
|
+
return { targets: [], removed: [], orphans: [], cluster: await reclaimCluster(emit) };
|
|
538
|
+
}
|
|
539
|
+
if (!confirm) {
|
|
540
|
+
throw new errors_1.ValidationError(`prune deletes ${String(targets.length)} taken-down workspace(s) incl. data - pass confirm=true`);
|
|
541
|
+
}
|
|
542
|
+
// The NAMESPACES go in the subject too. Recording only `targets` meant a sweep that
|
|
543
|
+
// deleted three namespaces and no local records wrote `- prune - system ok`, with no
|
|
544
|
+
// trace anywhere of what it destroyed.
|
|
545
|
+
const subject = [...targets, ...stray.map((ns) => `ns:${ns}`)].join(',');
|
|
546
|
+
(0, audit_1.record)('prune', subject);
|
|
547
|
+
const removed = [];
|
|
548
|
+
await removeEachWorkspace(emit, removed, targets);
|
|
549
|
+
const swept = await sweepOrphanNamespaces(emit, force, stray);
|
|
550
|
+
return { targets, removed, orphans: swept, cluster: await reclaimCluster(emit) };
|
|
551
|
+
}
|