@rocket.chat/houston 0.27.0-next.2 → 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 -192
- package/src/bin.js +0 -4
- package/src/cli.ts +0 -25
- package/src/commands/createBranch.ts +0 -25
- 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,367 @@
|
|
|
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.requireTheComposePlugin = requireTheComposePlugin;
|
|
37
|
+
exports.requireDocker = requireDocker;
|
|
38
|
+
exports.unsupportedFields = unsupportedFields;
|
|
39
|
+
exports.requireEngine = requireEngine;
|
|
40
|
+
exports.reachableBeyondLoopback = reachableBeyondLoopback;
|
|
41
|
+
exports.guardProjectCollision = guardProjectCollision;
|
|
42
|
+
exports.checkStateRequest = checkStateRequest;
|
|
43
|
+
exports.checkTeardownRequest = checkTeardownRequest;
|
|
44
|
+
exports.refuseUnsupportedOnKubernetes = refuseUnsupportedOnKubernetes;
|
|
45
|
+
exports.waitsOnHealth = waitsOnHealth;
|
|
46
|
+
exports.refuseHealthWaitsTheEngineCannotRun = refuseHealthWaitsTheEngineCannotRun;
|
|
47
|
+
/**
|
|
48
|
+
* What has to be true before a command runs at all.
|
|
49
|
+
*
|
|
50
|
+
* Tier 1. Each of these REFUSES rather than warning: an engine that is not there, a state
|
|
51
|
+
* transition that is not defined, a teardown the caller may not perform, a project name
|
|
52
|
+
* already taken by something houston did not create. A create that starts and then cannot
|
|
53
|
+
* finish leaves a half-made workspace, which is worse than never starting.
|
|
54
|
+
*/
|
|
55
|
+
const errors_1 = require("../../lib/errors");
|
|
56
|
+
const events_1 = require("../../lib/events");
|
|
57
|
+
const format_1 = require("../../lib/format");
|
|
58
|
+
const presets = __importStar(require("../../lib/presets/index"));
|
|
59
|
+
const composite_1 = require("../../lib/presets/composite");
|
|
60
|
+
const audit_1 = require("../audit");
|
|
61
|
+
const tools_1 = require("../kube/tools");
|
|
62
|
+
const host_1 = require("../runner/host");
|
|
63
|
+
const paths = __importStar(require("../runner/paths"));
|
|
64
|
+
const record_1 = require("../runner/record");
|
|
65
|
+
const queries_1 = require("../runner/queries");
|
|
66
|
+
const topology = __importStar(require("../topology"));
|
|
67
|
+
const tls_1 = require("../tls");
|
|
68
|
+
const naming = __importStar(require("./naming"));
|
|
69
|
+
const ownership = __importStar(require("./ownership"));
|
|
70
|
+
const request_1 = require("./request");
|
|
71
|
+
const types_1 = require("./types");
|
|
72
|
+
function isTruthy(value) {
|
|
73
|
+
if (value === null || value === undefined || value === false)
|
|
74
|
+
return false;
|
|
75
|
+
if (typeof value === 'string')
|
|
76
|
+
return value !== '';
|
|
77
|
+
if (typeof value === 'number')
|
|
78
|
+
return value !== 0;
|
|
79
|
+
if (Array.isArray(value))
|
|
80
|
+
return value.length > 0;
|
|
81
|
+
if (typeof value === 'object')
|
|
82
|
+
return Object.keys(value).length > 0;
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* A box can have the engine without the plugin, and `docker info` says nothing about it.
|
|
87
|
+
*
|
|
88
|
+
* AND the compose plugin, because every path here shells out to `docker compose` and a
|
|
89
|
+
* box can have one without the other. It is a preflight fault -- fix your environment --
|
|
90
|
+
* so it is raised as one, once, with the package to install.
|
|
91
|
+
*/
|
|
92
|
+
async function requireTheComposePlugin() {
|
|
93
|
+
const cv = (await (0, host_1.composeVersion)()) ?? '';
|
|
94
|
+
// Podman's own compose provider is a different program, not Compose v2: it does not honour
|
|
95
|
+
// what houston's documents rely on (depends_on conditions, one-shot init services).
|
|
96
|
+
if (cv.toLowerCase().includes('podman-compose')) {
|
|
97
|
+
throw new errors_1.PreflightError(`\`docker compose\` is podman-compose (${cv}), which houston does not support. Install ` +
|
|
98
|
+
'the Compose v2 plugin; Podman then uses it as its compose provider:\n' +
|
|
99
|
+
' mkdir -p ~/.docker/cli-plugins\n' +
|
|
100
|
+
' curl -fsSL -o ~/.docker/cli-plugins/docker-compose \\\n' +
|
|
101
|
+
' https://github.com/docker/compose/releases/latest/download/docker-compose-linux-$(uname -m)\n' +
|
|
102
|
+
' chmod +x ~/.docker/cli-plugins/docker-compose');
|
|
103
|
+
}
|
|
104
|
+
const major = cv ? cv.split('.')[0].replace(/^v/u, '') : '';
|
|
105
|
+
if (!/^\d+$/u.test(major) || Number.parseInt(major, 10) < 2) {
|
|
106
|
+
if (cv) {
|
|
107
|
+
throw new errors_1.PreflightError(`\`docker compose\` reports ${cv}, and houston needs v2 or newer. ` +
|
|
108
|
+
'Upgrade the compose plugin, then `docker compose version`.');
|
|
109
|
+
}
|
|
110
|
+
// NOT NECESSARILY ABSENT. The same binary is both the plugin and a standalone
|
|
111
|
+
// `docker-compose`, so a box can have a working v2 on PATH while `docker compose`
|
|
112
|
+
// does not exist -- the binary was never put where the docker CLI looks.
|
|
113
|
+
const standalone = (await (0, host_1.composeStandaloneVersion)()) ?? '';
|
|
114
|
+
if (standalone) {
|
|
115
|
+
throw new errors_1.PreflightError('`docker compose` is not available, but a standalone ' +
|
|
116
|
+
`\`docker-compose\` ${standalone} is on PATH — the binary is there and the ` +
|
|
117
|
+
'docker CLI cannot see it as a plugin. houston calls `docker compose`, ' +
|
|
118
|
+
'so register it once:\n' +
|
|
119
|
+
' mkdir -p ~/.docker/cli-plugins\n' +
|
|
120
|
+
' ln -sf "$(command -v docker-compose)" ' +
|
|
121
|
+
'~/.docker/cli-plugins/docker-compose\n' +
|
|
122
|
+
` Then \`docker compose version\` should print ${standalone}.`);
|
|
123
|
+
}
|
|
124
|
+
throw new errors_1.PreflightError('`docker compose` v2 is not available — the plugin is not installed. ' +
|
|
125
|
+
'Everything houston does with containers goes through it.' +
|
|
126
|
+
'\n Amazon Linux / RHEL / Fedora: `sudo dnf install -y docker-compose-plugin`' +
|
|
127
|
+
'\n Debian / Ubuntu: `sudo apt-get install -y docker-compose-plugin`' +
|
|
128
|
+
'\n Then `docker compose version`, and `houston doctor` to check the rest.');
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Refuse when the container engine is not answering.
|
|
133
|
+
*
|
|
134
|
+
* `DockerError`, not `NotReadyError`. The distinction is the whole point of the
|
|
135
|
+
* exit-code taxonomy: `NOT_READY` (exit 5, HTTP 409) means "it is coming up, poll again",
|
|
136
|
+
* and an absent engine is never that -- polling cannot start Docker.
|
|
137
|
+
*/
|
|
138
|
+
async function requireDocker() {
|
|
139
|
+
if (!(await (0, host_1.dockerAvailable)())) {
|
|
140
|
+
// Named for the platform, because "Start Docker Desktop" on Linux names a product
|
|
141
|
+
// that is usually not the one installed.
|
|
142
|
+
const starter = process.platform === 'darwin' || process.platform === 'win32'
|
|
143
|
+
? 'Start Docker Desktop'
|
|
144
|
+
: 'Start it with `sudo systemctl start docker`';
|
|
145
|
+
throw new errors_1.DockerError(`Docker isn't running. ${starter} and try again.`);
|
|
146
|
+
}
|
|
147
|
+
await requireTheComposePlugin();
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* What a runtime cannot honour, from the registry the create path enforces.
|
|
151
|
+
*
|
|
152
|
+
* Published so the create dialog can say it BEFORE somebody fills a field in -- and, more
|
|
153
|
+
* to the point, so it cannot say it wrongly.
|
|
154
|
+
*/
|
|
155
|
+
function unsupportedFields(runtime) {
|
|
156
|
+
if (topology.normalize(runtime) !== topology.KUBERNETES)
|
|
157
|
+
return [];
|
|
158
|
+
return types_1.KUBERNETES_UNSUPPORTED.map(([name, why]) => ({ field: name, why }));
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Require the engine THIS workspace runs on -- not the one Compose needs.
|
|
162
|
+
*
|
|
163
|
+
* `requireDocker()` was called before anything looked at the runtime, so every Kubernetes
|
|
164
|
+
* path went through a gate it has no use for. On a host with no Docker at all -- the
|
|
165
|
+
* documented adopt-an-existing-cluster setup -- `upgrade`, `ready`, `logs`, `token`,
|
|
166
|
+
* `api`, `pat`, `seed` and `down` all refused a perfectly healthy workspace.
|
|
167
|
+
*
|
|
168
|
+
* CONTRACT: `target` is an already-resolved workspace name.
|
|
169
|
+
*/
|
|
170
|
+
async function requireEngine(target) {
|
|
171
|
+
if ((await topology.ofRepro(target)) !== topology.KUBERNETES) {
|
|
172
|
+
await requireDocker();
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
// kubectl is the engine here. Said rather than assumed: without it every Kubernetes
|
|
176
|
+
// operation fails one layer deeper, in a subprocess whose "command not found" names
|
|
177
|
+
// nothing the reader can act on.
|
|
178
|
+
if (!(0, tools_1.which)('kubectl')) {
|
|
179
|
+
throw new errors_1.PreflightError(`'${target}' runs on Kubernetes and \`kubectl\` is not on PATH, so ` +
|
|
180
|
+
'houston cannot reach it. Install kubectl and make sure your ' +
|
|
181
|
+
'kubeconfig points at the cluster this workspace lives in.');
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Whether anything off this machine can reach this workspace.
|
|
186
|
+
*
|
|
187
|
+
* This is the ONE question `config.ADMIN_PASSWORD` turns on. Both ways of removing that
|
|
188
|
+
* premise are here: a public name reaches Rocket.Chat through the edge while the
|
|
189
|
+
* workspace itself stays on loopback, so the bind check alone answers "no" for the very
|
|
190
|
+
* case that matters most.
|
|
191
|
+
*
|
|
192
|
+
* A LOCAL-CA `--https` name is deliberately NOT public: `<name>.houston.localhost`
|
|
193
|
+
* resolves to 127.0.0.1, nothing off the box can reach it, and treating it as exposed
|
|
194
|
+
* would rotate the password for the common local case for no gain.
|
|
195
|
+
*/
|
|
196
|
+
function reachableBeyondLoopback({ tlsspec = null, bindHost = '', } = {}) {
|
|
197
|
+
if (tlsspec !== null && tlsspec.mode === tls_1.MODE_ACME)
|
|
198
|
+
return true;
|
|
199
|
+
return !types_1.LOOPBACK_BINDS.includes(bindHost);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Refuse to create when a docker compose project of the same derived name already exists
|
|
203
|
+
* but belongs to a DIFFERENT workspace.
|
|
204
|
+
*
|
|
205
|
+
* The project name is `houston-<name>` regardless of HOUSTON_HOME, so a repro named after
|
|
206
|
+
* an existing one in another home would make `docker compose up` reconcile (hijack) the
|
|
207
|
+
* other workspace's containers/volume. The project check is best-effort (docker that cannot
|
|
208
|
+
* list projects cannot create one either); the volume check refuses an unanswered ask.
|
|
209
|
+
*/
|
|
210
|
+
async function guardProjectCollision(name) {
|
|
211
|
+
const proj = await (0, record_1.projectName)(name);
|
|
212
|
+
// A PROJECT `down`ED WITHOUT --volumes is in no `compose ls`, so the check below passed,
|
|
213
|
+
// and Compose quietly mounted the MongoDB it left: a second home on this machine -- `sudo
|
|
214
|
+
// houston` is root's -- served the first one's data, and its `down --volumes` deleted it.
|
|
215
|
+
// A name this home has no record of has no data of its own yet.
|
|
216
|
+
if (!(await paths.exists(name))) {
|
|
217
|
+
const left = await (0, queries_1.projectDataVolumes)(proj);
|
|
218
|
+
// "Could not ask" is not "there is none": a timed-out ask let the create mount another
|
|
219
|
+
// home's MongoDB, and that home's data then went with this one's `down --volumes`.
|
|
220
|
+
if (left === null) {
|
|
221
|
+
throw new errors_1.DockerError(`could not ask Docker whether another houston home left a MongoDB for '${name}', so ` +
|
|
222
|
+
'nothing was created - check `docker volume ls` answers, then try again');
|
|
223
|
+
}
|
|
224
|
+
if (left.length > 0) {
|
|
225
|
+
throw new errors_1.ConflictError(`the Docker volume ${left.join(', ')} already holds a MongoDB for '${name}', and ` +
|
|
226
|
+
'this houston has no workspace of that name: another houston home on this machine ' +
|
|
227
|
+
"made it (`sudo houston` uses root's), or this one did before its record was lost. " +
|
|
228
|
+
`Creating '${name}' here would start on that data, and its \`down --volumes\` ` +
|
|
229
|
+
'would delete it - choose a different --name, or, if nobody needs that data, ' +
|
|
230
|
+
`\`docker volume rm ${left.join(' ')}\``);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
const existing = await (0, queries_1.projectConfigFiles)();
|
|
234
|
+
if (existing === null || Object.keys(existing).length === 0)
|
|
235
|
+
return;
|
|
236
|
+
if (!Object.hasOwn(existing, proj))
|
|
237
|
+
return;
|
|
238
|
+
const ours = `${paths.workspace(name)}/docker-compose.yml`;
|
|
239
|
+
const files = String(existing[proj] ?? '');
|
|
240
|
+
if (!files.includes(ours)) {
|
|
241
|
+
throw new errors_1.ConflictError(`a docker compose project '${proj}' already exists, owned by a different ` +
|
|
242
|
+
`workspace (${files || 'unknown'}). Creating '${name}' here would hijack its ` +
|
|
243
|
+
'containers and data volume - choose a different --name.');
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Refuse a bad stop/start/restart BEFORE any work is queued. Returns the target.
|
|
248
|
+
*
|
|
249
|
+
* A PREFLIGHT: a refusal must leave no trace. The GUI runs this as a job now, and a job
|
|
250
|
+
* answers 200 with an id -- so a bad action or an unknown name would have become a job
|
|
251
|
+
* that failed rather than a 400 or a 404 on the request that made the mistake.
|
|
252
|
+
*/
|
|
253
|
+
async function checkStateRequest(name, action) {
|
|
254
|
+
if (typeof action !== 'string') {
|
|
255
|
+
throw new errors_1.ValidationError(`action must be a string (want ${types_1.STATE_ACTIONS.join('|')}), got ` + `${(0, format_1.valueKind)(action)}`);
|
|
256
|
+
}
|
|
257
|
+
if (!types_1.STATE_ACTIONS.includes(action)) {
|
|
258
|
+
throw new errors_1.ValidationError(`unknown action '${action}' (want ${types_1.STATE_ACTIONS.join('|')})`);
|
|
259
|
+
}
|
|
260
|
+
return await naming.resolveName(name);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Refuse an unconfirmed or unowned teardown before it is queued. Returns the target.
|
|
264
|
+
*
|
|
265
|
+
* Same reason as `checkStateRequest`, and the stake is higher: without it a member who
|
|
266
|
+
* asked to destroy a colleague's workspace got 200 and a job id, and had to open the
|
|
267
|
+
* Activity list to discover they had been refused.
|
|
268
|
+
*/
|
|
269
|
+
async function checkTeardownRequest(name, { volumes = false, confirm = false } = {}) {
|
|
270
|
+
const target = await naming.resolveName(name);
|
|
271
|
+
if (volumes && !confirm) {
|
|
272
|
+
throw new errors_1.ValidationError(`deleting ${(0, format_1.quotedText)(target)}'s data volume and record is irreversible - pass confirm=true`);
|
|
273
|
+
}
|
|
274
|
+
if (volumes) {
|
|
275
|
+
const [allowed, why] = await ownership.mayDestroy(target, (0, audit_1.actor)());
|
|
276
|
+
if (!allowed) {
|
|
277
|
+
(0, audit_1.record)('down-volumes', target, { outcome: 'denied' });
|
|
278
|
+
throw new errors_1.ConflictError(why);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return target;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Refuse what this runtime cannot honour, rather than accepting and dropping it.
|
|
285
|
+
*
|
|
286
|
+
* Ordered so the most consequential is reported first when several are set: being told
|
|
287
|
+
* about `--fresh` matters more than being told about `--reg-token`, because one of them
|
|
288
|
+
* is about data.
|
|
289
|
+
*/
|
|
290
|
+
function refuseUnsupportedOnKubernetes(req) {
|
|
291
|
+
const bag = req;
|
|
292
|
+
for (const [name, why] of types_1.KUBERNETES_UNSUPPORTED) {
|
|
293
|
+
if (isTruthy(bag[name])) {
|
|
294
|
+
throw new errors_1.ValidationError(`--${name.replace(/_/gu, '-')} is not supported on Kubernetes yet: ` +
|
|
295
|
+
`${why}. Use --runtime docker for a workspace that needs it.`);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
// A preset reaches Kubernetes when it has an adapter for it. Those that do not are
|
|
299
|
+
// still refused, because being recorded and not applied is what this guard exists to
|
|
300
|
+
// prevent; but the refusal is now per preset rather than a blanket "not supported", and
|
|
301
|
+
// it names the ones that DO work so the answer is actionable.
|
|
302
|
+
// Each preset of a composed workspace on its own, with its own `--set` (`voice.sip_integration=on`):
|
|
303
|
+
// one without an adapter, or set the way Kubernetes cannot run it, is named.
|
|
304
|
+
const names = (0, composite_1.namesOf)(req.preset);
|
|
305
|
+
const byPreset = names.length > 1 ? (0, request_1.paramsByPreset)(names, req.params) : null;
|
|
306
|
+
for (const name of names.filter((one) => one !== 'default')) {
|
|
307
|
+
refuseOneOnKubernetes(name, byPreset?.[name] ?? req.params);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
function refuseOneOnKubernetes(preset, params) {
|
|
311
|
+
const works = [...presets.scenarioNames()].sort().join(', ') || 'none yet';
|
|
312
|
+
// A bad `--set` or an unknown preset is refused in Docker's own words: it is the input,
|
|
313
|
+
// not the runtime, and "use --runtime docker" would send the same typo to a refusal there.
|
|
314
|
+
presets.asValidation(() => presets.load(preset, params));
|
|
315
|
+
let resolved;
|
|
316
|
+
try {
|
|
317
|
+
resolved = presets.resolve(preset, topology.KUBERNETES, params);
|
|
318
|
+
}
|
|
319
|
+
catch (error) {
|
|
320
|
+
throw new errors_1.ValidationError(`preset '${preset}' cannot be resolved for Kubernetes: ` +
|
|
321
|
+
`${error instanceof Error ? error.message : String(error)}. ` +
|
|
322
|
+
`Presets with a Kubernetes adapter: ${works}. Or use ` +
|
|
323
|
+
'--runtime docker, where every preset works.');
|
|
324
|
+
}
|
|
325
|
+
// RESOLVING is not the same as WORKING. A preset with no scenario adapter comes back
|
|
326
|
+
// with its Compose `services` intact -- Keycloak, Mailpit, MinIO -- and this runtime
|
|
327
|
+
// builds no compose document, so those containers would simply never exist while the
|
|
328
|
+
// settings pointing at them were applied.
|
|
329
|
+
if (Object.keys(resolved.services).length > 0 && resolved.kubernetesManifests.length === 0) {
|
|
330
|
+
throw new errors_1.ValidationError(`preset '${preset}' needs backing services ` +
|
|
331
|
+
`(${Object.keys(resolved.services).sort().join(', ')}) and has no ` +
|
|
332
|
+
'Kubernetes adapter to create them, so they would be missing while ' +
|
|
333
|
+
'Rocket.Chat was configured to use them. Presets with an adapter: ' +
|
|
334
|
+
`${works}. Or use --runtime docker, where every preset works.`);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
/** Whether a compose document makes any service wait for another's healthcheck. */
|
|
338
|
+
function waitsOnHealth(doc) {
|
|
339
|
+
return Object.values(doc.services).some((service) => {
|
|
340
|
+
const dependsOn = service.depends_on;
|
|
341
|
+
if (typeof dependsOn !== 'object' || dependsOn === null || Array.isArray(dependsOn))
|
|
342
|
+
return false;
|
|
343
|
+
return Object.values(dependsOn).some((dependency) => dependency.condition === 'service_healthy');
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Refuse a document that waits on a healthcheck when this engine runs none: it would never
|
|
348
|
+
* start (MongoDB 8's replica-set init waits on MongoDB's health, so does every second
|
|
349
|
+
* instance). `--force` warns and tries anyway.
|
|
350
|
+
*/
|
|
351
|
+
async function refuseHealthWaitsTheEngineCannotRun(doc, force, emit) {
|
|
352
|
+
if (!waitsOnHealth(doc))
|
|
353
|
+
return;
|
|
354
|
+
const found = await (0, host_1.engine)();
|
|
355
|
+
if (found === null || found.healthchecks)
|
|
356
|
+
return;
|
|
357
|
+
const why = `${found.kind === 'podman' ? 'Podman' : 'This engine'} here runs no container healthchecks ` +
|
|
358
|
+
`(cgroup manager '${found.cgroupDriver || '?'}'; Podman times them with systemd), and this ` +
|
|
359
|
+
"workspace's startup waits on one, so it would never come up.";
|
|
360
|
+
const fix = 'Run Podman with cgroup_manager = "systemd" in containers.conf under a systemd user ' +
|
|
361
|
+
'session (a distro build; a static one cannot), or use a Podman machine or Docker.';
|
|
362
|
+
if (force) {
|
|
363
|
+
(0, events_1.warn)(emit, `${why} --force: trying anyway. ${fix}`, { phase: 'preflight' });
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
throw new errors_1.PreflightError(`${why}\n ${fix}\n --force tries anyway.`);
|
|
367
|
+
}
|