@rocket.chat/houston 0.27.0-next.3 → 2.1.8
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 +108 -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 +669 -0
- package/data/docs/kubernetes.md +138 -0
- package/data/docs/troubleshooting.md +193 -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 +168 -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 +39 -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 +3678 -0
- package/dist/cli/help.js +183 -0
- package/dist/cli/index.js +15 -0
- package/dist/cli/perf.js +810 -0
- package/dist/cli/render.js +254 -0
- package/dist/cli/serve.js +858 -0
- package/dist/cli/spec-data.js +2593 -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 +344 -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 +691 -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 +1533 -0
- package/dist/core/lifecycle/create-k8s.js +939 -0
- package/dist/core/lifecycle/destroy.js +339 -0
- package/dist/core/lifecycle/inspect.js +635 -0
- package/dist/core/lifecycle/naming.js +298 -0
- package/dist/core/lifecycle/notes.js +726 -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 +753 -0
- package/dist/core/lifecycle/request.js +525 -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 +995 -0
- package/dist/core/migrate.js +612 -0
- package/dist/core/monitor.js +494 -0
- package/dist/core/postready.js +969 -0
- package/dist/core/promote.js +804 -0
- package/dist/core/rcapi.js +1285 -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 +868 -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 +369 -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 +296 -0
- package/dist/perf/k6.js +235 -0
- package/dist/perf/mongoprof.js +171 -0
- package/dist/perf/rcmetrics.js +178 -0
- package/dist/perf/report.js +386 -0
- package/dist/perf/resources.js +224 -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 +67 -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,339 @@
|
|
|
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.removeTheClusterSide = removeTheClusterSide;
|
|
37
|
+
exports.stopTheForwards = stopTheForwards;
|
|
38
|
+
exports.dropTheEdgeRoute = dropTheEdgeRoute;
|
|
39
|
+
exports.teardownKubernetes = teardownKubernetes;
|
|
40
|
+
exports.teardownCompose = teardownCompose;
|
|
41
|
+
exports.teardown = teardown;
|
|
42
|
+
/**
|
|
43
|
+
* Removing a workspace: its containers or its namespace, and its record.
|
|
44
|
+
*
|
|
45
|
+
* Tier 4, and named `destroy` rather than `teardown` because the module also exports a
|
|
46
|
+
* function called `teardown`, and a module that shadows a symbol it has to export is
|
|
47
|
+
* unreachable from the façade the moment anything imports it.
|
|
48
|
+
*/
|
|
49
|
+
const fs = __importStar(require("node:fs/promises"));
|
|
50
|
+
const config = __importStar(require("../../lib/config"));
|
|
51
|
+
const errors_1 = require("../../lib/errors");
|
|
52
|
+
const format_1 = require("../../lib/format");
|
|
53
|
+
const events_1 = require("../../lib/events");
|
|
54
|
+
const audit_1 = require("../audit");
|
|
55
|
+
const networks_1 = require("../edge/networks");
|
|
56
|
+
const routes_1 = require("../edge/routes");
|
|
57
|
+
const journal_1 = require("../journal");
|
|
58
|
+
const namespace_1 = require("../kube/namespace");
|
|
59
|
+
const monitoring_1 = require("../kube/monitoring");
|
|
60
|
+
const operator_1 = require("../kube/operator");
|
|
61
|
+
const names_1 = require("../kube/names");
|
|
62
|
+
const engine = __importStar(require("../runner/engine"));
|
|
63
|
+
const locks_1 = require("../runner/locks");
|
|
64
|
+
const paths = __importStar(require("../runner/paths"));
|
|
65
|
+
const record_1 = require("../runner/record");
|
|
66
|
+
const topology = __importStar(require("../topology"));
|
|
67
|
+
const naming = __importStar(require("./naming"));
|
|
68
|
+
const ownership = __importStar(require("./ownership"));
|
|
69
|
+
const preconditions = __importStar(require("./preconditions"));
|
|
70
|
+
const ready_1 = require("./ready");
|
|
71
|
+
const state_1 = require("./state");
|
|
72
|
+
const types_1 = require("./types");
|
|
73
|
+
function bag(value) {
|
|
74
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
75
|
+
? value
|
|
76
|
+
: {};
|
|
77
|
+
}
|
|
78
|
+
function isTruthy(value) {
|
|
79
|
+
if (value === null || value === undefined || value === false)
|
|
80
|
+
return false;
|
|
81
|
+
if (typeof value === 'string')
|
|
82
|
+
return value !== '';
|
|
83
|
+
if (typeof value === 'number')
|
|
84
|
+
return value !== 0;
|
|
85
|
+
if (Array.isArray(value))
|
|
86
|
+
return value.length > 0;
|
|
87
|
+
if (typeof value === 'object')
|
|
88
|
+
return Object.keys(value).length > 0;
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Everything the namespace held that outlives it: the chart release, the operator, and
|
|
93
|
+
* the cluster itself when houston made it.
|
|
94
|
+
*/
|
|
95
|
+
async function removeTheClusterSide(context, emit, meta, target, volumes) {
|
|
96
|
+
if (!volumes)
|
|
97
|
+
return;
|
|
98
|
+
// Its namespace is gone by now, so a Grafana route that cannot be removed -- its cluster
|
|
99
|
+
// deleted outside houston -- is said, and does not keep a record whose data is gone from
|
|
100
|
+
// ever being removed.
|
|
101
|
+
if (isTruthy(bag(meta.extra).tls)) {
|
|
102
|
+
try {
|
|
103
|
+
await (0, monitoring_1.removeGrafanaIngress)(target, { context, emit });
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
(0, events_1.warn)(emit, `could not remove '${target}''s Grafana route from cluster '${context}' ` +
|
|
107
|
+
`(${error instanceof Error ? error.message : String(error)}) — if the cluster is still ` +
|
|
108
|
+
'there, remove it with `kubectl -n houston-system delete ingress -l ' +
|
|
109
|
+
`houston.io/workspace=${target}\``, { phase: 'teardown' });
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// AFTER the namespace, never before: deleting it took this workspace's
|
|
113
|
+
// MongoDBCommunity with it while the operator was still there to clear the finalizer.
|
|
114
|
+
const ns = await (0, namespace_1.namespaceFor)(target);
|
|
115
|
+
// RETURN DELIBERATELY NOT READ, and this is the one place on this path where that is
|
|
116
|
+
// right. `removeOperator` returns false for THREE reasons -- not installed, still wanted
|
|
117
|
+
// by another workspace, and a failed uninstall -- and the first two are the normal
|
|
118
|
+
// outcome of a shared resource being shared.
|
|
119
|
+
await (0, operator_1.removeOperator)({ context, excluding: ns, emit });
|
|
120
|
+
// AND the monitoring stack, which had the same hole and is far more expensive: ten pods
|
|
121
|
+
// and ~840 MB left running after the workspace that asked for them was destroyed.
|
|
122
|
+
// And its namespace, when the operator was the last thing in it. Not again after
|
|
123
|
+
// `removeMonitoring` removed the stack: it released the namespace itself, and a second ask
|
|
124
|
+
// found it Terminating and said "removed" twice.
|
|
125
|
+
if (!(await (0, monitoring_1.removeMonitoring)({ context, excluding: ns, emit }))) {
|
|
126
|
+
await (0, monitoring_1.releaseSystemNamespace)(context, emit);
|
|
127
|
+
}
|
|
128
|
+
// CHECKED, not assumed. Ignoring errors means a record that could not be removed -- a
|
|
129
|
+
// permission problem, a file held open -- is silently left behind, and the success line
|
|
130
|
+
// then says "and the local record".
|
|
131
|
+
//
|
|
132
|
+
// SWALLOWED, because the removal forgives EVERY failure, not just a missing
|
|
133
|
+
// directory: `force: true` forgives ENOENT alone, and a rejection from a container's
|
|
134
|
+
// root-owned file (EACCES) or a held-open one (EBUSY) made the warning below, the
|
|
135
|
+
// default clear and `dropTheEdgeRoute` unreachable -- leaving the edge registered for a
|
|
136
|
+
// namespace that is gone, which is what `dropTheEdgeRoute` exists to prevent.
|
|
137
|
+
try {
|
|
138
|
+
await fs.rm(paths.workspace(target), { recursive: true, force: true });
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
// reported by the `exists` check and the warning below
|
|
142
|
+
}
|
|
143
|
+
if (await paths.exists(target)) {
|
|
144
|
+
(0, events_1.warn)(emit, `the namespace is gone but ${paths.workspace(target)} ` +
|
|
145
|
+
`could not be removed, so \`list\` will still show ` +
|
|
146
|
+
`'${target}'. Remove that directory by hand.`, { phase: 'teardown' });
|
|
147
|
+
}
|
|
148
|
+
// Its repair notes go too, whether or not the directory did: what they repair went with
|
|
149
|
+
// the namespace, and a record removed by hand would strand them.
|
|
150
|
+
(0, journal_1.clearWorkspace)(target);
|
|
151
|
+
await (0, state_1.clearDefaultIf)(target);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* The port-forwards this workspace was published on. They outlive the namespace because
|
|
155
|
+
* they are processes on THIS box, not cluster objects.
|
|
156
|
+
*/
|
|
157
|
+
async function stopTheForwards(meta, target) {
|
|
158
|
+
const extra = bag(meta.extra);
|
|
159
|
+
const ns = isTruthy(extra.namespace) ? String(extra.namespace) : await (0, namespace_1.namespaceFor)(target);
|
|
160
|
+
const pid = extra.port_forward_pid;
|
|
161
|
+
if (isTruthy(pid)) {
|
|
162
|
+
await (0, ready_1.stopPortForward)(Number(pid), { namespace: ns });
|
|
163
|
+
}
|
|
164
|
+
// The GRAFANA forward, which `monitor --off` stops and `down --volumes` did. It targets a
|
|
165
|
+
// deployment in `houston-system`, so unlike the workspace's own forward it survives the
|
|
166
|
+
// workspace -- it held :5050 after the workspace was destroyed -- and a PLAIN `down`
|
|
167
|
+
// left it running: the re-up's record no longer named it, so nothing ever stopped it.
|
|
168
|
+
const gpid = extra.grafana_pid;
|
|
169
|
+
if (isTruthy(gpid)) {
|
|
170
|
+
await (0, ready_1.stopPortForward)(Number(gpid), { namespace: monitoring_1.MONITORING_NAMESPACE });
|
|
171
|
+
}
|
|
172
|
+
// A preset's UI forwards too, or `down` leaves 8082 bound to a namespace that no longer
|
|
173
|
+
// exists -- and the NEXT workspace using that preset finds the port taken by a corpse.
|
|
174
|
+
const forwards = bag(extra.scenario_forwards);
|
|
175
|
+
for (const uiPid of Object.values(forwards)) {
|
|
176
|
+
try {
|
|
177
|
+
await (0, ready_1.stopPortForward)(Number(uiPid), { namespace: ns });
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
// A malformed recorded pid: nothing to stop.
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* A route left behind points at something that is gone, so the hostname 502s instead of
|
|
186
|
+
* 404ing and nobody can reuse the name. After the cluster work, because a teardown that
|
|
187
|
+
* could not confirm the namespace is gone has not torn the workspace down.
|
|
188
|
+
*/
|
|
189
|
+
async function dropTheEdgeRoute(emit, target, volumes) {
|
|
190
|
+
// No `detach`: that disconnects a Docker network a Kubernetes workspace does not have.
|
|
191
|
+
// Deregistering is the whole of it.
|
|
192
|
+
(0, routes_1.deregister)(target);
|
|
193
|
+
const ns = await (0, namespace_1.namespaceFor)(target);
|
|
194
|
+
// Docker's nouns are wrong here. "containers, data volume, and record" for a workspace
|
|
195
|
+
// that has a namespace and a PVC says nothing about what actually went away -- and
|
|
196
|
+
// `helm uninstall` does NOT delete a PVC.
|
|
197
|
+
if (volumes) {
|
|
198
|
+
(0, events_1.info)(emit, `'${target}' removed — namespace ${ns}, its ` + 'PersistentVolumeClaim and the local record', { phase: 'done' });
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
(0, events_1.info)(emit, `'${target}' down — the ${names_1.RELEASE} release is ` +
|
|
202
|
+
`uninstalled; namespace ${ns} ` +
|
|
203
|
+
'and its PersistentVolumeClaim are KEPT, so `up` again ' +
|
|
204
|
+
'reuses the data. `down --volumes` deletes it.', { phase: 'done' });
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/** Remove the namespace, or just stop what is in it. */
|
|
208
|
+
async function teardownKubernetes(target, volumes, emit) {
|
|
209
|
+
// Deliberately BELOW the confirmation, the ownership gate and the audit record: all
|
|
210
|
+
// three are about whose data is being destroyed, which does not depend on the runtime.
|
|
211
|
+
// SAID FIRST: the namespace's identity is asked before anything is reported, and the
|
|
212
|
+
// whole teardown was measured at 48-61 s.
|
|
213
|
+
(0, events_1.info)(emit, `removing '${target}' from its cluster, which can take a minute`, {
|
|
214
|
+
phase: 'teardown',
|
|
215
|
+
});
|
|
216
|
+
const meta = await (0, record_1.readMeta)(target);
|
|
217
|
+
const extra = bag(meta.extra);
|
|
218
|
+
const context = isTruthy(extra[config.EXTRA_CONTEXT])
|
|
219
|
+
? String(extra[config.EXTRA_CONTEXT])
|
|
220
|
+
: names_1.CONTEXT;
|
|
221
|
+
await stopTheForwards(meta, target);
|
|
222
|
+
const found = await (0, namespace_1.deleteNamespace)(target, { context, volumes, emit });
|
|
223
|
+
// BRANCHED ON, at last. This value was returned to the caller as `{"found": ...}` and
|
|
224
|
+
// read by nobody -- so `--volumes` deleted the local record, the shared operator and
|
|
225
|
+
// the monitoring stack whatever it said.
|
|
226
|
+
if (volumes && !found) {
|
|
227
|
+
(0, events_1.warn)(emit, `'${target}': the namespace is not confirmed gone, so the ` +
|
|
228
|
+
'local record is KEPT. Nothing else was removed -- the ' +
|
|
229
|
+
'operator and any monitoring stack are untouched. Re-run ' +
|
|
230
|
+
`\`houston down --name ${target} --volumes\` once ` +
|
|
231
|
+
`\`kubectl get ns ${await (0, namespace_1.namespaceFor)(target)}\` says it is ` +
|
|
232
|
+
'absent.', { phase: 'teardown' });
|
|
233
|
+
return { name: target, removed: false, found, runtime: topology.KUBERNETES, context };
|
|
234
|
+
}
|
|
235
|
+
await removeTheClusterSide(context, emit, meta, target, volumes);
|
|
236
|
+
await dropTheEdgeRoute(emit, target, volumes);
|
|
237
|
+
// ON PURPOSE (`uninstallWorkspaceWorkloads` keeps a preset's Services stable for the re-up),
|
|
238
|
+
// but unsaid: after a plain `down` the preset's pods ran on while `list` said "down".
|
|
239
|
+
// `teardown`, not `done`: the CLI prints no informational `done` line. Only a preset that
|
|
240
|
+
// runs services, which is one that publishes a console (e2ee is settings and users only).
|
|
241
|
+
const services = Array.isArray(extra.sidecar_ports) && extra.sidecar_ports.length > 0;
|
|
242
|
+
if (!volumes && services && (meta.preset || 'default') !== 'default') {
|
|
243
|
+
(0, events_1.info)(emit, `its ${meta.preset} services keep running in ${await (0, namespace_1.namespaceFor)(target)} until ` +
|
|
244
|
+
'`down --volumes`', { phase: 'teardown' });
|
|
245
|
+
}
|
|
246
|
+
// `context` rides along so the CLI can say what a kept disk costs on a cloud cluster.
|
|
247
|
+
return { name: target, removed: volumes, found, runtime: topology.KUBERNETES, context };
|
|
248
|
+
}
|
|
249
|
+
/** Stop the project, detach from the edge, bring it down, and forget the name. */
|
|
250
|
+
async function teardownCompose(target, volumes, emit = events_1.nullEmit, streamOutput = false) {
|
|
251
|
+
// docker's own lines, streamed into a GUI job; the terminal keeps docker's output.
|
|
252
|
+
const echo = (line) => (0, events_1.info)(emit, line, { phase: 'teardown', data: { echo: 'docker' } });
|
|
253
|
+
// Stop while the edge is still attached, so its pooled upstream connections receive
|
|
254
|
+
// the backend's close. Disconnecting first strands those sockets on Podman; when a
|
|
255
|
+
// kept workspace gets a new network/IP, the first HTTPS request can reuse one and hang.
|
|
256
|
+
// Each slow step SAID before it runs: a `down` emitted nothing until its final line, so the
|
|
257
|
+
// GUI's job dialog stayed empty through the whole stop and removal (12 s on a voice lab).
|
|
258
|
+
(0, events_1.info)(emit, `stopping '${target}': each service closes cleanly first, which can take several seconds`, { phase: 'teardown' });
|
|
259
|
+
if ((await (streamOutput ? engine.stop(target, echo) : engine.stop(target))) !== 0) {
|
|
260
|
+
throw new errors_1.DockerError(`\`docker compose stop\` failed for '${target}'`);
|
|
261
|
+
}
|
|
262
|
+
// BEFORE `down`, not after: compose cannot remove a network that still has an active
|
|
263
|
+
// endpoint, and the edge attached to it is exactly that.
|
|
264
|
+
await (0, networks_1.detach)(target);
|
|
265
|
+
(0, events_1.info)(emit, `removing '${target}'s containers and network${volumes ? ', data volume and record' : ' (data kept)'}`, { phase: 'teardown' });
|
|
266
|
+
if ((await engine.down(target, { volumes, ...(streamOutput ? { onLine: echo } : {}) })) !== 0) {
|
|
267
|
+
throw new errors_1.DockerError(`\`docker compose down\` failed for '${target}'`);
|
|
268
|
+
}
|
|
269
|
+
// A route left behind points the edge at a container that no longer exists, so that
|
|
270
|
+
// hostname would 502 instead of 404 -- and the name could never be reused by anyone else.
|
|
271
|
+
(0, routes_1.deregister)(target);
|
|
272
|
+
if (volumes) {
|
|
273
|
+
await paths.remove(target);
|
|
274
|
+
// SAID, as the Kubernetes path says it: the containers and volume are gone, and a record
|
|
275
|
+
// that could not be removed would otherwise go on being listed with nothing behind it.
|
|
276
|
+
if (await paths.exists(target)) {
|
|
277
|
+
(0, events_1.warn)(emit, `the containers and data volume are gone but ${paths.workspace(target)} could not be ` +
|
|
278
|
+
`removed, so \`list\` will still show '${target}'. Remove that directory by hand.`, { phase: 'teardown' });
|
|
279
|
+
}
|
|
280
|
+
// A note about a workspace that is gone advises work nobody can do: `doctor` kept
|
|
281
|
+
// telling people to `houston ready` a workspace this had just deleted.
|
|
282
|
+
(0, journal_1.clearWorkspace)(target);
|
|
283
|
+
await (0, state_1.clearDefaultIf)(target);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
async function teardown(name, { volumes = false, confirm = false, emit = events_1.nullEmit, streamOutput = false } = {}) {
|
|
287
|
+
const target = await naming.resolveName(name);
|
|
288
|
+
await preconditions.requireEngine(target);
|
|
289
|
+
if (volumes && !confirm) {
|
|
290
|
+
throw new errors_1.ValidationError(`deleting ${(0, format_1.quotedText)(target)}'s data volume and record is irreversible - pass confirm=true`);
|
|
291
|
+
}
|
|
292
|
+
const refuseUnlessAllowed = async () => {
|
|
293
|
+
if (!volumes)
|
|
294
|
+
return;
|
|
295
|
+
const [allowed, why] = await ownership.mayDestroy(target, (0, audit_1.actor)());
|
|
296
|
+
if (!allowed) {
|
|
297
|
+
(0, audit_1.record)('down-volumes', target, { outcome: 'denied' });
|
|
298
|
+
throw new errors_1.ConflictError(why);
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
await refuseUnlessAllowed();
|
|
302
|
+
// Locked: `down` during a create races `docker compose up` and leaves orphaned
|
|
303
|
+
// containers behind.
|
|
304
|
+
const body = async () => {
|
|
305
|
+
// AGAIN UNDER THE LOCK: handed over while this waited, it is somebody else's data now.
|
|
306
|
+
await refuseUnlessAllowed();
|
|
307
|
+
// Recorded BEFORE the work, not after: a teardown that dies half way through has still
|
|
308
|
+
// destroyed containers, and that is exactly the event someone will come looking for.
|
|
309
|
+
// After the check, so a refusal is not also written down as done.
|
|
310
|
+
(0, audit_1.record)(volumes ? 'down-volumes' : 'down', target);
|
|
311
|
+
// The two runtimes answer DIFFERENTLY, and always did: the Kubernetes path reports
|
|
312
|
+
// `found` and its own `runtime`, and says its own "done" line.
|
|
313
|
+
if ((await topology.ofRepro(target)) === topology.KUBERNETES) {
|
|
314
|
+
await (0, state_1.downComposeLeftovers)(target, volumes, emit);
|
|
315
|
+
return await teardownKubernetes(target, volumes, emit);
|
|
316
|
+
}
|
|
317
|
+
await teardownCompose(target, volumes, emit, streamOutput);
|
|
318
|
+
return null;
|
|
319
|
+
};
|
|
320
|
+
// ASKED FIRST WITHOUT WAITING, so a wait is SAID: `down --volumes` behind a running
|
|
321
|
+
// `backup` sat silent for its whole duration. Only the lock's own refusal waits; any other
|
|
322
|
+
// conflict from the teardown is the answer.
|
|
323
|
+
let result;
|
|
324
|
+
try {
|
|
325
|
+
result = await (0, locks_1.reproLock)(target, body, { timeoutMs: 0 });
|
|
326
|
+
}
|
|
327
|
+
catch (error) {
|
|
328
|
+
if (!(error instanceof errors_1.ConflictError && error.message.startsWith('another houston'))) {
|
|
329
|
+
throw error;
|
|
330
|
+
}
|
|
331
|
+
(0, events_1.info)(emit, `another houston command is working on '${target}' (a backup, restore or upgrade?) — ` +
|
|
332
|
+
`waiting up to ${String(types_1.INTERACTIVE_LOCK_WAIT)}s for it to finish`, { phase: 'teardown' });
|
|
333
|
+
result = await (0, locks_1.reproLock)(target, body, { timeoutMs: types_1.INTERACTIVE_LOCK_WAIT * 1000 });
|
|
334
|
+
}
|
|
335
|
+
if (result !== null)
|
|
336
|
+
return result;
|
|
337
|
+
(0, events_1.info)(emit, `'${target}' ${volumes ? 'removed' : 'down (data kept)'}`, { phase: 'done' });
|
|
338
|
+
return { name: target, removed: volumes };
|
|
339
|
+
}
|