@rocket.chat/houston 0.27.0-next.3 → 2.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +109 -15
- package/bin/houston +62 -0
- package/data/docs/ARCHITECTURE.md +387 -0
- package/data/docs/automation.md +107 -0
- package/data/docs/e2ee.md +76 -0
- package/data/docs/eks.md +258 -0
- package/data/docs/gui.md +282 -0
- package/data/docs/guide.md +642 -0
- package/data/docs/kubernetes.md +138 -0
- package/data/docs/loadtest.md +264 -0
- package/data/docs/troubleshooting.md +203 -0
- package/data/docs/upgrading.md +84 -0
- package/data/docs/voice.md +253 -0
- package/data/iam/engineer-policy.json +11 -0
- package/data/iam/engineer-rbac.yaml +42 -0
- package/data/iam/operator-policy.json +211 -0
- package/data/loadtest/badbot.js +22 -0
- package/data/loadtest/common.js +170 -0
- package/data/loadtest/custom.js +20 -0
- package/data/loadtest/journey.js +58 -0
- package/data/loadtest/login.js +18 -0
- package/data/loadtest/messages.js +13 -0
- package/data/loadtest/mixed.js +57 -0
- package/data/loadtest/read.js +12 -0
- package/data/loadtest/webhook.js +20 -0
- package/data/monitoring/houston-logs.json +98 -0
- package/data/monitoring/k6-loadtest.json +610 -0
- package/data/monitoring/mongodb-exporter.json +3007 -0
- package/data/monitoring/node-exporter-full.json +16114 -0
- package/data/monitoring/rocketchat-metrics.json +6471 -0
- package/data/presets/airgapped.yaml +16 -0
- package/data/presets/default.yaml +9 -0
- package/data/seed/avatar-0.png +0 -0
- package/data/seed/avatar-1.png +0 -0
- package/data/seed/avatar-2.png +0 -0
- package/data/seed/avatar-3.png +0 -0
- package/data/seed/avatar-4.png +0 -0
- package/data/seed/avatar-5.png +0 -0
- package/data/seed/avatar-6.png +0 -0
- package/data/seed/avatar-7.png +0 -0
- package/data/seed/seed-metrics.csv +3 -0
- package/data/seed/seed-preview.png +0 -0
- package/data/seed/seed-report.pdf +32 -0
- package/data/seed/seed-runbook.txt +3 -0
- package/data/skill/SKILL.md +399 -0
- package/data/versions.yaml +55 -0
- package/data/voice/freeswitch/drachtio.xml +52 -0
- package/data/voice/freeswitch/public.xml +87 -0
- package/data/webui/app.css +2003 -0
- package/data/webui/index.html +678 -0
- package/data/webui/js/api.js +561 -0
- package/data/webui/js/boot.js +44 -0
- package/data/webui/js/clusters-tail.js +1377 -0
- package/data/webui/js/clusters.js +896 -0
- package/data/webui/js/create.js +276 -0
- package/data/webui/js/detail.js +507 -0
- package/data/webui/js/jobs.js +636 -0
- package/data/webui/js/logs.js +634 -0
- package/data/webui/js/main.js +14 -0
- package/data/webui/js/options.js +408 -0
- package/data/webui/js/people.js +438 -0
- package/data/webui/js/perf.js +303 -0
- package/data/webui/js/render.js +438 -0
- package/data/webui/js/shared.js +3 -0
- package/data/webui/js/state.js +583 -0
- package/data/webui/js/theme.js +123 -0
- package/data/webui/js/util.js +584 -0
- package/dist/cli/app.js +593 -0
- package/dist/cli/capabilities.js +76 -0
- package/dist/cli/cell-widths.js +495 -0
- package/dist/cli/entry.js +10 -0
- package/dist/cli/error-panel.js +492 -0
- package/dist/cli/handlers/actor.js +84 -0
- package/dist/cli/handlers/https.js +614 -0
- package/dist/cli/handlers/prompt.js +299 -0
- package/dist/cli/handlers/users.js +226 -0
- package/dist/cli/handlers.js +3694 -0
- package/dist/cli/help.js +183 -0
- package/dist/cli/index.js +15 -0
- package/dist/cli/perf.js +814 -0
- package/dist/cli/render.js +254 -0
- package/dist/cli/serve.js +858 -0
- package/dist/cli/spec-data.js +2599 -0
- package/dist/cli/spec-types.js +8 -0
- package/dist/cli/usage-error.js +520 -0
- package/dist/cli/wire.js +70 -0
- package/dist/core/audit.js +346 -0
- package/dist/core/backup-compat.js +85 -0
- package/dist/core/backup.js +1639 -0
- package/dist/core/cluster.js +1398 -0
- package/dist/core/configimport.js +345 -0
- package/dist/core/data.js +267 -0
- package/dist/core/database-of.js +82 -0
- package/dist/core/diagnose.js +159 -0
- package/dist/core/doctor.js +1518 -0
- package/dist/core/edge/acme.js +338 -0
- package/dist/core/edge/engine.js +500 -0
- package/dist/core/edge/networks.js +174 -0
- package/dist/core/edge/paths.js +107 -0
- package/dist/core/edge/routes.js +251 -0
- package/dist/core/edge/routeyml.js +195 -0
- package/dist/core/edge/runtime.js +493 -0
- package/dist/core/edge/spec.js +305 -0
- package/dist/core/edge/types.js +202 -0
- package/dist/core/eks-docs.js +135 -0
- package/dist/core/eks.js +2240 -0
- package/dist/core/envvars.js +562 -0
- package/dist/core/eventlog.js +541 -0
- package/dist/core/firstrun.js +153 -0
- package/dist/core/journal.js +694 -0
- package/dist/core/kube/ask.js +231 -0
- package/dist/core/kube/capabilities.js +269 -0
- package/dist/core/kube/certmanager.js +452 -0
- package/dist/core/kube/chart.js +413 -0
- package/dist/core/kube/cluster.js +196 -0
- package/dist/core/kube/context.js +545 -0
- package/dist/core/kube/endpoints.js +448 -0
- package/dist/core/kube/exec.js +195 -0
- package/dist/core/kube/forward.js +732 -0
- package/dist/core/kube/grafana-ingress.js +110 -0
- package/dist/core/kube/ingress.js +218 -0
- package/dist/core/kube/manifests.js +361 -0
- package/dist/core/kube/monitoring.js +768 -0
- package/dist/core/kube/names.js +237 -0
- package/dist/core/kube/namespace.js +678 -0
- package/dist/core/kube/operator.js +941 -0
- package/dist/core/kube/probe.js +202 -0
- package/dist/core/kube/reachability.js +163 -0
- package/dist/core/kube/release.js +439 -0
- package/dist/core/kube/replicaset.js +180 -0
- package/dist/core/kube/scale.js +398 -0
- package/dist/core/kube/status.js +633 -0
- package/dist/core/kube/tools.js +238 -0
- package/dist/core/kube/transfer.js +173 -0
- package/dist/core/kube/workspace.js +423 -0
- package/dist/core/lifecycle/admin.js +64 -0
- package/dist/core/lifecycle/create-docker.js +1549 -0
- package/dist/core/lifecycle/create-k8s.js +960 -0
- package/dist/core/lifecycle/destroy.js +339 -0
- package/dist/core/lifecycle/inspect.js +636 -0
- package/dist/core/lifecycle/naming.js +298 -0
- package/dist/core/lifecycle/notes.js +862 -0
- package/dist/core/lifecycle/ownership.js +313 -0
- package/dist/core/lifecycle/payload.js +401 -0
- package/dist/core/lifecycle/ports.js +388 -0
- package/dist/core/lifecycle/preconditions.js +367 -0
- package/dist/core/lifecycle/pruning.js +551 -0
- package/dist/core/lifecycle/ready.js +818 -0
- package/dist/core/lifecycle/request.js +510 -0
- package/dist/core/lifecycle/seeding.js +281 -0
- package/dist/core/lifecycle/sizing.js +392 -0
- package/dist/core/lifecycle/state.js +286 -0
- package/dist/core/lifecycle/tlsplan.js +704 -0
- package/dist/core/lifecycle/types.js +232 -0
- package/dist/core/loadtest.js +1051 -0
- package/dist/core/migrate.js +612 -0
- package/dist/core/monitor.js +494 -0
- package/dist/core/postready.js +976 -0
- package/dist/core/promote.js +804 -0
- package/dist/core/rcapi.js +1336 -0
- package/dist/core/recovery.js +75 -0
- package/dist/core/runner/engine.js +394 -0
- package/dist/core/runner/host.js +298 -0
- package/dist/core/runner/locks.js +129 -0
- package/dist/core/runner/paths.js +173 -0
- package/dist/core/runner/ports.js +172 -0
- package/dist/core/runner/queries.js +612 -0
- package/dist/core/runner/record.js +563 -0
- package/dist/core/scaleseed.js +271 -0
- package/dist/core/seed-db.js +208 -0
- package/dist/core/sessions.js +472 -0
- package/dist/core/skill.js +326 -0
- package/dist/core/sso-identities.js +172 -0
- package/dist/core/sso.js +703 -0
- package/dist/core/tls-local.js +311 -0
- package/dist/core/tls.js +878 -0
- package/dist/core/topology.js +482 -0
- package/dist/core/upgrade.js +877 -0
- package/dist/core/users.js +739 -0
- package/dist/lib/audit.js +100 -0
- package/dist/lib/close-matches.js +238 -0
- package/dist/lib/compose.js +672 -0
- package/dist/lib/config.js +1398 -0
- package/dist/lib/context.js +18 -0
- package/dist/lib/errors.js +305 -0
- package/dist/lib/events.js +208 -0
- package/dist/lib/float-text.js +126 -0
- package/dist/lib/format.js +1320 -0
- package/dist/lib/home.js +325 -0
- package/dist/lib/journal.js +122 -0
- package/dist/lib/json-text.js +733 -0
- package/dist/lib/jsonout.js +382 -0
- package/dist/lib/lock.js +516 -0
- package/dist/lib/login-name.js +202 -0
- package/dist/lib/map-limit.js +29 -0
- package/dist/lib/mkdir-parents.js +90 -0
- package/dist/lib/mongo-kernel.js +67 -0
- package/dist/lib/monitoring.js +492 -0
- package/dist/lib/platform-name.js +59 -0
- package/dist/lib/presets/common.js +390 -0
- package/dist/lib/presets/composite.js +326 -0
- package/dist/lib/presets/e2ee.js +143 -0
- package/dist/lib/presets/email.js +172 -0
- package/dist/lib/presets/guides.js +27 -0
- package/dist/lib/presets/index.js +490 -0
- package/dist/lib/presets/keycloak.js +371 -0
- package/dist/lib/presets/ldap.js +1285 -0
- package/dist/lib/presets/livechat.js +220 -0
- package/dist/lib/presets/multi-instance.js +124 -0
- package/dist/lib/presets/oidc.js +161 -0
- package/dist/lib/presets/public.js +496 -0
- package/dist/lib/presets/registry.js +64 -0
- package/dist/lib/presets/s3-minio.js +300 -0
- package/dist/lib/presets/saml.js +149 -0
- package/dist/lib/presets/scenario.js +51 -0
- package/dist/lib/presets/types.js +86 -0
- package/dist/lib/presets/voice-pbx.js +320 -0
- package/dist/lib/presets/voice.js +345 -0
- package/dist/lib/presets/webhooks.js +182 -0
- package/dist/lib/redact.js +106 -0
- package/dist/lib/seed-options.js +68 -0
- package/dist/lib/seed-profiles.js +59 -0
- package/dist/lib/targz.js +1383 -0
- package/dist/lib/teammode.js +25 -0
- package/dist/lib/tempdir.js +162 -0
- package/dist/lib/unicode-tables.js +2335 -0
- package/dist/lib/version-spec.js +357 -0
- package/dist/lib/versions.js +463 -0
- package/dist/lib/yaml-dump.js +1361 -0
- package/dist/perf/baseline.js +168 -0
- package/dist/perf/constrain.js +299 -0
- package/dist/perf/k6.js +235 -0
- package/dist/perf/mongoprof.js +171 -0
- package/dist/perf/rcmetrics.js +191 -0
- package/dist/perf/report.js +386 -0
- package/dist/perf/resources.js +236 -0
- package/dist/perf/slo.js +111 -0
- package/dist/perf/timeline.js +187 -0
- package/dist/perf/timings.js +85 -0
- package/dist/perf/verdict.js +201 -0
- package/dist/seams/aws-cli.js +126 -0
- package/dist/seams/docker-cli.js +280 -0
- package/dist/seams/exec.js +861 -0
- package/dist/seams/fs/lock.js +528 -0
- package/dist/seams/kubectl.js +83 -0
- package/dist/seams/rc-http.js +921 -0
- package/dist/seed/apply.js +190 -0
- package/dist/seed/assets.js +76 -0
- package/dist/seed/check.js +391 -0
- package/dist/seed/client.js +172 -0
- package/dist/seed/executor.js +726 -0
- package/dist/seed/history.js +281 -0
- package/dist/seed/kinds.js +91 -0
- package/dist/seed/plan.js +432 -0
- package/dist/seed/receipt.js +339 -0
- package/dist/seed/repairs.js +75 -0
- package/dist/seed/verification.js +363 -0
- package/dist/seed/wording.js +248 -0
- package/dist/web/app.js +326 -0
- package/dist/web/jobs.js +510 -0
- package/dist/web/route-deps.js +211 -0
- package/dist/web/route-table.js +213 -0
- package/dist/web/routes/backup.js +244 -0
- package/dist/web/routes/clusters.js +303 -0
- package/dist/web/routes/data.js +187 -0
- package/dist/web/routes/edge.js +82 -0
- package/dist/web/routes/index.js +63 -0
- package/dist/web/routes/jobs.js +95 -0
- package/dist/web/routes/logs.js +297 -0
- package/dist/web/routes/meta.js +191 -0
- package/dist/web/routes/people.js +151 -0
- package/dist/web/routes/perf.js +95 -0
- package/dist/web/routes/repros.js +550 -0
- package/dist/web/routes/session.js +361 -0
- package/dist/web/routes/spa.js +198 -0
- package/dist/web/security.js +475 -0
- package/dist/web/signin.js +246 -0
- package/package.json +70 -32
- package/.eslintrc +0 -94
- package/.swcrc +0 -18
- package/dist/bin.js +0 -3
- package/dist/cli.js +0 -184
- package/dist/commands/createBranch.js +0 -194
- package/dist/outputCI.js +0 -59
- package/src/bin.js +0 -4
- package/src/cli.ts +0 -25
- package/src/commands/createBranch.ts +0 -28
- package/src/outputCI.ts +0 -12
- package/src-old/logs.js +0 -323
- package/src-old/md.js +0 -191
- package/src-old/release-table.js +0 -60
- package/src-old/set-version.js +0 -614
- package/src-old/utils.js +0 -15
|
@@ -0,0 +1,423 @@
|
|
|
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.createWorkspace = createWorkspace;
|
|
37
|
+
/**
|
|
38
|
+
* Creating a workspace in a cluster: the one function everything below this line serves.
|
|
39
|
+
*
|
|
40
|
+
* Tier k5. Nothing in the package imports it -- which is what being the top of the tiers
|
|
41
|
+
* means. It is the orchestrator: the namespace, MongoDB, the chart release, the scenario's
|
|
42
|
+
* manifests and the port-forward, in the order that each one's failure can still be acted on.
|
|
43
|
+
*/
|
|
44
|
+
const crypto = __importStar(require("node:crypto"));
|
|
45
|
+
const errors_1 = require("../../lib/errors");
|
|
46
|
+
const events_1 = require("../../lib/events");
|
|
47
|
+
const composite_1 = require("../../lib/presets/composite");
|
|
48
|
+
const public_1 = require("../../lib/presets/public");
|
|
49
|
+
const capabilities_1 = require("./capabilities");
|
|
50
|
+
const certmanager_1 = require("./certmanager");
|
|
51
|
+
const cluster_1 = require("./cluster");
|
|
52
|
+
const context_1 = require("./context");
|
|
53
|
+
const chart_1 = require("./chart");
|
|
54
|
+
const exec_1 = require("../../seams/exec");
|
|
55
|
+
const record_1 = require("../runner/record");
|
|
56
|
+
const forward_1 = require("./forward");
|
|
57
|
+
const ingress_1 = require("./ingress");
|
|
58
|
+
const manifests_1 = require("./manifests");
|
|
59
|
+
const names_1 = require("./names");
|
|
60
|
+
const namespace_1 = require("./namespace");
|
|
61
|
+
const operator_1 = require("./operator");
|
|
62
|
+
const probe_1 = require("./probe");
|
|
63
|
+
const release_1 = require("./release");
|
|
64
|
+
const replicaset_1 = require("./replicaset");
|
|
65
|
+
const realSleep = (seconds) => new Promise((resolve) => setTimeout(resolve, seconds * 1000));
|
|
66
|
+
/**
|
|
67
|
+
* A generated password: base64url of 24 random bytes, unpadded.
|
|
68
|
+
*
|
|
69
|
+
* The established 32 characters, from a cryptographic source. These never reach disk on
|
|
70
|
+
* this side -- they go to `kubectl apply` on
|
|
71
|
+
* stdin and come back out of the Secret when a tool needs them.
|
|
72
|
+
*/
|
|
73
|
+
function generatedPassword() {
|
|
74
|
+
return crypto.randomBytes(24).toString('base64url');
|
|
75
|
+
}
|
|
76
|
+
/** Provision or adopt the cluster, resolve its chart, and enforce the capability gates. */
|
|
77
|
+
async function prepareCluster(given, resolved, emit) {
|
|
78
|
+
const plan = given ?? (await (0, context_1.planCluster)());
|
|
79
|
+
const context = await (0, cluster_1.ensureKubeconfig)(plan, emit);
|
|
80
|
+
if (!plan.create && !(0, names_1.isOurs)(context)) {
|
|
81
|
+
(0, events_1.info)(emit, `using ${plan.distribution} cluster '${context}' — houston creates a namespace in ` +
|
|
82
|
+
'it; the cluster itself stays until `houston cluster delete`', { phase: 'provision', pct: 5 });
|
|
83
|
+
}
|
|
84
|
+
const hadCluster = !plan.create;
|
|
85
|
+
if (!hadCluster || plan.distribution !== 'kind') {
|
|
86
|
+
(0, events_1.info)(emit, `the ${plan.distribution} cluster has its own image store, separate from Docker's — ` +
|
|
87
|
+
'a version already pulled for Compose is fetched again here (about 1.6 GB the ' +
|
|
88
|
+
'first time)', { phase: 'provision', pct: 6 });
|
|
89
|
+
}
|
|
90
|
+
await (0, chart_1.ensureRepo)(emit);
|
|
91
|
+
const chartVersion = await (0, chart_1.resolveChartVersion)(resolved.rcVersion, emit);
|
|
92
|
+
(0, events_1.info)(emit, `chart ${chartVersion} for Rocket.Chat ${resolved.rcVersion}`, { phase: 'plan' });
|
|
93
|
+
const pre = await (0, probe_1.preflight)(context);
|
|
94
|
+
const blocked = (0, capabilities_1.storageBlocker)(pre) || (0, capabilities_1.architectureBlocker)(pre, resolved.rcVersion, resolved.rcImage);
|
|
95
|
+
if (blocked !== '')
|
|
96
|
+
throw new errors_1.PreflightError(blocked);
|
|
97
|
+
return { plan, context, hadCluster, chartVersion };
|
|
98
|
+
}
|
|
99
|
+
/** Create or adopt the namespace, and remember whether rollback may remove it. */
|
|
100
|
+
async function ensureWorkspaceNamespace(name, context, owner, emit) {
|
|
101
|
+
// Only this call's successful atomic CREATE proves rollback may remove a namespace.
|
|
102
|
+
// A separate list can miss an existing or concurrently-created namespace.
|
|
103
|
+
const receipt = { uid: '', owner: '', createdUid: '' };
|
|
104
|
+
const namespace = await (0, namespace_1.ensureNamespace)(name, { context, owner, emit, receipt });
|
|
105
|
+
return { namespace, receipt };
|
|
106
|
+
}
|
|
107
|
+
/** Install an operator-managed MongoDB and return its connection metadata. */
|
|
108
|
+
async function operatorDatabase(name, resolved, owner, namespace, context, emit) {
|
|
109
|
+
await (0, operator_1.ensureOperator)({ context, namespace, emit });
|
|
110
|
+
const appPassword = generatedPassword();
|
|
111
|
+
(0, events_1.info)(emit, `MongoDB ${resolved.mongoTag} via the operator, SCRAM auth, ${String(names_1.MONGO_VOLUME_GB)}Gi ` +
|
|
112
|
+
'volume', { phase: 'provision', pct: 20 });
|
|
113
|
+
await (0, release_1.apply)((0, operator_1.mongoRbacManifest)(name, { owner }), { namespace, context });
|
|
114
|
+
await (0, release_1.apply)((0, operator_1.mongoSecretManifest)(name, {
|
|
115
|
+
adminPassword: generatedPassword(),
|
|
116
|
+
appPassword,
|
|
117
|
+
owner,
|
|
118
|
+
}), { namespace, context });
|
|
119
|
+
const operatorDoc = (0, operator_1.mongodbCommunityManifest)(name, resolved.mongoTag, { owner });
|
|
120
|
+
await (0, release_1.apply)(operatorDoc, { namespace, context });
|
|
121
|
+
await (0, operator_1.waitForMongodb)({ namespace, context, emit });
|
|
122
|
+
return {
|
|
123
|
+
mongoUrl: (0, operator_1.operatorMongoUrl)(namespace, appPassword),
|
|
124
|
+
oplogUrl: (0, operator_1.operatorMongoUrl)(namespace, appPassword, { oplog: true }),
|
|
125
|
+
rendered: { mongodb: operatorDoc },
|
|
126
|
+
managedBy: 'operator',
|
|
127
|
+
image: `mongodb-community-server ${(0, operator_1.operatorVersion)(resolved.mongoTag)} ` + "(operator's choice)",
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/** Install the unauthenticated StatefulSet fallback and initiate its replica set. */
|
|
131
|
+
async function statefulSetDatabase(name, resolved, owner, namespace, context, emit, operatorRequested) {
|
|
132
|
+
const floor = operator_1.OPERATOR_MIN_MONGO.join('.');
|
|
133
|
+
const whyNoAuth = operatorRequested
|
|
134
|
+
? `the operator cannot manage MongoDB below ${floor}, so this falls back to a plain ` +
|
|
135
|
+
'StatefulSet'
|
|
136
|
+
: 'the MongoDB operator is opt-in — add `--mongo-operator` for a database with SCRAM ' +
|
|
137
|
+
'authentication';
|
|
138
|
+
(0, events_1.info)(emit, `MongoDB ${resolved.mongoTag}, ${String(names_1.MONGO_VOLUME_GB)}Gi volume (no authentication: ` +
|
|
139
|
+
`${whyNoAuth})`, { phase: 'provision', pct: 20 });
|
|
140
|
+
await (0, release_1.apply)((0, manifests_1.mongoManifest)(name, resolved.mongoTag, { owner }), { namespace, context });
|
|
141
|
+
await (0, replicaset_1.initReplicaSet)({ namespace, context, emit });
|
|
142
|
+
return {
|
|
143
|
+
mongoUrl: names_1.MONGO_URL,
|
|
144
|
+
oplogUrl: names_1.MONGO_OPLOG_URL,
|
|
145
|
+
rendered: {},
|
|
146
|
+
managedBy: 'statefulset',
|
|
147
|
+
image: (0, names_1.mongoImage)(resolved.mongoTag),
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/** Choose the operator or StatefulSet path without changing their ordering. */
|
|
151
|
+
async function provisionDatabase(name, resolved, useOperator, owner, namespace, context, emit) {
|
|
152
|
+
const requested = useOperator || (0, operator_1.operatorEnabled)();
|
|
153
|
+
if ((0, operator_1.wouldUseOperator)(resolved.mongoTag, useOperator)) {
|
|
154
|
+
return await operatorDatabase(name, resolved, owner, namespace, context, emit);
|
|
155
|
+
}
|
|
156
|
+
return await statefulSetDatabase(name, resolved, owner, namespace, context, emit, requested);
|
|
157
|
+
}
|
|
158
|
+
/** Apply scenario resources and the Secrets the Rocket.Chat chart consumes. */
|
|
159
|
+
async function applyScenarioAndSecrets(name, preset, regToken, license, owner, namespace, context, database, emit, advertised = '') {
|
|
160
|
+
const rendered = database.rendered;
|
|
161
|
+
const manifests = preset?.kubernetesManifests ?? [];
|
|
162
|
+
if (manifests.length > 0) {
|
|
163
|
+
const count = manifests.length;
|
|
164
|
+
(0, events_1.info)(emit, `applying the ${(0, composite_1.presetsLabel)(preset?.name ?? '')} preset — ` +
|
|
165
|
+
`${String(count)} resource${count === 1 ? '' : 's'}`, { phase: 'provision', pct: 25 });
|
|
166
|
+
for (const [index, manifest] of manifests.entries()) {
|
|
167
|
+
const body = (0, manifests_1.renderScenarioManifest)(manifest, name, advertised);
|
|
168
|
+
rendered[index === 0 ? 'scenario' : `scenario-${String(index)}`] = body;
|
|
169
|
+
await (0, release_1.apply)(body, { namespace, context });
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
await (0, release_1.apply)((0, operator_1.mongoUrlSecretManifest)(name, {
|
|
173
|
+
mongoUrl: database.mongoUrl,
|
|
174
|
+
oplogUrl: database.oplogUrl,
|
|
175
|
+
owner,
|
|
176
|
+
}), { namespace, context });
|
|
177
|
+
if (regToken !== '') {
|
|
178
|
+
(0, events_1.info)(emit, 'installing the registration token Secret', { phase: 'boot' });
|
|
179
|
+
await (0, release_1.apply)((0, operator_1.regTokenSecretManifest)(name, { token: regToken, owner }), { namespace, context });
|
|
180
|
+
}
|
|
181
|
+
if (license !== '') {
|
|
182
|
+
// Not added to `rendered`: that is written to the workspace for a human to read.
|
|
183
|
+
(0, events_1.info)(emit, 'installing the license Secret', { phase: 'boot' });
|
|
184
|
+
await (0, release_1.apply)((0, operator_1.licenseSecretManifest)(name, { license, owner }), { namespace, context });
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/** Build values, prepare TLS, and install the Rocket.Chat release. */
|
|
188
|
+
async function installChart(options) {
|
|
189
|
+
const { name, resolved, tlsHost, regToken, namespace, context, chartVersion, emit } = options;
|
|
190
|
+
const values = (0, chart_1.valuesFor)({
|
|
191
|
+
rcVersion: resolved.rcVersion,
|
|
192
|
+
rcImage: resolved.rcImage,
|
|
193
|
+
microservices: options.microservices,
|
|
194
|
+
replicas: options.replicas,
|
|
195
|
+
// `host` and `root_url` are the same field to the chart and must never both be set --
|
|
196
|
+
// two entries for ROOT_URL is a server-side-apply conflict, not an override.
|
|
197
|
+
rootUrl: tlsHost !== '' ? '' : options.rootUrl,
|
|
198
|
+
host: tlsHost,
|
|
199
|
+
oplog: resolved.oplog,
|
|
200
|
+
mongoSecret: operator_1.MONGO_URL_SECRET,
|
|
201
|
+
regTokenSecret: regToken !== '' ? operator_1.REG_TOKEN_SECRET : '',
|
|
202
|
+
adminPassword: options.adminPassword,
|
|
203
|
+
...(options.preset !== null ? { presetEnv: options.preset.env } : {}),
|
|
204
|
+
envOverrides: options.envOverrides,
|
|
205
|
+
licensed: options.licensed,
|
|
206
|
+
});
|
|
207
|
+
if (tlsHost !== '') {
|
|
208
|
+
const spec = options.issuer ?? { mode: 'local' };
|
|
209
|
+
await (0, certmanager_1.ensureIssuer)(spec, { context, ingressClass: options.ingressClass, emit });
|
|
210
|
+
Object.assign(values, (0, ingress_1.ingressValues)(tlsHost, {
|
|
211
|
+
ingressClass: options.ingressClass,
|
|
212
|
+
secretName: (0, certmanager_1.tlsSecretFor)(name),
|
|
213
|
+
issuer: (0, certmanager_1.issuerName)(spec),
|
|
214
|
+
}));
|
|
215
|
+
}
|
|
216
|
+
Object.assign(values, await (0, manifests_1.containerSecurityContext)(chartVersion));
|
|
217
|
+
(0, events_1.info)(emit, `installing ${names_1.CHART} as ${names_1.RELEASE} — the pods pull the image now, which is the longest ` +
|
|
218
|
+
'step of a create', { phase: 'boot', pct: 60 });
|
|
219
|
+
await (0, release_1.install)({ namespace, context, values, chartVersion, emit });
|
|
220
|
+
// The preset's own UIs at paths of the same name (Mailpit, Keycloak, the demo page).
|
|
221
|
+
const tools = options.preset === null ? [] : (0, public_1.publicPathsOf)(options.preset.extra);
|
|
222
|
+
if (tlsHost !== '' && tools.length > 0) {
|
|
223
|
+
(0, events_1.info)(emit, `serving ${tools.map((p) => p.path).join(', ')} at https://${tlsHost}`, {
|
|
224
|
+
phase: 'tls',
|
|
225
|
+
});
|
|
226
|
+
await (0, release_1.apply)((0, ingress_1.toolsIngressManifest)(tlsHost, {
|
|
227
|
+
ingressClass: options.ingressClass,
|
|
228
|
+
secretName: (0, certmanager_1.tlsSecretFor)(name),
|
|
229
|
+
paths: tools,
|
|
230
|
+
labels: (0, namespace_1.labelsFor)(name),
|
|
231
|
+
}), { namespace, context });
|
|
232
|
+
}
|
|
233
|
+
return values;
|
|
234
|
+
}
|
|
235
|
+
/** Undo only the resources this create proved it introduced. */
|
|
236
|
+
async function rollbackCreate(name, namespace, context, receipt, hadCluster, emit) {
|
|
237
|
+
if (receipt.createdUid === '') {
|
|
238
|
+
(0, events_1.warn)(emit, `create failed — namespace ${namespace} and its volume are left as they were`, {
|
|
239
|
+
phase: 'teardown',
|
|
240
|
+
});
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
(0, events_1.warn)(emit, `create failed — removing namespace ${namespace}`, { phase: 'teardown' });
|
|
244
|
+
try {
|
|
245
|
+
const gone = await (0, namespace_1.deleteNamespace)(name, {
|
|
246
|
+
context,
|
|
247
|
+
volumes: true,
|
|
248
|
+
owner: receipt.owner,
|
|
249
|
+
expectedUid: receipt.createdUid,
|
|
250
|
+
emit,
|
|
251
|
+
});
|
|
252
|
+
if (gone && !hadCluster)
|
|
253
|
+
await (0, cluster_1.deleteCluster)({ emit });
|
|
254
|
+
}
|
|
255
|
+
catch {
|
|
256
|
+
// The ORIGINAL failure is what matters; a rollback that fails must not replace it.
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Forward pids, into the write-ahead record the moment they exist.
|
|
261
|
+
*
|
|
262
|
+
* They reached the record only once the whole create finished, so a create killed after
|
|
263
|
+
* "port-forward established" left a kubectl holding the port that no record named:
|
|
264
|
+
* `down --volumes` said it had removed everything, and the listener outlived the namespace
|
|
265
|
+
* (it exits only when something next connects). Best effort: a path with no record yet
|
|
266
|
+
* has its final record carry them.
|
|
267
|
+
*/
|
|
268
|
+
async function noteForwards(name, fields) {
|
|
269
|
+
try {
|
|
270
|
+
await (0, record_1.updateMeta)(name, (meta) => {
|
|
271
|
+
Object.assign(meta.extra, fields);
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
catch (error) {
|
|
275
|
+
if (error instanceof exec_1.Interrupted)
|
|
276
|
+
throw error;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
/** Persist the namespace identity before installing anything into it. */
|
|
280
|
+
async function noteNamespace(name, receipt) {
|
|
281
|
+
try {
|
|
282
|
+
await (0, record_1.updateMeta)(name, (meta) => {
|
|
283
|
+
Object.assign(meta.extra, { namespace_uid: receipt.uid, namespace_owner: receipt.owner });
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
catch (error) {
|
|
287
|
+
// Low-level callers without a write-ahead record receive these fields in the result.
|
|
288
|
+
// An existing record whose identity cannot be saved must not continue unbound.
|
|
289
|
+
if (!(error instanceof errors_1.MissingRecordError))
|
|
290
|
+
throw error;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
/** Wait for TLS, establish the forwards, persist the manifests, and return the metadata. */
|
|
294
|
+
async function connectWorkspace(options) {
|
|
295
|
+
const { name, namespace, context, hostPort, bindHost, tlsHost, emit } = options;
|
|
296
|
+
let certReady = false;
|
|
297
|
+
if (tlsHost !== '') {
|
|
298
|
+
certReady = await (0, certmanager_1.waitForCertificate)((0, certmanager_1.tlsSecretFor)(name), { namespace, context, emit });
|
|
299
|
+
}
|
|
300
|
+
let pid = await (0, forward_1.portForward)(name, {
|
|
301
|
+
namespace,
|
|
302
|
+
context,
|
|
303
|
+
hostPort,
|
|
304
|
+
bindHost,
|
|
305
|
+
previousPid: options.previousPid,
|
|
306
|
+
previousPort: options.previousPort,
|
|
307
|
+
emit,
|
|
308
|
+
});
|
|
309
|
+
await noteForwards(name, { port_forward_pid: pid });
|
|
310
|
+
await options.sleep(1.0);
|
|
311
|
+
if (await (0, forward_1.forwardAlive)(pid, { namespace, hostPort })) {
|
|
312
|
+
(0, events_1.info)(emit, `port-forward established — http://localhost:${String(hostPort)}`, {
|
|
313
|
+
phase: 'boot',
|
|
314
|
+
pct: 90,
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
pid = 0;
|
|
319
|
+
(0, events_1.warn)(emit, `the port-forward did not stay up, so http://localhost:${String(hostPort)} is not ` +
|
|
320
|
+
`reachable yet. Once the pod is running: kubectl -n ${namespace} port-forward ` +
|
|
321
|
+
`deployment/${names_1.RELEASE}-rocketchat ${String(hostPort)}:3000 — or \`houston ready ` +
|
|
322
|
+
`--name ${name}\` to re-establish it.`, { phase: 'boot' });
|
|
323
|
+
}
|
|
324
|
+
await (0, manifests_1.recordRendered)(name, { values: options.values, manifests: options.rendered });
|
|
325
|
+
const ui = await (0, forward_1.scenarioUiForwards)(name, { namespace, context, bindHost, emit });
|
|
326
|
+
const scenarioForwards = Object.fromEntries(Object.entries(ui).map(([port, forwardPid]) => [String(port), forwardPid]));
|
|
327
|
+
await noteForwards(name, { scenario_forwards: scenarioForwards });
|
|
328
|
+
return {
|
|
329
|
+
scenario_forwards: scenarioForwards,
|
|
330
|
+
context,
|
|
331
|
+
namespace,
|
|
332
|
+
bind_host: bindHost,
|
|
333
|
+
chart_version: options.chartVersion,
|
|
334
|
+
release: names_1.RELEASE,
|
|
335
|
+
port_forward_pid: pid,
|
|
336
|
+
microservices: options.microservices,
|
|
337
|
+
mongo_managed_by: options.database.managedBy,
|
|
338
|
+
mongo_image: options.database.image,
|
|
339
|
+
tls_host: tlsHost,
|
|
340
|
+
certificate_ready: certReady,
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Build a Kubernetes workspace, and return what repro.json needs.
|
|
345
|
+
*
|
|
346
|
+
* A PARALLEL path to lifecycle's compose one rather than a refactor of it, which is PR #3's
|
|
347
|
+
* call and the right one: lifecycle is compose-shaped throughout and two front-ends depend
|
|
348
|
+
* on it, so the Docker default stays byte-identical and this owns the Kubernetes sequence
|
|
349
|
+
* instead. Naming, version resolution and metadata are shared, not reimplemented.
|
|
350
|
+
*
|
|
351
|
+
* Ordered so nothing waits on something that cannot happen: the replica set is initiated
|
|
352
|
+
* BEFORE the chart goes in, because Rocket.Chat needs change streams and would otherwise sit
|
|
353
|
+
* at not-ready with nothing in its logs naming MongoDB.
|
|
354
|
+
*/
|
|
355
|
+
async function createWorkspace({ name, resolved, hostPort, microservices, replicas = 1, owner = '', rootUrl = '', bindHost = '', useOperator = false, regToken = '', preset = null, envOverrides = {}, license = '', licensed = false, plan = null, tlsHost = '', ingressClass = '', issuer = null, adminPassword = '', previousPid = 0, previousPort = null, emit = events_1.nullEmit, sleep = realSleep, }) {
|
|
356
|
+
const prepared = await prepareCluster(plan, resolved, emit);
|
|
357
|
+
const { context, hadCluster, chartVersion } = prepared;
|
|
358
|
+
const { namespace, receipt } = await ensureWorkspaceNamespace(name, context, owner, emit);
|
|
359
|
+
let database;
|
|
360
|
+
let values;
|
|
361
|
+
try {
|
|
362
|
+
await noteNamespace(name, receipt);
|
|
363
|
+
database = await provisionDatabase(name, resolved, useOperator, owner, namespace, context, emit);
|
|
364
|
+
await applyScenarioAndSecrets(name, preset, regToken, license, owner, namespace, context, database, emit,
|
|
365
|
+
// Where a browser reaches Rocket.Chat: the HTTPS name, else the workspace's own URL.
|
|
366
|
+
tlsHost !== '' ? `https://${tlsHost}` : rootUrl);
|
|
367
|
+
values = await installChart({
|
|
368
|
+
name,
|
|
369
|
+
resolved,
|
|
370
|
+
microservices,
|
|
371
|
+
replicas,
|
|
372
|
+
rootUrl,
|
|
373
|
+
tlsHost,
|
|
374
|
+
regToken,
|
|
375
|
+
adminPassword,
|
|
376
|
+
preset,
|
|
377
|
+
envOverrides,
|
|
378
|
+
licensed,
|
|
379
|
+
issuer,
|
|
380
|
+
ingressClass,
|
|
381
|
+
namespace,
|
|
382
|
+
context,
|
|
383
|
+
chartVersion,
|
|
384
|
+
emit,
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
catch (error) {
|
|
388
|
+
// A failed create must not leave anything a user cannot see. No repro.json is written
|
|
389
|
+
// until this returns, so a surviving namespace would be invisible to `list` and to
|
|
390
|
+
// `down` -- and on Compose a failed `up` at least leaves a workspace directory you can
|
|
391
|
+
// find. The cluster goes too if this call created it and nothing else is using it:
|
|
392
|
+
// `deleteCluster` refuses while any other workspace namespace is there, so a
|
|
393
|
+
// colleague's concurrent `up` is safe from this. As cleanup, so it runs to the end
|
|
394
|
+
// when the failure IS a Ctrl-C or a stopped job: refused there, it left a namespace
|
|
395
|
+
// no record pointed at.
|
|
396
|
+
await (0, exec_1.cleanup)(async () => {
|
|
397
|
+
await rollbackCreate(name, namespace, context, receipt, hadCluster, emit);
|
|
398
|
+
});
|
|
399
|
+
throw error;
|
|
400
|
+
}
|
|
401
|
+
// AFTER the try/catch, so a certificate that has not arrived cannot roll back a workspace
|
|
402
|
+
// that installed perfectly well. cert-manager issues asynchronously from the Ingress
|
|
403
|
+
// annotation, so this is the difference between "the name works" and "the name will work
|
|
404
|
+
// in a moment, probably".
|
|
405
|
+
const connected = await connectWorkspace({
|
|
406
|
+
name,
|
|
407
|
+
namespace,
|
|
408
|
+
context,
|
|
409
|
+
hostPort,
|
|
410
|
+
bindHost,
|
|
411
|
+
previousPid,
|
|
412
|
+
previousPort,
|
|
413
|
+
tlsHost,
|
|
414
|
+
values,
|
|
415
|
+
rendered: database.rendered,
|
|
416
|
+
chartVersion,
|
|
417
|
+
microservices,
|
|
418
|
+
database,
|
|
419
|
+
emit,
|
|
420
|
+
sleep,
|
|
421
|
+
});
|
|
422
|
+
return { ...connected, namespace_uid: receipt.uid, namespace_owner: receipt.owner };
|
|
423
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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.login = login;
|
|
37
|
+
/**
|
|
38
|
+
* THE admin login every service function goes through.
|
|
39
|
+
*
|
|
40
|
+
* Tier 0. Named `admin` rather than `auth` because `auth` is what every caller names the
|
|
41
|
+
* local it binds the result to, and a module shadowed by a local is a module nobody can reach
|
|
42
|
+
* from inside the function that needs it most.
|
|
43
|
+
*
|
|
44
|
+
* Its own module because of who calls it: `seed`, `pat`, `api`, `loadtest`, `monitor`,
|
|
45
|
+
* `upgrade` and readiness all authenticate through this one function, and the suite
|
|
46
|
+
* patches it from four different subjects. Filing it under `ready` would have made
|
|
47
|
+
* `seeding` import `ready` while `ready` imports `seeding`.
|
|
48
|
+
*/
|
|
49
|
+
const config = __importStar(require("../../lib/config"));
|
|
50
|
+
const rcapi_1 = require("../rcapi");
|
|
51
|
+
const record_1 = require("../runner/record");
|
|
52
|
+
/**
|
|
53
|
+
* `password` is not optional here even though `rcapi.login` has a default. The default is
|
|
54
|
+
* the shared loopback `admin123`, and a workspace with a public name has its own -- so
|
|
55
|
+
* leaving it off would authenticate `pat`, `api`, `seed`, `loadtest`, `monitor`,
|
|
56
|
+
* `upgrade` and readiness with the wrong password and return a 401 that names nothing.
|
|
57
|
+
*/
|
|
58
|
+
async function login(meta) {
|
|
59
|
+
const mailpit = meta.extra[config.EXTRA_MAILPIT_URL];
|
|
60
|
+
return await (0, rcapi_1.login)(meta.rootUrl, {
|
|
61
|
+
password: (0, record_1.adminPass)(meta),
|
|
62
|
+
mailpitUrl: typeof mailpit === 'string' ? mailpit : '',
|
|
63
|
+
});
|
|
64
|
+
}
|