@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,939 @@
|
|
|
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.kubeCreate = kubeCreate;
|
|
37
|
+
exports.settleName = settleName;
|
|
38
|
+
exports.settleEnv = settleEnv;
|
|
39
|
+
exports.resolvePairing = resolvePairing;
|
|
40
|
+
exports.settleAddressing = settleAddressing;
|
|
41
|
+
exports.certifyTheDirectory = certifyTheDirectory;
|
|
42
|
+
exports.planClusterStep = planClusterStep;
|
|
43
|
+
exports.planTls = planTls;
|
|
44
|
+
exports.planKubeTls = planKubeTls;
|
|
45
|
+
exports.writeProvisionalRecord = writeProvisionalRecord;
|
|
46
|
+
exports.routeTheName = routeTheName;
|
|
47
|
+
exports.forgetTheRouteThisCreateMade = forgetTheRouteThisCreateMade;
|
|
48
|
+
exports.createTheWorkspace = createTheWorkspace;
|
|
49
|
+
exports.buildRecord = buildRecord;
|
|
50
|
+
exports.recordTheRequest = recordTheRequest;
|
|
51
|
+
exports.writeRecordStep = writeRecordStep;
|
|
52
|
+
exports.finish = finish;
|
|
53
|
+
exports.createKubernetes = createKubernetes;
|
|
54
|
+
/**
|
|
55
|
+
* Creating a workspace on Kubernetes.
|
|
56
|
+
*
|
|
57
|
+
* Tier 5. The Kubernetes half of create, split from the Compose half because the two share a
|
|
58
|
+
* request and almost nothing else: this one talks to a cluster that may not exist yet, has no
|
|
59
|
+
* compose file to write, and publishes a name through an ingress rather than a port.
|
|
60
|
+
*
|
|
61
|
+
* Like the Compose half, this is a PLAN plus named steps rather than one function. The
|
|
62
|
+
* order carries decisions that each cost a real defect to learn -- the write-ahead record
|
|
63
|
+
* before any cluster resource exists, the cluster chosen before a byte is written, the
|
|
64
|
+
* core tools checked before a kind cluster is built. The order is visible at the bottom.
|
|
65
|
+
*/
|
|
66
|
+
const fs = __importStar(require("node:fs/promises"));
|
|
67
|
+
const config = __importStar(require("../../lib/config"));
|
|
68
|
+
const home_1 = require("../../lib/home");
|
|
69
|
+
const format_1 = require("../../lib/format");
|
|
70
|
+
const errors_1 = require("../../lib/errors");
|
|
71
|
+
const events_1 = require("../../lib/events");
|
|
72
|
+
const presets = __importStar(require("../../lib/presets/index"));
|
|
73
|
+
const composite_1 = require("../../lib/presets/composite");
|
|
74
|
+
const ldap_1 = require("../../lib/presets/ldap");
|
|
75
|
+
const public_1 = require("../../lib/presets/public");
|
|
76
|
+
const version_spec_1 = require("../../lib/version-spec");
|
|
77
|
+
const versions_1 = require("../../lib/versions");
|
|
78
|
+
const chart_1 = require("../kube/chart");
|
|
79
|
+
const ownership = __importStar(require("./ownership"));
|
|
80
|
+
const e2ee_1 = require("../../lib/presets/e2ee");
|
|
81
|
+
const voice_1 = require("../../lib/presets/voice");
|
|
82
|
+
const endpoints_1 = require("../kube/endpoints");
|
|
83
|
+
const forward_1 = require("../kube/forward");
|
|
84
|
+
const routes_1 = require("../edge/routes");
|
|
85
|
+
const spec_1 = require("../edge/spec");
|
|
86
|
+
const namespace_1 = require("../kube/namespace");
|
|
87
|
+
const names_1 = require("../kube/names");
|
|
88
|
+
const operator_1 = require("../kube/operator");
|
|
89
|
+
const context_1 = require("../kube/context");
|
|
90
|
+
const cluster_1 = require("../kube/cluster");
|
|
91
|
+
const reachability_1 = require("../kube/reachability");
|
|
92
|
+
const tools_1 = require("../kube/tools");
|
|
93
|
+
const probe_1 = require("../kube/probe");
|
|
94
|
+
const workspace_1 = require("../kube/workspace");
|
|
95
|
+
const record_1 = require("../runner/record");
|
|
96
|
+
const paths_1 = require("../runner/paths");
|
|
97
|
+
const exec_1 = require("../../seams/exec");
|
|
98
|
+
const topology = __importStar(require("../topology"));
|
|
99
|
+
const tls_1 = require("../tls");
|
|
100
|
+
const naming = __importStar(require("./naming"));
|
|
101
|
+
const notes = __importStar(require("./notes"));
|
|
102
|
+
const ports = __importStar(require("./ports"));
|
|
103
|
+
const preconditions = __importStar(require("./preconditions"));
|
|
104
|
+
const ready_1 = require("./ready");
|
|
105
|
+
const request = __importStar(require("./request"));
|
|
106
|
+
const seeding = __importStar(require("./seeding"));
|
|
107
|
+
const sizing = __importStar(require("./sizing"));
|
|
108
|
+
const types_1 = require("./types");
|
|
109
|
+
const tlsplan = __importStar(require("./tlsplan"));
|
|
110
|
+
function bag(value) {
|
|
111
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
112
|
+
? value
|
|
113
|
+
: {};
|
|
114
|
+
}
|
|
115
|
+
function isTruthy(value) {
|
|
116
|
+
if (value === null || value === undefined || value === false)
|
|
117
|
+
return false;
|
|
118
|
+
if (typeof value === 'string')
|
|
119
|
+
return value !== '';
|
|
120
|
+
if (typeof value === 'number')
|
|
121
|
+
return value !== 0;
|
|
122
|
+
if (Array.isArray(value))
|
|
123
|
+
return value.length > 0;
|
|
124
|
+
if (typeof value === 'object')
|
|
125
|
+
return Object.keys(value).length > 0;
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
function kubeCreate(values) {
|
|
129
|
+
return {
|
|
130
|
+
reproName: '',
|
|
131
|
+
reused: false,
|
|
132
|
+
envOverrides: {},
|
|
133
|
+
licensed: false,
|
|
134
|
+
previous: { pid: 0, port: null, scenarioForwards: {} },
|
|
135
|
+
previousMeta: null,
|
|
136
|
+
namespaceIdentity: null,
|
|
137
|
+
presetParams: null,
|
|
138
|
+
resolved: null,
|
|
139
|
+
recorded: 0,
|
|
140
|
+
wasPinned: false,
|
|
141
|
+
hostPort: 0,
|
|
142
|
+
cfg: {},
|
|
143
|
+
regToken: '',
|
|
144
|
+
bindHost: '',
|
|
145
|
+
root: '',
|
|
146
|
+
microservices: false,
|
|
147
|
+
presetForNotes: null,
|
|
148
|
+
sidePorts: {},
|
|
149
|
+
monitoringPorts: [],
|
|
150
|
+
pre: null,
|
|
151
|
+
plan: null,
|
|
152
|
+
tlsspec: null,
|
|
153
|
+
ktls: null,
|
|
154
|
+
routeIntroduced: false,
|
|
155
|
+
adminPassword: '',
|
|
156
|
+
provisional: null,
|
|
157
|
+
out: {},
|
|
158
|
+
meta: null,
|
|
159
|
+
groups: null,
|
|
160
|
+
result: {},
|
|
161
|
+
...values,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* When the workspace was made: kept on a re-up, which keeps its data. Stamped afresh, a backup
|
|
166
|
+
* taken before a `down` and re-up read as one from an earlier workspace with the same name.
|
|
167
|
+
*/
|
|
168
|
+
function bornAt(previous) {
|
|
169
|
+
return previous?.createdAt || new Date().toISOString().slice(0, 19) + '+00:00';
|
|
170
|
+
}
|
|
171
|
+
/** The longest a namespace, a DNS label, may be. */
|
|
172
|
+
const NAMESPACE_MAX = 63;
|
|
173
|
+
/** The name, whether this is a re-create, and the capacity refusal. */
|
|
174
|
+
async function settleName(job) {
|
|
175
|
+
job.reproName = naming.deriveFor(job.req);
|
|
176
|
+
naming.warnNameCoerced(job.req, job.emit);
|
|
177
|
+
naming.announceName(job.req, job.reproName, job.emit);
|
|
178
|
+
naming.requireValidName(job.reproName);
|
|
179
|
+
// NO refusal for an existing workspace. `down` tells the user "bring it back: houston up
|
|
180
|
+
// ...", and this raised "already exists, down first or --force" at them -- two messages
|
|
181
|
+
// in the same tool contradicting each other about the same workspace. The namespace and
|
|
182
|
+
// its PVC survived a plain `down`, which is exactly what makes bringing it back
|
|
183
|
+
// meaningful.
|
|
184
|
+
job.reused = await (0, paths_1.exists)(job.reproName);
|
|
185
|
+
if (job.reused) {
|
|
186
|
+
(0, events_1.info)(job.emit, `'${job.reproName}' already exists — bringing it back up`, { phase: 'plan' });
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
// Before anything is made: a namespace is a DNS label, 63 characters, and kubectl
|
|
190
|
+
// refused a longer `houston-<name>` only once the create was under way.
|
|
191
|
+
const namespace = (0, names_1.mintNamespace)(job.reproName);
|
|
192
|
+
if (namespace.length > NAMESPACE_MAX) {
|
|
193
|
+
const max = job.reproName.length - (namespace.length - NAMESPACE_MAX);
|
|
194
|
+
throw new errors_1.ValidationError(`'${job.reproName}' is too long for Kubernetes: its namespace ${namespace} is ` +
|
|
195
|
+
`${String(namespace.length)} characters, and a namespace holds ` +
|
|
196
|
+
`${String(NAMESPACE_MAX)}. Give it a shorter name: ` +
|
|
197
|
+
`${naming.typedRoom(job.req, job.reproName, max)}.`);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
await sizing.checkCapacity(job.req, job.req.preset, job.emit);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* The env overrides, as Compose's `buildDocument` settles them: what the workspace already
|
|
204
|
+
* had, then anything named on THIS run. Without the carry-forward a re-up silently dropped
|
|
205
|
+
* them; without this step at all, `up --env` and `--setting` were ignored on Kubernetes.
|
|
206
|
+
* Refused here, before anything is written, if the chart owns the key.
|
|
207
|
+
*/
|
|
208
|
+
async function settleEnv(job) {
|
|
209
|
+
job.envOverrides = {};
|
|
210
|
+
job.licensed = job.req.license !== '';
|
|
211
|
+
if (job.reused) {
|
|
212
|
+
let old = null;
|
|
213
|
+
try {
|
|
214
|
+
old = await (0, record_1.readMeta)(job.reproName);
|
|
215
|
+
}
|
|
216
|
+
catch {
|
|
217
|
+
// half-written record; nothing to carry
|
|
218
|
+
}
|
|
219
|
+
// A different set of presets is refused, not applied over the old one: the old
|
|
220
|
+
// presets' objects would stay in the namespace with nothing pointing at them.
|
|
221
|
+
const was = old?.preset || 'default';
|
|
222
|
+
// Compared as SETS: a record an earlier build wrote as typed (`ldap+email`) is the same
|
|
223
|
+
// set as the canonical `email+ldap` this run asks for.
|
|
224
|
+
const asked = job.req.preset || 'default';
|
|
225
|
+
if (old !== null &&
|
|
226
|
+
old.extra.incomplete !== true &&
|
|
227
|
+
(0, composite_1.compositeName)((0, composite_1.namesOf)(was)) !== (0, composite_1.compositeName)((0, composite_1.namesOf)(asked))) {
|
|
228
|
+
throw new errors_1.ValidationError(`'${job.reproName}' runs the ${was} preset${(0, composite_1.namesOf)(was).length > 1 ? 's' : ''} and ` +
|
|
229
|
+
`this asks for ${job.req.preset || 'default'}. Kubernetes cannot swap presets in ` +
|
|
230
|
+
`place: \`houston down --name ${job.reproName} --volumes\`, then \`up\` again, or ` +
|
|
231
|
+
'leave out --preset to bring it back as it was.');
|
|
232
|
+
}
|
|
233
|
+
if (old !== null) {
|
|
234
|
+
job.previousMeta = old;
|
|
235
|
+
const previous = old.extra;
|
|
236
|
+
const owner = Object.hasOwn(previous, 'namespace_owner')
|
|
237
|
+
? previous.namespace_owner
|
|
238
|
+
: (previous.created_by ?? '');
|
|
239
|
+
const uid = Object.hasOwn(previous, 'namespace_uid') ? previous.namespace_uid : '';
|
|
240
|
+
if (typeof owner !== 'string' || typeof uid !== 'string') {
|
|
241
|
+
throw new errors_1.ConflictError(`'${job.reproName}' has an invalid namespace ownership record — refusing to replace it`);
|
|
242
|
+
}
|
|
243
|
+
job.namespaceIdentity = { uid, owner };
|
|
244
|
+
job.envOverrides = { ...bag(previous.env) };
|
|
245
|
+
// The Secret stays in the namespace across a `down`, so a re-up keeps referencing it.
|
|
246
|
+
job.licensed || (job.licensed = previous.licensed === true);
|
|
247
|
+
// HERE, not after the write-ahead record: that record replaces this one, and reading
|
|
248
|
+
// the forwards back from it found none -- so a re-up never retired its own forward,
|
|
249
|
+
// which kept the port and failed the readiness wait, and `down` lost track of both
|
|
250
|
+
// forwards, which then outlived the workspace holding 3000-range and side ports.
|
|
251
|
+
job.previous = {
|
|
252
|
+
pid: Number(previous.port_forward_pid ?? 0) || 0,
|
|
253
|
+
port: Number(old.hostPort) || null,
|
|
254
|
+
scenarioForwards: bag(previous.scenario_forwards),
|
|
255
|
+
};
|
|
256
|
+
// MONITORING COMES BACK WITH IT, as TLS does. The record is rewritten on a re-up and
|
|
257
|
+
// only an attach writes `monitoring` and the Grafana forward, so a workspace brought
|
|
258
|
+
// back without `--monitor` lost its Grafana link -- while the stack, its Ingress and
|
|
259
|
+
// the namespace label were all still there.
|
|
260
|
+
if (isTruthy(previous.monitoring))
|
|
261
|
+
job.req.monitor = true;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
Object.assign(job.envOverrides, job.req.env);
|
|
265
|
+
(0, chart_1.refuseChartOwnedEnv)(job.envOverrides);
|
|
266
|
+
}
|
|
267
|
+
/** A version recorded for a CI build (`8.10.0.dev0`), which no release carries. */
|
|
268
|
+
function isDevBuild(version) {
|
|
269
|
+
try {
|
|
270
|
+
return (0, version_spec_1.parseVersion)(version).dev !== null;
|
|
271
|
+
}
|
|
272
|
+
catch {
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Rocket.Chat, its MongoDB and the host port -- announced before the slow part starts.
|
|
278
|
+
*
|
|
279
|
+
* SAID BEFORE IT IS DONE, not after. The live lookup and the cluster probing below are a
|
|
280
|
+
* dozen kubectl round trips; together they were a minute or more of complete silence
|
|
281
|
+
* after the opening line.
|
|
282
|
+
*/
|
|
283
|
+
async function resolvePairing(job) {
|
|
284
|
+
(0, events_1.info)(job.emit, `resolving Rocket.Chat ${job.req.version} and its MongoDB pairing`, {
|
|
285
|
+
phase: 'plan',
|
|
286
|
+
});
|
|
287
|
+
// Looked up HERE, after the announcement, where the release lookup has always gone
|
|
288
|
+
// online -- no longer by the front door ahead of every refusal, and no longer skipped by
|
|
289
|
+
// the ones that had no door to do it.
|
|
290
|
+
const fetcher = await request.releaseFetcher(job.req.version, job.req.offline, job.versionFetcher);
|
|
291
|
+
try {
|
|
292
|
+
job.resolved = (0, versions_1.resolve)(job.req.version, {
|
|
293
|
+
offline: job.req.offline,
|
|
294
|
+
...(fetcher === undefined ? {} : { fetcher }),
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
catch (error) {
|
|
298
|
+
throw new errors_1.ValidationError((0, errors_1.errorText)(error));
|
|
299
|
+
}
|
|
300
|
+
// A CI BUILD IS REFUSED HERE, before a namespace or a MongoDB exists. The Rocket.Chat
|
|
301
|
+
// chart compares its image tag as a semantic version (`semverCompare` in the stream-hub
|
|
302
|
+
// template, which every render evaluates), and a build's tag -- `develop`, `pr-123` -- is
|
|
303
|
+
// not one: helm refused it after MongoDB was up (exit 7), and no values combination pulls
|
|
304
|
+
// the ghcr image instead (measured on chart 7.0.0 and 7.0.2). A recorded build (`.devN`)
|
|
305
|
+
// fails the same way. Docker runs them.
|
|
306
|
+
if (job.resolved.source === versions_1.BUILD_SOURCE || isDevBuild(job.resolved.rcVersion)) {
|
|
307
|
+
throw new errors_1.ValidationError(`${job.req.version} is a CI build, and the Rocket.Chat chart reads its image tag as a ` +
|
|
308
|
+
'semantic version, so helm refuses a build tag. Run CI builds on Docker: `--runtime docker`.');
|
|
309
|
+
}
|
|
310
|
+
// SAID BEFORE THE BUILD, not discovered after it. `resolve()` already knows when
|
|
311
|
+
// releases.rocket.chat answered 404 -- it stamps `source` and the create path ignored
|
|
312
|
+
// it, so `up --version 99.99.99` built the whole document and failed at the pull ~90
|
|
313
|
+
// seconds later, leaving a workspace to clean up.
|
|
314
|
+
if (job.resolved.source === 'map (no such release)') {
|
|
315
|
+
(0, events_1.warn)(job.emit, `releases.rocket.chat has no ${job.req.version} — the pairing below ` +
|
|
316
|
+
'comes from the shipped map, and the image pull will fail unless ' +
|
|
317
|
+
`this tag really exists (\`houston versions ${job.req.version}\`).`, { phase: 'resolve' });
|
|
318
|
+
}
|
|
319
|
+
let before = null;
|
|
320
|
+
if (job.reused) {
|
|
321
|
+
try {
|
|
322
|
+
before = await (0, record_1.readMeta)(job.reproName);
|
|
323
|
+
}
|
|
324
|
+
catch {
|
|
325
|
+
before = null;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
// The flag, then -- for a workspace coming back -- the image it ran, then the box-wide
|
|
329
|
+
// `rc_image` (config.yaml or HOUSTON_RC_IMAGE), as Compose resolves it. Only the flag was
|
|
330
|
+
// read here, so a box pointed at a mirror pulled Kubernetes workspaces from Docker Hub;
|
|
331
|
+
// and a re-up swapped `--rc-image` (or a CI build's ghcr image) for the default
|
|
332
|
+
// repository, where Compose reuses the file that names it.
|
|
333
|
+
request.chooseImage(job.resolved, job.req.rcImage || (before === null ? '' : String(before.rcImage || '')), config.loadConfig().rc_image);
|
|
334
|
+
// A WORKSPACE COMES BACK AS IT WAS. A re-up re-applies the chart and MongoDB from this
|
|
335
|
+
// request: another version helm-moved Rocket.Chat over a database a different release had
|
|
336
|
+
// migrated -- downwards too, which `upgrade` refuses -- and a fresh pairing swapped the
|
|
337
|
+
// MongoDB image under its data. A create that never finished has nothing to keep.
|
|
338
|
+
const kept = before !== null && before.extra.incomplete !== true ? before : null;
|
|
339
|
+
if (kept !== null && kept.rcVersion !== '' && job.resolved.rcVersion !== kept.rcVersion) {
|
|
340
|
+
throw new errors_1.ValidationError(`'${job.reproName}' runs Rocket.Chat ${kept.rcVersion}, and this asks for ` +
|
|
341
|
+
`${job.resolved.rcVersion}. It comes back at its own version: \`--version ` +
|
|
342
|
+
`${kept.rcVersion}\`. \`houston upgrade --name ${job.reproName} --to ` +
|
|
343
|
+
`${job.resolved.rcVersion}\` moves it, with a backup to roll back to.`);
|
|
344
|
+
}
|
|
345
|
+
if (job.req.mongo)
|
|
346
|
+
(0, versions_1.applyMongoOverride)(job.resolved, job.req.mongo);
|
|
347
|
+
else if (kept !== null && kept.mongoTag !== '')
|
|
348
|
+
(0, versions_1.applyMongoOverride)(job.resolved, kept.mongoTag);
|
|
349
|
+
// NOR UNDER ANOTHER MONGODB. The operator keeps its data in a claim of its own, so a kept
|
|
350
|
+
// workspace brought back with --mongo-operator (or HOUSTON_MONGO_OPERATOR set since) came up
|
|
351
|
+
// on an empty database, its data in a claim nothing read -- and `down --volumes` deleted it.
|
|
352
|
+
if (kept !== null &&
|
|
353
|
+
kept.extra.mongo_managed_by === 'statefulset' &&
|
|
354
|
+
(0, operator_1.wouldUseOperator)(job.resolved.mongoTag, job.req.mongoOperator)) {
|
|
355
|
+
throw new errors_1.ValidationError(`'${job.reproName}' keeps its data in a MongoDB houston runs itself, and this would bring ` +
|
|
356
|
+
'it back under the MongoDB operator, on an empty volume. Bring it back without ' +
|
|
357
|
+
'--mongo-operator (and with HOUSTON_MONGO_OPERATOR unset). To move it to the operator: ' +
|
|
358
|
+
`\`houston backup --name ${job.reproName}\`, \`down --volumes\`, then \`restore --new\` ` +
|
|
359
|
+
'with the operator.');
|
|
360
|
+
}
|
|
361
|
+
// A workspace that comes back must come back at the SAME address. Allocating afresh
|
|
362
|
+
// moved it from :3382 to :3000 on the `up` after a `down` -- so every bookmark, every
|
|
363
|
+
// curl in a ticket and the URL the user had just been shown all pointed at nothing.
|
|
364
|
+
job.recorded = before === null ? 0 : Number(before.hostPort) || 0;
|
|
365
|
+
job.wasPinned = before !== null && isTruthy(before.pinned);
|
|
366
|
+
const publicMonitoring = Boolean(job.req.https || job.req.domain || job.req.acmeEmail) ||
|
|
367
|
+
(job.req.monitor && (await tlsplan.tlsFromRecord(job.reproName)) !== null);
|
|
368
|
+
// The side UIs' forwards, and the local Grafana's: preferred first, the next free port when
|
|
369
|
+
// another workspace holds one. A re-up keeps what its record holds -- its own live forwards
|
|
370
|
+
// hold those ports -- so its manifests render the same labels and nothing rolls.
|
|
371
|
+
const claim = await ports.claimSidePorts(job.reproName, requestedPreset(job), (given) => requestedPreset(job, given), {
|
|
372
|
+
monitoring: job.req.monitor && !publicMonitoring ? ['grafana'] : [],
|
|
373
|
+
reserve: job.req.port ? [job.req.port] : [],
|
|
374
|
+
});
|
|
375
|
+
for (const [whose, was, now] of claim.moved) {
|
|
376
|
+
(0, events_1.warn)(job.emit, `${whose}'s port ${String(was)} is claimed by another workspace now, so ` +
|
|
377
|
+
`'${job.reproName}' forwards it on ${String(now)}`, { phase: 'plan' });
|
|
378
|
+
}
|
|
379
|
+
job.sidePorts = claim.side;
|
|
380
|
+
job.monitoringPorts = claim.monitoring;
|
|
381
|
+
const pre = claim.pre;
|
|
382
|
+
// CHECKED, as Compose checks it, before anything is made. A port given here was taken on
|
|
383
|
+
// trust: the whole workspace deployed, the forward then found the port held, and `up`
|
|
384
|
+
// ended exit 8 with the workspace left running. The workspace's own recorded port stays
|
|
385
|
+
// its own (`pickHostPort` excludes it), so a re-up is not refused by its live forward.
|
|
386
|
+
job.hostPort = await ports.pickHostPort(job.req.port || job.recorded, {
|
|
387
|
+
...pre,
|
|
388
|
+
// This runtime publishes one application forward, independent of chart replicas.
|
|
389
|
+
instances: 1,
|
|
390
|
+
ports: [...pre.ports, ...job.monitoringPorts],
|
|
391
|
+
}, job.reproName);
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Resolve the actual scenario once, including ports added by its parameters: on the registry's
|
|
395
|
+
* ports, which side ports are allocated from, until `ports` -- the ones allocated -- rebuilds it.
|
|
396
|
+
*/
|
|
397
|
+
function requestedPreset(job, ports) {
|
|
398
|
+
if (job.presetForNotes !== null && ports === undefined)
|
|
399
|
+
return job.presetForNotes;
|
|
400
|
+
const names = (0, composite_1.namesOf)(job.req.preset || 'default');
|
|
401
|
+
if (names.length > 1) {
|
|
402
|
+
job.presetParams = request.paramsByPreset(names, job.req.params);
|
|
403
|
+
job.presetForNotes = presets.loadMany(names, job.presetParams, topology.KUBERNETES, new Set(Object.keys(job.envOverrides)), ports ?? {});
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
job.presetForNotes = presets.resolve(job.req.preset || 'default', topology.KUBERNETES, job.req.params, ports ?? {});
|
|
407
|
+
request.refuseUnknownParams(job.req.params, job.presetForNotes, job.req.preset || 'default');
|
|
408
|
+
}
|
|
409
|
+
return job.presetForNotes;
|
|
410
|
+
}
|
|
411
|
+
/** How this workspace is reached and what shape it is, in Compose's own order. */
|
|
412
|
+
function settleAddressing(job) {
|
|
413
|
+
// Same resolution order Compose uses: the flag, then the box-level config, then
|
|
414
|
+
// loopback. This was dropped entirely on the Kubernetes path.
|
|
415
|
+
job.cfg = config.loadConfig();
|
|
416
|
+
job.regToken = job.req.regToken || (0, format_1.toText)(job.cfg.reg_token);
|
|
417
|
+
if (job.req.bind)
|
|
418
|
+
job.bindHost = String(job.req.bind);
|
|
419
|
+
else if (isTruthy(job.cfg.bind_host))
|
|
420
|
+
job.bindHost = String(job.cfg.bind_host);
|
|
421
|
+
else
|
|
422
|
+
job.bindHost = config.DEFAULT_BIND_HOST;
|
|
423
|
+
// Where the forward listens: loopback, unless one other address was asked for.
|
|
424
|
+
job.root = `http://${request.callHost(job.bindHost)}:${String(job.hostPort)}`;
|
|
425
|
+
job.microservices = job.req.deployment === topology.MICROSERVICES;
|
|
426
|
+
// Allocation, deployment and notes share the same resolved scenario.
|
|
427
|
+
requestedPreset(job);
|
|
428
|
+
const names = (0, composite_1.namesOf)(job.req.preset || 'default');
|
|
429
|
+
const premium = request.premiumAuthWarning(names, job.resolved?.rcVersion ?? '', job.licensed, job.regToken);
|
|
430
|
+
if (premium !== '')
|
|
431
|
+
(0, events_1.warn)(job.emit, premium, { phase: 'plan' });
|
|
432
|
+
const voice = request.voiceLicenceWarning(names, job.licensed, job.regToken);
|
|
433
|
+
if (voice !== '')
|
|
434
|
+
(0, events_1.warn)(job.emit, voice, { phase: 'plan' });
|
|
435
|
+
const samlEmail = request.samlEmailWarning(job.presetForNotes, job.resolved?.rcVersion ?? '', new Set(Object.keys(job.envOverrides)));
|
|
436
|
+
if (samlEmail !== '')
|
|
437
|
+
(0, events_1.warn)(job.emit, samlEmail, { phase: 'plan' });
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* A directory served over LDAPS or StartTLS: its certificate, as a Secret beside it. (Its side
|
|
441
|
+
* ports were given in `resolvePairing`, which this runtime port-forwards on this machine.)
|
|
442
|
+
*/
|
|
443
|
+
async function certifyTheDirectory(job) {
|
|
444
|
+
const pre = job.presetForNotes;
|
|
445
|
+
if (pre.extra.directory_tls !== undefined) {
|
|
446
|
+
job.presetForNotes = (0, ldap_1.withCertificate)(pre, await tlsplan.issueDirectoryCertificate((0, ldap_1.directoryHost)(pre.extra)), topology.KUBERNETES);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Which cluster, what it would cost, and whether this box has the tools to talk to it.
|
|
451
|
+
*
|
|
452
|
+
* THE CLUSTER IS CHOSEN FIRST, before a single byte is written. `planCluster` only probes,
|
|
453
|
+
* and it is what refuses when there is no cluster and no `kind` -- so that refusal now
|
|
454
|
+
* costs nothing, where before it left an `incomplete` record that `list` showed as a
|
|
455
|
+
* workspace and whose port `usedPorts()` went on reserving.
|
|
456
|
+
*
|
|
457
|
+
* THE CORE TOOLS FIRST, before anything is provisioned: with `kubectl` absent, `up` built
|
|
458
|
+
* an entire kind cluster, THEN failed, and blamed the API server.
|
|
459
|
+
*/
|
|
460
|
+
async function planClusterStep(job) {
|
|
461
|
+
job.pre = await (0, probe_1.preflight)();
|
|
462
|
+
const missing = (0, tools_1.missingTools)(job.pre);
|
|
463
|
+
if (missing.length > 0) {
|
|
464
|
+
throw new errors_1.PreflightError(`${missing.join(', ')} is not installed, and a Kubernetes ` +
|
|
465
|
+
'workspace cannot be created or used without it. Install it and try ' +
|
|
466
|
+
'again — `houston doctor` lists what this runtime needs.');
|
|
467
|
+
}
|
|
468
|
+
job.plan = await (0, context_1.planCluster)(request.reqContext(job.req));
|
|
469
|
+
// A BILLABLE CLUSTER AND NO PUBLIC NAME. Warned, not refused, and the distinction
|
|
470
|
+
// matters: a refusal would remove the one way to reach a workspace whose ingress is
|
|
471
|
+
// broken, which is exactly when somebody needs it.
|
|
472
|
+
if (types_1.BILLABLE_DISTRIBUTIONS.includes(job.plan.distribution) && !(job.req.domain || '').trim()) {
|
|
473
|
+
(0, events_1.warn)(job.emit, `'${job.plan.context}' is a ${job.plan.distribution} cluster, and without --domain ` +
|
|
474
|
+
'this workspace opens only in a browser on the machine running houston, through a ' +
|
|
475
|
+
'port-forward that ends when its pod restarts. ' +
|
|
476
|
+
'`--domain <name>` gives it a publicly-trusted address instead.', { phase: 'preflight' });
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
/** The HTTPS name, and which of the two mechanisms will serve it. */
|
|
480
|
+
async function planTls(job) {
|
|
481
|
+
job.tlsspec = await tlsplan.resolveTls(job.req, job.reproName, job.bindHost, job.reproName, job.emit);
|
|
482
|
+
job.ktls = null;
|
|
483
|
+
if (job.plan !== null && !job.plan.create) {
|
|
484
|
+
// THE PREFLIGHT NEEDS A KUBECONFIG THAT KNOWS THIS CONTEXT, and on a fresh
|
|
485
|
+
// HOUSTON_HOME it does not have one: the cluster exists, so nothing was created, so
|
|
486
|
+
// nothing exported the context this is about to ask through. Idempotent, and a no-op
|
|
487
|
+
// for a cluster houston did not make.
|
|
488
|
+
await (0, cluster_1.ensureKubeconfig)(job.plan, job.emit);
|
|
489
|
+
// HELM'S OWN ANSWER, and this is the cheapest refusal on the path. houston drives
|
|
490
|
+
// kubectl AND helm, they resolve their configuration differently, and only kubectl was
|
|
491
|
+
// ever asked. Measured: kubectl completely happy while helm refused every call with
|
|
492
|
+
// `x509: certificate signed by unknown authority`, so the create built a namespace, a
|
|
493
|
+
// StatefulSet, a PersistentVolume and an initiated replica set, spent four minutes,
|
|
494
|
+
// then died at the chart and rolled all of it back.
|
|
495
|
+
const helmWhy = await (0, reachability_1.helmReachable)(job.plan.context);
|
|
496
|
+
if (helmWhy) {
|
|
497
|
+
throw new errors_1.ValidationError(`helm cannot reach cluster '${job.plan.context}', although kubectl can. ` +
|
|
498
|
+
'The chart install would fail after MongoDB and roll the whole ' +
|
|
499
|
+
`workspace back. helm said: ${helmWhy} — a kubeconfig left over ` +
|
|
500
|
+
'from a previous install of the same cluster does this. Regenerate ' +
|
|
501
|
+
'it (k3s: `sudo cat /etc/rancher/k3s/k3s.yaml > ~/.kube/config`; ' +
|
|
502
|
+
'kind: `kind export kubeconfig --name <cluster>`) and run this ' +
|
|
503
|
+
'again. `houston doctor` reports the same thing.');
|
|
504
|
+
}
|
|
505
|
+
await (0, namespace_1.assertNamespaceAvailable)(job.reproName, {
|
|
506
|
+
context: job.plan.context,
|
|
507
|
+
owner: job.req.actor,
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
/** What the in-cluster ingress needs, when the edge is not the thing serving the name. */
|
|
512
|
+
async function planKubeTls(job) {
|
|
513
|
+
if (job.tlsspec !== null) {
|
|
514
|
+
// Named before the probing starts. `kubernetesTlsPlan` asks the cluster about its
|
|
515
|
+
// ingress classes, its cert-manager CRD and its ingress endpoint before it emits
|
|
516
|
+
// anything, which on a managed cluster is several seconds of nothing at the exact
|
|
517
|
+
// moment the reader is waiting to learn where HTTPS is coming from.
|
|
518
|
+
(0, events_1.info)(job.emit, `checking ${job.plan?.context ?? ''} for the ingress and cert-manager HTTPS ` + 'needs', { phase: 'tls' });
|
|
519
|
+
// AFTER `ensureKubeconfig`, because every probe in it needs a kubeconfig that knows
|
|
520
|
+
// the context, and BEFORE the write-ahead record, because a refusal must leave
|
|
521
|
+
// nothing.
|
|
522
|
+
job.ktls = await tlsplan.kubernetesTlsPlan(job.req, job.tlsspec, job.plan, {
|
|
523
|
+
emit: job.emit,
|
|
524
|
+
});
|
|
525
|
+
// A preset's own UIs at paths of that name; `installChart` routes them with an Ingress.
|
|
526
|
+
if (job.presetForNotes !== null) {
|
|
527
|
+
job.presetForNotes = (0, public_1.withPublicUrl)(job.presetForNotes, `https://${job.ktls.host}`, topology.KUBERNETES);
|
|
528
|
+
const presigned = (0, public_1.presignedOverHttps)(job.presetForNotes);
|
|
529
|
+
if (presigned)
|
|
530
|
+
(0, events_1.warn)(job.emit, presigned, { phase: 'tls' });
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
/** A record BEFORE any cluster resource exists, so a killed create leaves something. */
|
|
535
|
+
async function writeProvisionalRecord(job) {
|
|
536
|
+
// A WRITE-AHEAD RECORD, before a single cluster resource exists. `createWorkspace`
|
|
537
|
+
// below builds the namespace, MongoDB, the chart release, the scenario's manifests and
|
|
538
|
+
// the port-forward -- minutes of work -- and only after it returned was anything written
|
|
539
|
+
// down. Kill the process in that window and the workspace is left fully running with NO
|
|
540
|
+
// record: invisible to `list`, `info` and `down`. Two such orphans were found holding
|
|
541
|
+
// several GB between them.
|
|
542
|
+
// A workspace brought back keeps its PersistentVolumeClaim, so its database's password too.
|
|
543
|
+
const kept = job.reused ? await (0, record_1.keptAdminPassword)(job.reproName) : null;
|
|
544
|
+
const reachable = preconditions.reachableBeyondLoopback({
|
|
545
|
+
tlsspec: job.tlsspec,
|
|
546
|
+
bindHost: job.bindHost,
|
|
547
|
+
});
|
|
548
|
+
job.adminPassword = kept ?? (reachable ? config.generateAdminPassword() : '');
|
|
549
|
+
const shared = request.keptSharedPasswordWarning(job.reproName, kept, reachable);
|
|
550
|
+
if (shared !== '')
|
|
551
|
+
(0, events_1.warn)(job.emit, shared, { phase: 'plan' });
|
|
552
|
+
const resolved = job.resolved;
|
|
553
|
+
const plan = job.plan;
|
|
554
|
+
job.provisional = (0, record_1.metadata)({
|
|
555
|
+
name: job.reproName,
|
|
556
|
+
project: await (0, namespace_1.namespaceFor)(job.reproName),
|
|
557
|
+
rcVersion: resolved.rcVersion,
|
|
558
|
+
rcImage: resolved.rcImage,
|
|
559
|
+
mongoTag: resolved.mongoTag,
|
|
560
|
+
mongoFlavor: resolved.mongoFlavor,
|
|
561
|
+
preset: job.req.preset,
|
|
562
|
+
rootUrl: job.root,
|
|
563
|
+
hostPort: job.hostPort,
|
|
564
|
+
versionSource: resolved.source,
|
|
565
|
+
pinned: job.req.pin || job.wasPinned,
|
|
566
|
+
adminPassword: job.adminPassword,
|
|
567
|
+
createdAt: bornAt(job.previousMeta),
|
|
568
|
+
});
|
|
569
|
+
topology.stamp(job.provisional.extra, topology.KUBERNETES);
|
|
570
|
+
job.provisional.extra[config.EXTRA_DEPLOYMENT] = job.req.deployment || topology.MICROSERVICES;
|
|
571
|
+
job.provisional.extra.namespace = await (0, namespace_1.namespaceFor)(job.reproName);
|
|
572
|
+
if (job.namespaceIdentity !== null) {
|
|
573
|
+
job.provisional.extra.namespace_owner = job.namespaceIdentity.owner;
|
|
574
|
+
if (job.namespaceIdentity.uid !== '') {
|
|
575
|
+
job.provisional.extra.namespace_uid = job.namespaceIdentity.uid;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
// The chosen context, not a guess at it. This was `CONTEXT` unconditionally, which was
|
|
579
|
+
// right only while houston's own cluster was the only one it could use.
|
|
580
|
+
job.provisional.extra[config.EXTRA_CONTEXT] = plan.context;
|
|
581
|
+
job.provisional.extra.distribution = plan.distribution;
|
|
582
|
+
// A RE-UP OF A FINISHED WORKSPACE IS NOT A HALF-MADE ONE. Marked incomplete, a re-up that
|
|
583
|
+
// failed left the flag behind, and the next `up` skipped the checks that keep a workspace's
|
|
584
|
+
// version, MongoDB and presets -- the ones a half-made workspace has nothing to keep for.
|
|
585
|
+
job.provisional.extra.incomplete =
|
|
586
|
+
job.previousMeta === null || job.previousMeta.extra.incomplete === true;
|
|
587
|
+
if (job.req.actor)
|
|
588
|
+
job.provisional.extra.created_by = job.req.actor;
|
|
589
|
+
// In the write-ahead record too: a re-up after a killed create carries forward from it.
|
|
590
|
+
if (Object.keys(job.envOverrides).length > 0)
|
|
591
|
+
job.provisional.extra.env = job.envOverrides;
|
|
592
|
+
if (job.licensed)
|
|
593
|
+
job.provisional.extra.licensed = true;
|
|
594
|
+
// Still recorded while the create runs, so a create killed part-way leaves `down` able to
|
|
595
|
+
// stop them.
|
|
596
|
+
if (job.previous.pid !== 0)
|
|
597
|
+
job.provisional.extra.port_forward_pid = job.previous.pid;
|
|
598
|
+
if (Object.keys(job.previous.scenarioForwards).length > 0) {
|
|
599
|
+
job.provisional.extra.scenario_forwards = job.previous.scenarioForwards;
|
|
600
|
+
}
|
|
601
|
+
// Claimed from the write-ahead record on, so a concurrent create sees them.
|
|
602
|
+
const sidePorts = job.presetForNotes.ports;
|
|
603
|
+
if (sidePorts.length > 0)
|
|
604
|
+
job.provisional.extra.sidecar_ports = sidePorts;
|
|
605
|
+
if (Object.keys(job.sidePorts).length > 0)
|
|
606
|
+
job.provisional.extra.side_ports = job.sidePorts;
|
|
607
|
+
if (job.monitoringPorts.length > 0) {
|
|
608
|
+
job.provisional.extra.monitoring_ports = [...job.monitoringPorts];
|
|
609
|
+
}
|
|
610
|
+
ownership.carryOwnership(job.previousMeta, job.provisional);
|
|
611
|
+
// Through the runner seam, so the workspace directory is restricted to 0700 the way
|
|
612
|
+
// every Compose one is. This runtime is the one that also writes `kubernetes/values.yaml`
|
|
613
|
+
// with ADMIN_PASS in it.
|
|
614
|
+
await (0, record_1.writeRecord)(job.reproName, job.provisional);
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* The name on the edge, BEFORE the create, so an ACME challenge has somewhere to land the
|
|
618
|
+
* moment the chart's Ingress appears. Inside the create's rollback: the edge refusing to
|
|
619
|
+
* start (another home's edge holds :443) left the write-ahead record of a workspace that
|
|
620
|
+
* never existed, and the retry reused it.
|
|
621
|
+
*/
|
|
622
|
+
async function routeTheName(job) {
|
|
623
|
+
if (job.ktls === null)
|
|
624
|
+
return;
|
|
625
|
+
job.routeIntroduced = (0, routes_1.routeHost)(job.reproName) === '';
|
|
626
|
+
await tlsplan.routeKubernetesName(job.reproName, job.ktls, { emit: job.emit });
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* A failed create takes back the edge route it registered, as the cluster side takes back
|
|
630
|
+
* the namespace. The route goes in BEFORE the create, so an ACME challenge has somewhere to
|
|
631
|
+
* land; left behind, it sent the name to a NodePort the rollback had already deleted
|
|
632
|
+
* (measured on a k3s playground, 2026-10-06). The record stays, as it always has, so
|
|
633
|
+
* `list` and `down` still find the workspace; a route that was there before this create --
|
|
634
|
+
* a workspace being re-created -- stays too.
|
|
635
|
+
*/
|
|
636
|
+
function forgetTheRouteThisCreateMade(job) {
|
|
637
|
+
if (job.ktls === null || !job.routeIntroduced || (0, routes_1.routeHost)(job.reproName) === '')
|
|
638
|
+
return;
|
|
639
|
+
(0, routes_1.deregister)(job.reproName);
|
|
640
|
+
(0, events_1.warn)(job.emit, `create failed — removing the edge route for ${job.ktls.host}`, {
|
|
641
|
+
phase: 'teardown',
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* A fresh create that left no namespace leaves no record either.
|
|
646
|
+
*
|
|
647
|
+
* The rollback removes the namespace a failed or stopped create made, and the write-ahead
|
|
648
|
+
* record stayed: a "down" workspace that claimed its port and its preset's side ports --
|
|
649
|
+
* the next create wanting 8025 was refused for it -- and whose panel said its data volume
|
|
650
|
+
* was "still here". Nothing was. A workspace coming back keeps its record; so does one whose
|
|
651
|
+
* namespace survived, or could not be asked about.
|
|
652
|
+
*/
|
|
653
|
+
async function forgetARecordWithNothingBehindIt(job) {
|
|
654
|
+
if (job.reused || job.plan === null)
|
|
655
|
+
return;
|
|
656
|
+
let labels;
|
|
657
|
+
try {
|
|
658
|
+
labels = await (0, namespace_1.namespaceLabels)(await (0, namespace_1.namespaceFor)(job.reproName), {
|
|
659
|
+
context: job.plan.context,
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
catch {
|
|
663
|
+
return; // could not ask: the record stays, and says what it knows
|
|
664
|
+
}
|
|
665
|
+
if (labels !== null)
|
|
666
|
+
return;
|
|
667
|
+
await (0, paths_1.remove)(job.reproName);
|
|
668
|
+
(0, events_1.warn)(job.emit, `nothing of '${job.reproName}' was left in the cluster, so its record goes too — ` +
|
|
669
|
+
'its ports are free again', { phase: 'teardown', code: events_1.NOTHING_LEFT });
|
|
670
|
+
}
|
|
671
|
+
/** The namespace, MongoDB, the chart release and the port-forward -- the long part. */
|
|
672
|
+
async function createTheWorkspace(job) {
|
|
673
|
+
const ns = await (0, namespace_1.namespaceFor)(job.reproName);
|
|
674
|
+
// The preset UIs' forwards are re-made below; the old ones would keep their ports.
|
|
675
|
+
for (const [port, pid] of Object.entries(job.previous.scenarioForwards)) {
|
|
676
|
+
await (0, forward_1.stopForward)(Number(pid) || 0, { namespace: ns, hostPort: Number(port) || null });
|
|
677
|
+
}
|
|
678
|
+
const resolved = job.resolved;
|
|
679
|
+
job.out = await (0, workspace_1.createWorkspace)({
|
|
680
|
+
name: job.reproName,
|
|
681
|
+
resolved,
|
|
682
|
+
hostPort: job.hostPort,
|
|
683
|
+
microservices: job.microservices,
|
|
684
|
+
replicas: job.req.replicas || 1,
|
|
685
|
+
owner: job.req.actor,
|
|
686
|
+
bindHost: job.bindHost,
|
|
687
|
+
adminPassword: job.adminPassword,
|
|
688
|
+
previousPid: job.previous.pid,
|
|
689
|
+
previousPort: job.previous.port,
|
|
690
|
+
// PASSED AT LAST. `createWorkspace` has taken `rootUrl` since it was written and this
|
|
691
|
+
// call never supplied it, so `valuesFor` never set anything and the chart emitted no
|
|
692
|
+
// ROOT_URL -- Rocket.Chat ran on its own default while every human reached it here.
|
|
693
|
+
rootUrl: job.root,
|
|
694
|
+
// With a name, the chart's own Ingress template builds the Ingress -- houston
|
|
695
|
+
// hand-writes none.
|
|
696
|
+
tlsHost: job.ktls?.host ?? '',
|
|
697
|
+
ingressClass: job.ktls?.ingressClass ?? '',
|
|
698
|
+
issuer: job.ktls?.issuer ?? null,
|
|
699
|
+
useOperator: job.req.mongoOperator,
|
|
700
|
+
// Through a Secret referenced by `valueFrom`, never as a values literal: `helm get
|
|
701
|
+
// values` is readable by anyone who can reach the release.
|
|
702
|
+
regToken: job.regToken,
|
|
703
|
+
// Resolved through the KUBERNETES adapter, so a scenario yields native manifests here
|
|
704
|
+
// and a compose service on the other runtime -- one intent, two renderings.
|
|
705
|
+
preset: job.presetForNotes,
|
|
706
|
+
envOverrides: job.envOverrides,
|
|
707
|
+
license: job.req.license,
|
|
708
|
+
licensed: job.licensed,
|
|
709
|
+
plan: job.plan,
|
|
710
|
+
emit: job.emit,
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
/** `repro.json` as it stands once the cluster has answered. */
|
|
714
|
+
async function buildRecord(job) {
|
|
715
|
+
const resolved = job.resolved;
|
|
716
|
+
const plan = job.plan;
|
|
717
|
+
job.meta = (0, record_1.metadata)({
|
|
718
|
+
name: job.reproName,
|
|
719
|
+
project: String(job.out.namespace ?? ''),
|
|
720
|
+
rcVersion: resolved.rcVersion,
|
|
721
|
+
rcImage: resolved.rcImage,
|
|
722
|
+
mongoTag: resolved.mongoTag,
|
|
723
|
+
// NOT `resolved.mongoFlavor`. That is a COMPOSE concept -- "official" vs
|
|
724
|
+
// "bitnami-legacy" -- and this runtime honours neither: `createWorkspace` records
|
|
725
|
+
// `mongo_managed_by` and `mongo_image` for exactly this reason.
|
|
726
|
+
mongoFlavor: '',
|
|
727
|
+
preset: job.req.preset,
|
|
728
|
+
rootUrl: job.root,
|
|
729
|
+
hostPort: job.hostPort,
|
|
730
|
+
versionSource: resolved.source,
|
|
731
|
+
pinned: job.req.pin || job.wasPinned,
|
|
732
|
+
adminPassword: job.adminPassword,
|
|
733
|
+
createdAt: bornAt(job.previousMeta),
|
|
734
|
+
});
|
|
735
|
+
// The preset's own record fields -- `mailpit_url`, which `admin.login` reads to fetch an
|
|
736
|
+
// email-2FA code, so without it every login to an email workspace here failed at 2FA.
|
|
737
|
+
// BEFORE the runtime's stamps, so a preset cannot overwrite them.
|
|
738
|
+
const pre = job.presetForNotes;
|
|
739
|
+
Object.assign(job.meta.extra, pre.extra);
|
|
740
|
+
if (pre.ports.length > 0)
|
|
741
|
+
job.meta.extra.sidecar_ports = pre.ports;
|
|
742
|
+
// Only what moved, in BOTH records: a re-up reads it back to render the same labels.
|
|
743
|
+
if (Object.keys(job.sidePorts).length > 0)
|
|
744
|
+
job.meta.extra.side_ports = job.sidePorts;
|
|
745
|
+
if (job.monitoringPorts.length > 0) {
|
|
746
|
+
job.meta.extra.monitoring_ports = [...job.monitoringPorts];
|
|
747
|
+
}
|
|
748
|
+
topology.stamp(job.meta.extra, topology.KUBERNETES);
|
|
749
|
+
job.meta.extra[config.EXTRA_DEPLOYMENT] = job.req.deployment || topology.MICROSERVICES;
|
|
750
|
+
for (const [key, value] of Object.entries(job.out)) {
|
|
751
|
+
if (key !== 'microservices')
|
|
752
|
+
job.meta.extra[key] = value;
|
|
753
|
+
}
|
|
754
|
+
// WHAT kind of cluster this workspace lives in. A label, never a branch -- it is what
|
|
755
|
+
// lets `doctor`, the notes and a support case say "k3s" instead of leaving a reader to
|
|
756
|
+
// infer it from a context name.
|
|
757
|
+
job.meta.extra.distribution = plan.distribution;
|
|
758
|
+
if (job.ktls !== null) {
|
|
759
|
+
// The SAME three fields the Compose path records, so `list`, `info`, `reproLinks`, the
|
|
760
|
+
// GUI grid and `tls-status` all work on a Kubernetes workspace for free. `rootUrl`
|
|
761
|
+
// deliberately stays the plain http port-forward URL; `publicUrl` is what a human opens.
|
|
762
|
+
job.meta.publicUrl = `https://${job.ktls.host}`;
|
|
763
|
+
job.meta.extra.tls = job.ktls.issuer?.mode === 'acme' ? tls_1.MODE_ACME : 'local';
|
|
764
|
+
if (job.ktls.issuer?.mode === 'acme') {
|
|
765
|
+
job.meta.extra.tls_staging = Boolean(job.ktls.issuer.acmeStaging);
|
|
766
|
+
job.meta.extra.tls_email = job.ktls.issuer.acmeEmail ?? '';
|
|
767
|
+
}
|
|
768
|
+
// `edge` means "a route file speaks for this name". It is what `noteGroupsOf` keys the
|
|
769
|
+
// HTTPS card on, and it is false in the topology where the cluster holds :443 itself
|
|
770
|
+
// and no edge is involved at all.
|
|
771
|
+
job.meta.extra.edge = (0, spec_1.installed)();
|
|
772
|
+
// Where TLS actually terminates, which is the one thing genuinely different from
|
|
773
|
+
// Compose: the certificate is a cluster Secret issued by cert-manager, not a file the
|
|
774
|
+
// edge loaded.
|
|
775
|
+
job.meta.extra.tls_terminates = 'cluster';
|
|
776
|
+
job.meta.extra.ingress_endpoint = (0, endpoints_1.endpointString)(job.ktls.endpoint);
|
|
777
|
+
job.meta.extra.ingress_class = job.ktls.ingressClass;
|
|
778
|
+
// `certificate_ready` decides how a fallback certificate is EXPLAINED. It was computed
|
|
779
|
+
// here all along and thrown away, so the check that reports the result did not know
|
|
780
|
+
// whether one had ever been issued.
|
|
781
|
+
await tlsplan.publishKubernetesName(job.reproName, job.ktls, {
|
|
782
|
+
certReady: Boolean(job.out.certificate_ready),
|
|
783
|
+
emit: job.emit,
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
/** What was ASKED for, so the workspace can be rebuilt exactly as it was. */
|
|
788
|
+
function recordTheRequest(job) {
|
|
789
|
+
const meta = job.meta;
|
|
790
|
+
if (job.req.replicas > 1)
|
|
791
|
+
meta.extra.instances = job.req.replicas;
|
|
792
|
+
if (job.req.actor)
|
|
793
|
+
meta.extra.created_by = job.req.actor;
|
|
794
|
+
// Recorded so the notes can be REBUILT from the record rather than read back out of it
|
|
795
|
+
// -- a dynamic scenario's prose is a function of its params, and nothing was keeping them.
|
|
796
|
+
if (job.presetParams !== null) {
|
|
797
|
+
// As Compose records a composed workspace: one preset string, the list and its params.
|
|
798
|
+
meta.extra.presets = (0, composite_1.namesOf)(job.req.preset);
|
|
799
|
+
meta.extra.preset_params = structuredClone(job.presetParams);
|
|
800
|
+
}
|
|
801
|
+
else if (Object.keys(job.req.params).length > 0) {
|
|
802
|
+
meta.extra.params = { ...job.req.params };
|
|
803
|
+
}
|
|
804
|
+
// The same key Compose records them under, so re-up, `backup` and `restore --new` carry them.
|
|
805
|
+
if (Object.keys(job.envOverrides).length > 0)
|
|
806
|
+
meta.extra.env = job.envOverrides;
|
|
807
|
+
if (job.licensed)
|
|
808
|
+
meta.extra.licensed = true;
|
|
809
|
+
// A preset's self-configuration actions, recorded exactly as the Compose path records
|
|
810
|
+
// them. Without this the OIDC preset would create no OAuth provider and the SAML preset
|
|
811
|
+
// no provider settings -- both recorded and neither applied.
|
|
812
|
+
const postReady = job.presetForNotes?.postReady;
|
|
813
|
+
if (postReady !== undefined && postReady.length > 0)
|
|
814
|
+
meta.extra.post_ready = postReady;
|
|
815
|
+
ownership.carryOwnership(job.provisional ?? job.previousMeta, meta);
|
|
816
|
+
}
|
|
817
|
+
/** The notes a reader needs, then the record -- and no compose file, because it is not one. */
|
|
818
|
+
async function writeRecordStep(job) {
|
|
819
|
+
const meta = job.meta;
|
|
820
|
+
job.groups = await notes.noteGroupsOf(meta);
|
|
821
|
+
// THE GROUPS ARE NOT PERSISTED. They are rendered presentation -- roughly 5.5 KB of a
|
|
822
|
+
// 6.4 KB Kubernetes record, the same content as `notes` a second time, and including an
|
|
823
|
+
// absolute `export KUBECONFIG=<home>/clients/kubernetes/config` that is wrong the moment
|
|
824
|
+
// the home moves.
|
|
825
|
+
delete meta.extra.note_groups;
|
|
826
|
+
// Derived, never written twice: the CLI and every workspace record made before groups
|
|
827
|
+
// existed read this.
|
|
828
|
+
meta.extra.notes = notes.flattenNotes(job.groups);
|
|
829
|
+
// No compose document, so an empty one rather than a fake: a file that looks like a
|
|
830
|
+
// compose project but is not would be worse than none.
|
|
831
|
+
const ws = (0, paths_1.workspace)(job.reproName);
|
|
832
|
+
await fs.mkdir(ws, { recursive: true });
|
|
833
|
+
// `serialise(meta)`, as every record is written: the record's one spelling, not
|
|
834
|
+
// JSON.stringify's.
|
|
835
|
+
await (0, paths_1.atomicWrite)((0, home_1.joinPath)(ws, 'repro.json'), (0, record_1.serialise)(meta));
|
|
836
|
+
}
|
|
837
|
+
/** Waiting, seeding, monitoring, and the line the caller reads at the end. */
|
|
838
|
+
async function finish(job) {
|
|
839
|
+
const meta = job.meta;
|
|
840
|
+
job.result = {
|
|
841
|
+
name: job.reproName,
|
|
842
|
+
meta: (0, record_1.toDocument)(meta),
|
|
843
|
+
url: job.root,
|
|
844
|
+
// The two a caller opens, as the Compose create's summary names them: the GUI's create
|
|
845
|
+
// dialog offered no address at all for a Kubernetes workspace, and `up --json` none to
|
|
846
|
+
// a script.
|
|
847
|
+
root_url: meta.rootUrl,
|
|
848
|
+
public_url: meta.publicUrl,
|
|
849
|
+
open_url: (0, record_1.externalUrl)(meta),
|
|
850
|
+
reused: job.reused,
|
|
851
|
+
runtime: topology.KUBERNETES,
|
|
852
|
+
};
|
|
853
|
+
// A preset with post_ready actions MUST wait, or there is nothing to configure against.
|
|
854
|
+
if (job.req.wait || job.req.seed || isTruthy(meta.extra.post_ready)) {
|
|
855
|
+
// waitAndFinalize, not bare waitServing: it also finalizes the setup wizard over REST
|
|
856
|
+
// and runs the preset's post_ready actions. Waiting and stopping there left every
|
|
857
|
+
// self-configuring preset half-applied.
|
|
858
|
+
Object.assign(job.result, await (0, ready_1.waitAndFinalize)(meta, job.emit, 600.0, false));
|
|
859
|
+
job.result.ready = true;
|
|
860
|
+
}
|
|
861
|
+
// NOT when the caller seeds. `seedHere` means the CLI runs it after this returns, so
|
|
862
|
+
// seeding here as well would seed the workspace twice.
|
|
863
|
+
if (job.req.seed && !job.req.seedHere) {
|
|
864
|
+
job.result.seed = await seeding.runSeedInline(meta, job.req.seedProfile, job.req.stats, job.emit, { scenarios: job.req.seedScenarios, historyDays: job.req.seedHistoryDays });
|
|
865
|
+
}
|
|
866
|
+
// `--monitor` last, and only once the workspace is serving: attaching turns on RC's own
|
|
867
|
+
// Prometheus_Enabled over REST, which needs a workspace that answers.
|
|
868
|
+
if (job.req.monitor) {
|
|
869
|
+
if (!(job.req.wait || job.req.seed)) {
|
|
870
|
+
await (0, ready_1.waitServing)(meta, job.emit, 600.0);
|
|
871
|
+
}
|
|
872
|
+
// An add-on failing does not un-create the workspace. The first live run of this
|
|
873
|
+
// failed on the monitoring chart and exited 7 with the workspace up, serving, and
|
|
874
|
+
// listed as running -- a create reported as failed while its result was sitting there
|
|
875
|
+
// working.
|
|
876
|
+
try {
|
|
877
|
+
job.result.monitoring = await job.monitorAttach(job.reproName, job.emit);
|
|
878
|
+
}
|
|
879
|
+
catch (error) {
|
|
880
|
+
if (!(error instanceof errors_1.ReproError))
|
|
881
|
+
throw error;
|
|
882
|
+
(0, events_1.warn)(job.emit, `the workspace is up, but monitoring did not attach: ${error.message}`, {
|
|
883
|
+
phase: 'monitor',
|
|
884
|
+
});
|
|
885
|
+
(0, events_1.warn)(job.emit, `retry it with: houston monitor --name ${job.reproName}`, {
|
|
886
|
+
phase: 'monitor',
|
|
887
|
+
});
|
|
888
|
+
job.result.monitoring = { monitoring: false, error: error.message };
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
(0, events_1.info)(job.emit, `${job.root} admin / ${(0, record_1.adminPass)(meta)}`, { phase: 'done', pct: 100 });
|
|
892
|
+
return job.result;
|
|
893
|
+
}
|
|
894
|
+
/**
|
|
895
|
+
* The Kubernetes half of `createReproLocked`.
|
|
896
|
+
*
|
|
897
|
+
* Shares everything that is not runtime-specific -- name derivation, version resolution,
|
|
898
|
+
* the capacity refusal, host-port allocation, repro.json -- and delegates only the
|
|
899
|
+
* sequence that differs. A workspace created here is a workspace like any other: `list`,
|
|
900
|
+
* `info`, `logs` and `down` find it because it has a repro.json.
|
|
901
|
+
*/
|
|
902
|
+
async function createKubernetes(req, emit = events_1.nullEmit, { monitorAttach = request.missingMonitorAttach, versionFetcher, } = {}) {
|
|
903
|
+
const job = kubeCreate({
|
|
904
|
+
req,
|
|
905
|
+
emit,
|
|
906
|
+
monitorAttach,
|
|
907
|
+
...(versionFetcher === undefined ? {} : { versionFetcher }),
|
|
908
|
+
});
|
|
909
|
+
await settleName(job);
|
|
910
|
+
await settleEnv(job);
|
|
911
|
+
await ports.withPortPublication(async () => {
|
|
912
|
+
await resolvePairing(job);
|
|
913
|
+
settleAddressing(job);
|
|
914
|
+
// Before the cluster is probed or anything is written.
|
|
915
|
+
(0, e2ee_1.refuseEnforcedBefore880)(requestedPreset(job), job.resolved.rcVersion);
|
|
916
|
+
(0, voice_1.refuseVoiceBefore800)(requestedPreset(job), job.resolved.rcVersion);
|
|
917
|
+
await certifyTheDirectory(job);
|
|
918
|
+
await planClusterStep(job);
|
|
919
|
+
await planTls(job);
|
|
920
|
+
await planKubeTls(job);
|
|
921
|
+
await writeProvisionalRecord(job);
|
|
922
|
+
});
|
|
923
|
+
try {
|
|
924
|
+
await routeTheName(job);
|
|
925
|
+
await createTheWorkspace(job);
|
|
926
|
+
}
|
|
927
|
+
catch (error) {
|
|
928
|
+
forgetTheRouteThisCreateMade(job);
|
|
929
|
+
// As cleanup, so a stopped job's unwind runs it to the end, as the rollback does.
|
|
930
|
+
await (0, exec_1.cleanup)(async () => {
|
|
931
|
+
await forgetARecordWithNothingBehindIt(job);
|
|
932
|
+
});
|
|
933
|
+
throw error;
|
|
934
|
+
}
|
|
935
|
+
await buildRecord(job);
|
|
936
|
+
recordTheRequest(job);
|
|
937
|
+
await writeRecordStep(job);
|
|
938
|
+
return await finish(job);
|
|
939
|
+
}
|