@rocket.chat/houston 0.27.0-next.2 → 2.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +108 -15
- package/bin/houston +62 -0
- package/data/docs/ARCHITECTURE.md +387 -0
- package/data/docs/automation.md +107 -0
- package/data/docs/e2ee.md +76 -0
- package/data/docs/eks.md +258 -0
- package/data/docs/gui.md +282 -0
- package/data/docs/guide.md +669 -0
- package/data/docs/kubernetes.md +138 -0
- package/data/docs/troubleshooting.md +193 -0
- package/data/docs/upgrading.md +84 -0
- package/data/docs/voice.md +253 -0
- package/data/iam/engineer-policy.json +11 -0
- package/data/iam/engineer-rbac.yaml +42 -0
- package/data/iam/operator-policy.json +211 -0
- package/data/loadtest/badbot.js +22 -0
- package/data/loadtest/common.js +168 -0
- package/data/loadtest/custom.js +20 -0
- package/data/loadtest/journey.js +58 -0
- package/data/loadtest/login.js +18 -0
- package/data/loadtest/messages.js +13 -0
- package/data/loadtest/mixed.js +39 -0
- package/data/loadtest/read.js +12 -0
- package/data/loadtest/webhook.js +20 -0
- package/data/monitoring/houston-logs.json +98 -0
- package/data/monitoring/k6-loadtest.json +610 -0
- package/data/monitoring/mongodb-exporter.json +3007 -0
- package/data/monitoring/node-exporter-full.json +16114 -0
- package/data/monitoring/rocketchat-metrics.json +6471 -0
- package/data/presets/airgapped.yaml +16 -0
- package/data/presets/default.yaml +9 -0
- package/data/seed/avatar-0.png +0 -0
- package/data/seed/avatar-1.png +0 -0
- package/data/seed/avatar-2.png +0 -0
- package/data/seed/avatar-3.png +0 -0
- package/data/seed/avatar-4.png +0 -0
- package/data/seed/avatar-5.png +0 -0
- package/data/seed/avatar-6.png +0 -0
- package/data/seed/avatar-7.png +0 -0
- package/data/seed/seed-metrics.csv +3 -0
- package/data/seed/seed-preview.png +0 -0
- package/data/seed/seed-report.pdf +32 -0
- package/data/seed/seed-runbook.txt +3 -0
- package/data/skill/SKILL.md +399 -0
- package/data/versions.yaml +55 -0
- package/data/voice/freeswitch/drachtio.xml +52 -0
- package/data/voice/freeswitch/public.xml +87 -0
- package/data/webui/app.css +2003 -0
- package/data/webui/index.html +678 -0
- package/data/webui/js/api.js +561 -0
- package/data/webui/js/boot.js +44 -0
- package/data/webui/js/clusters-tail.js +1377 -0
- package/data/webui/js/clusters.js +896 -0
- package/data/webui/js/create.js +276 -0
- package/data/webui/js/detail.js +507 -0
- package/data/webui/js/jobs.js +636 -0
- package/data/webui/js/logs.js +634 -0
- package/data/webui/js/main.js +14 -0
- package/data/webui/js/options.js +408 -0
- package/data/webui/js/people.js +438 -0
- package/data/webui/js/perf.js +303 -0
- package/data/webui/js/render.js +438 -0
- package/data/webui/js/shared.js +3 -0
- package/data/webui/js/state.js +583 -0
- package/data/webui/js/theme.js +123 -0
- package/data/webui/js/util.js +584 -0
- package/dist/cli/app.js +593 -0
- package/dist/cli/capabilities.js +76 -0
- package/dist/cli/cell-widths.js +495 -0
- package/dist/cli/entry.js +10 -0
- package/dist/cli/error-panel.js +492 -0
- package/dist/cli/handlers/actor.js +84 -0
- package/dist/cli/handlers/https.js +614 -0
- package/dist/cli/handlers/prompt.js +299 -0
- package/dist/cli/handlers/users.js +226 -0
- package/dist/cli/handlers.js +3678 -0
- package/dist/cli/help.js +183 -0
- package/dist/cli/index.js +15 -0
- package/dist/cli/perf.js +810 -0
- package/dist/cli/render.js +254 -0
- package/dist/cli/serve.js +858 -0
- package/dist/cli/spec-data.js +2593 -0
- package/dist/cli/spec-types.js +8 -0
- package/dist/cli/usage-error.js +520 -0
- package/dist/cli/wire.js +70 -0
- package/dist/core/audit.js +346 -0
- package/dist/core/backup-compat.js +85 -0
- package/dist/core/backup.js +1639 -0
- package/dist/core/cluster.js +1398 -0
- package/dist/core/configimport.js +344 -0
- package/dist/core/data.js +267 -0
- package/dist/core/database-of.js +82 -0
- package/dist/core/diagnose.js +159 -0
- package/dist/core/doctor.js +1518 -0
- package/dist/core/edge/acme.js +338 -0
- package/dist/core/edge/engine.js +500 -0
- package/dist/core/edge/networks.js +174 -0
- package/dist/core/edge/paths.js +107 -0
- package/dist/core/edge/routes.js +251 -0
- package/dist/core/edge/routeyml.js +195 -0
- package/dist/core/edge/runtime.js +493 -0
- package/dist/core/edge/spec.js +305 -0
- package/dist/core/edge/types.js +202 -0
- package/dist/core/eks-docs.js +135 -0
- package/dist/core/eks.js +2240 -0
- package/dist/core/envvars.js +562 -0
- package/dist/core/eventlog.js +541 -0
- package/dist/core/firstrun.js +153 -0
- package/dist/core/journal.js +691 -0
- package/dist/core/kube/ask.js +231 -0
- package/dist/core/kube/capabilities.js +269 -0
- package/dist/core/kube/certmanager.js +452 -0
- package/dist/core/kube/chart.js +413 -0
- package/dist/core/kube/cluster.js +196 -0
- package/dist/core/kube/context.js +545 -0
- package/dist/core/kube/endpoints.js +448 -0
- package/dist/core/kube/exec.js +195 -0
- package/dist/core/kube/forward.js +732 -0
- package/dist/core/kube/grafana-ingress.js +110 -0
- package/dist/core/kube/ingress.js +218 -0
- package/dist/core/kube/manifests.js +361 -0
- package/dist/core/kube/monitoring.js +768 -0
- package/dist/core/kube/names.js +237 -0
- package/dist/core/kube/namespace.js +678 -0
- package/dist/core/kube/operator.js +941 -0
- package/dist/core/kube/probe.js +202 -0
- package/dist/core/kube/reachability.js +163 -0
- package/dist/core/kube/release.js +439 -0
- package/dist/core/kube/replicaset.js +180 -0
- package/dist/core/kube/scale.js +398 -0
- package/dist/core/kube/status.js +633 -0
- package/dist/core/kube/tools.js +238 -0
- package/dist/core/kube/transfer.js +173 -0
- package/dist/core/kube/workspace.js +423 -0
- package/dist/core/lifecycle/admin.js +64 -0
- package/dist/core/lifecycle/create-docker.js +1533 -0
- package/dist/core/lifecycle/create-k8s.js +939 -0
- package/dist/core/lifecycle/destroy.js +339 -0
- package/dist/core/lifecycle/inspect.js +635 -0
- package/dist/core/lifecycle/naming.js +298 -0
- package/dist/core/lifecycle/notes.js +726 -0
- package/dist/core/lifecycle/ownership.js +313 -0
- package/dist/core/lifecycle/payload.js +401 -0
- package/dist/core/lifecycle/ports.js +388 -0
- package/dist/core/lifecycle/preconditions.js +367 -0
- package/dist/core/lifecycle/pruning.js +551 -0
- package/dist/core/lifecycle/ready.js +753 -0
- package/dist/core/lifecycle/request.js +525 -0
- package/dist/core/lifecycle/seeding.js +281 -0
- package/dist/core/lifecycle/sizing.js +392 -0
- package/dist/core/lifecycle/state.js +286 -0
- package/dist/core/lifecycle/tlsplan.js +704 -0
- package/dist/core/lifecycle/types.js +232 -0
- package/dist/core/loadtest.js +995 -0
- package/dist/core/migrate.js +612 -0
- package/dist/core/monitor.js +494 -0
- package/dist/core/postready.js +969 -0
- package/dist/core/promote.js +804 -0
- package/dist/core/rcapi.js +1285 -0
- package/dist/core/recovery.js +75 -0
- package/dist/core/runner/engine.js +394 -0
- package/dist/core/runner/host.js +298 -0
- package/dist/core/runner/locks.js +129 -0
- package/dist/core/runner/paths.js +173 -0
- package/dist/core/runner/ports.js +172 -0
- package/dist/core/runner/queries.js +612 -0
- package/dist/core/runner/record.js +563 -0
- package/dist/core/scaleseed.js +271 -0
- package/dist/core/seed-db.js +208 -0
- package/dist/core/sessions.js +472 -0
- package/dist/core/skill.js +326 -0
- package/dist/core/sso-identities.js +172 -0
- package/dist/core/sso.js +703 -0
- package/dist/core/tls-local.js +311 -0
- package/dist/core/tls.js +878 -0
- package/dist/core/topology.js +482 -0
- package/dist/core/upgrade.js +868 -0
- package/dist/core/users.js +739 -0
- package/dist/lib/audit.js +100 -0
- package/dist/lib/close-matches.js +238 -0
- package/dist/lib/compose.js +672 -0
- package/dist/lib/config.js +1398 -0
- package/dist/lib/context.js +18 -0
- package/dist/lib/errors.js +305 -0
- package/dist/lib/events.js +208 -0
- package/dist/lib/float-text.js +126 -0
- package/dist/lib/format.js +1320 -0
- package/dist/lib/home.js +325 -0
- package/dist/lib/journal.js +122 -0
- package/dist/lib/json-text.js +733 -0
- package/dist/lib/jsonout.js +382 -0
- package/dist/lib/lock.js +516 -0
- package/dist/lib/login-name.js +202 -0
- package/dist/lib/map-limit.js +29 -0
- package/dist/lib/mkdir-parents.js +90 -0
- package/dist/lib/mongo-kernel.js +67 -0
- package/dist/lib/monitoring.js +492 -0
- package/dist/lib/platform-name.js +59 -0
- package/dist/lib/presets/common.js +390 -0
- package/dist/lib/presets/composite.js +326 -0
- package/dist/lib/presets/e2ee.js +143 -0
- package/dist/lib/presets/email.js +172 -0
- package/dist/lib/presets/guides.js +27 -0
- package/dist/lib/presets/index.js +490 -0
- package/dist/lib/presets/keycloak.js +369 -0
- package/dist/lib/presets/ldap.js +1285 -0
- package/dist/lib/presets/livechat.js +220 -0
- package/dist/lib/presets/multi-instance.js +124 -0
- package/dist/lib/presets/oidc.js +161 -0
- package/dist/lib/presets/public.js +496 -0
- package/dist/lib/presets/registry.js +64 -0
- package/dist/lib/presets/s3-minio.js +300 -0
- package/dist/lib/presets/saml.js +149 -0
- package/dist/lib/presets/scenario.js +51 -0
- package/dist/lib/presets/types.js +86 -0
- package/dist/lib/presets/voice-pbx.js +320 -0
- package/dist/lib/presets/voice.js +345 -0
- package/dist/lib/presets/webhooks.js +182 -0
- package/dist/lib/redact.js +106 -0
- package/dist/lib/seed-options.js +68 -0
- package/dist/lib/seed-profiles.js +59 -0
- package/dist/lib/targz.js +1383 -0
- package/dist/lib/teammode.js +25 -0
- package/dist/lib/tempdir.js +162 -0
- package/dist/lib/unicode-tables.js +2335 -0
- package/dist/lib/version-spec.js +357 -0
- package/dist/lib/versions.js +463 -0
- package/dist/lib/yaml-dump.js +1361 -0
- package/dist/perf/baseline.js +168 -0
- package/dist/perf/constrain.js +296 -0
- package/dist/perf/k6.js +235 -0
- package/dist/perf/mongoprof.js +171 -0
- package/dist/perf/rcmetrics.js +178 -0
- package/dist/perf/report.js +386 -0
- package/dist/perf/resources.js +224 -0
- package/dist/perf/slo.js +111 -0
- package/dist/perf/timeline.js +187 -0
- package/dist/perf/timings.js +85 -0
- package/dist/perf/verdict.js +201 -0
- package/dist/seams/aws-cli.js +126 -0
- package/dist/seams/docker-cli.js +280 -0
- package/dist/seams/exec.js +861 -0
- package/dist/seams/fs/lock.js +528 -0
- package/dist/seams/kubectl.js +83 -0
- package/dist/seams/rc-http.js +921 -0
- package/dist/seed/apply.js +190 -0
- package/dist/seed/assets.js +76 -0
- package/dist/seed/check.js +391 -0
- package/dist/seed/client.js +172 -0
- package/dist/seed/executor.js +726 -0
- package/dist/seed/history.js +281 -0
- package/dist/seed/kinds.js +91 -0
- package/dist/seed/plan.js +432 -0
- package/dist/seed/receipt.js +339 -0
- package/dist/seed/repairs.js +75 -0
- package/dist/seed/verification.js +363 -0
- package/dist/seed/wording.js +248 -0
- package/dist/web/app.js +326 -0
- package/dist/web/jobs.js +510 -0
- package/dist/web/route-deps.js +211 -0
- package/dist/web/route-table.js +213 -0
- package/dist/web/routes/backup.js +244 -0
- package/dist/web/routes/clusters.js +303 -0
- package/dist/web/routes/data.js +187 -0
- package/dist/web/routes/edge.js +82 -0
- package/dist/web/routes/index.js +63 -0
- package/dist/web/routes/jobs.js +95 -0
- package/dist/web/routes/logs.js +297 -0
- package/dist/web/routes/meta.js +191 -0
- package/dist/web/routes/people.js +151 -0
- package/dist/web/routes/perf.js +95 -0
- package/dist/web/routes/repros.js +550 -0
- package/dist/web/routes/session.js +361 -0
- package/dist/web/routes/spa.js +198 -0
- package/dist/web/security.js +475 -0
- package/dist/web/signin.js +246 -0
- package/package.json +67 -32
- package/.eslintrc +0 -94
- package/.swcrc +0 -18
- package/dist/bin.js +0 -3
- package/dist/cli.js +0 -184
- package/dist/commands/createBranch.js +0 -192
- package/src/bin.js +0 -4
- package/src/cli.ts +0 -25
- package/src/commands/createBranch.ts +0 -25
- package/src-old/logs.js +0 -323
- package/src-old/md.js +0 -191
- package/src-old/release-table.js +0 -60
- package/src-old/set-version.js +0 -614
- package/src-old/utils.js +0 -15
|
@@ -0,0 +1,563 @@
|
|
|
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.META_FIELDS = void 0;
|
|
37
|
+
exports.metadata = metadata;
|
|
38
|
+
exports.externalUrl = externalUrl;
|
|
39
|
+
exports.adminPass = adminPass;
|
|
40
|
+
exports.sidePortsOf = sidePortsOf;
|
|
41
|
+
exports.grafanaPortOf = grafanaPortOf;
|
|
42
|
+
exports.prometheusPortOf = prometheusPortOf;
|
|
43
|
+
exports.recordedOwner = recordedOwner;
|
|
44
|
+
exports.keptAdminPassword = keptAdminPassword;
|
|
45
|
+
exports.toDocument = toDocument;
|
|
46
|
+
exports.fromDocument = fromDocument;
|
|
47
|
+
exports.serialise = serialise;
|
|
48
|
+
exports.readMeta = readMeta;
|
|
49
|
+
exports.recorded = recorded;
|
|
50
|
+
exports.projectName = projectName;
|
|
51
|
+
exports.write = write;
|
|
52
|
+
exports.writeRecord = writeRecord;
|
|
53
|
+
exports.updateMeta = updateMeta;
|
|
54
|
+
exports.readCompose = readCompose;
|
|
55
|
+
exports.listMeta = listMeta;
|
|
56
|
+
exports.rcServices = rcServices;
|
|
57
|
+
/**
|
|
58
|
+
* `repro.json`: what a workspace wrote down about itself, and how it is read back.
|
|
59
|
+
*
|
|
60
|
+
* The on-disk names are snake_case because that file is a format earlier releases wrote and
|
|
61
|
+
* this build reads unchanged; the TypeScript property names are camelCase because that is
|
|
62
|
+
* what the rest of this tree reads like. `META_FIELDS` is the one table that maps between
|
|
63
|
+
* them, so a typo breaks both directions at once and the round-trip test sees it -- two
|
|
64
|
+
* hand-written mappings is how a field silently stops surviving a write.
|
|
65
|
+
*/
|
|
66
|
+
const fs = __importStar(require("node:fs/promises"));
|
|
67
|
+
const path = __importStar(require("node:path"));
|
|
68
|
+
const config = __importStar(require("../../lib/config"));
|
|
69
|
+
const errors_1 = require("../../lib/errors");
|
|
70
|
+
const home_1 = require("../../lib/home");
|
|
71
|
+
const format_1 = require("../../lib/format");
|
|
72
|
+
const json_text_1 = require("../../lib/json-text");
|
|
73
|
+
const locks_1 = require("./locks");
|
|
74
|
+
const paths = __importStar(require("./paths"));
|
|
75
|
+
/**
|
|
76
|
+
* The record's fields in their established order, with the on-disk key beside the
|
|
77
|
+
* property. ORDER IS PART OF THE FORMAT: a record is written in exactly this order, and a
|
|
78
|
+
* file whose keys are shuffled is a needless diff against every record earlier releases
|
|
79
|
+
* wrote.
|
|
80
|
+
*/
|
|
81
|
+
exports.META_FIELDS = Object.freeze([
|
|
82
|
+
['name', 'name'],
|
|
83
|
+
['project', 'project'],
|
|
84
|
+
['rcVersion', 'rc_version'],
|
|
85
|
+
['rcImage', 'rc_image'],
|
|
86
|
+
['mongoTag', 'mongo_tag'],
|
|
87
|
+
['mongoFlavor', 'mongo_flavor'],
|
|
88
|
+
['preset', 'preset'],
|
|
89
|
+
['rootUrl', 'root_url'],
|
|
90
|
+
['hostPort', 'host_port'],
|
|
91
|
+
['versionSource', 'version_source'],
|
|
92
|
+
['pinned', 'pinned'],
|
|
93
|
+
['createdAt', 'created_at'],
|
|
94
|
+
['publicUrl', 'public_url'],
|
|
95
|
+
['adminPassword', 'admin_password'],
|
|
96
|
+
['extra', 'extra'],
|
|
97
|
+
]);
|
|
98
|
+
/** A record with the established defaults, for the fields that have one. */
|
|
99
|
+
function metadata(values = {}) {
|
|
100
|
+
return {
|
|
101
|
+
name: '',
|
|
102
|
+
project: '',
|
|
103
|
+
rcVersion: '',
|
|
104
|
+
rcImage: '',
|
|
105
|
+
mongoTag: '',
|
|
106
|
+
mongoFlavor: '',
|
|
107
|
+
preset: '',
|
|
108
|
+
rootUrl: '',
|
|
109
|
+
hostPort: 0,
|
|
110
|
+
versionSource: '',
|
|
111
|
+
pinned: false,
|
|
112
|
+
createdAt: '',
|
|
113
|
+
publicUrl: '',
|
|
114
|
+
adminPassword: '',
|
|
115
|
+
extra: {},
|
|
116
|
+
...values,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* What a human or a browser should open -- the https URL if there is one, else the one
|
|
121
|
+
* `--root-url` advertised (a proxy's, a tunnel's), else houston's own loopback address.
|
|
122
|
+
*/
|
|
123
|
+
function externalUrl(meta) {
|
|
124
|
+
// `extra` is null in a hand-edited record, and the detail panel still has to render it.
|
|
125
|
+
const extra = meta.extra;
|
|
126
|
+
return meta.publicUrl || String(extra?.advertised_url ?? '') || meta.rootUrl;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* This workspace's admin password.
|
|
130
|
+
*
|
|
131
|
+
* `config.ADMIN_PASSWORD` is the fixed `admin123`, and loopback is WHY that is
|
|
132
|
+
* acceptable -- `config.DEFAULT_BIND_HOST`'s own comment says so. A workspace reachable
|
|
133
|
+
* beyond loopback removes that premise, so `createRepro` generates one for it and
|
|
134
|
+
* stores it here.
|
|
135
|
+
*
|
|
136
|
+
* Everything that logs in reads THIS, not the constant: houston's own REST calls
|
|
137
|
+
* (readiness, PATs, seeding, settings, load tests) would otherwise all authenticate
|
|
138
|
+
* with `admin123` against a workspace whose admin password is not `admin123`.
|
|
139
|
+
*
|
|
140
|
+
* The empty fallback is not a default so much as a version marker: a repro.json written
|
|
141
|
+
* before this field existed means a workspace whose Rocket.Chat really does run
|
|
142
|
+
* `admin123`, and it has to keep working untouched.
|
|
143
|
+
*/
|
|
144
|
+
function adminPass(meta) {
|
|
145
|
+
return meta.adminPassword || config.ADMIN_PASSWORD;
|
|
146
|
+
}
|
|
147
|
+
/** A host port as a record may spell it: an integer 1024-65535, else null. */
|
|
148
|
+
function hostPort(value) {
|
|
149
|
+
const port = typeof value === 'string' && /^\d+$/u.test(value) ? Number(value) : value;
|
|
150
|
+
return typeof port === 'number' && Number.isInteger(port) && port >= 1024 && port <= 65535
|
|
151
|
+
? port
|
|
152
|
+
: null;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The workspace's side ports, sparse over `config.PRESET_PORTS`: `extra.side_ports` names only
|
|
156
|
+
* the presets whose ports MOVED because another workspace held them. A workspace on the
|
|
157
|
+
* preferred ports, and every record written before ports could move, has no key -- and those
|
|
158
|
+
* presets publish their preferred ports, which is what such a workspace runs.
|
|
159
|
+
*
|
|
160
|
+
* Read it through this, never directly. A hand-edited record is a trust boundary: an entry
|
|
161
|
+
* that is not a registry preset, or not a list of that preset's length of ports 1024-65535,
|
|
162
|
+
* is dropped, so that preset answers its preferred ports rather than a nonsense address.
|
|
163
|
+
*/
|
|
164
|
+
function sidePortsOf(meta) {
|
|
165
|
+
// A record whose `extra` is null is read as having none, as `recordedOwner` reads it.
|
|
166
|
+
const recorded = (meta.extra ?? {}).side_ports;
|
|
167
|
+
if (recorded === null || typeof recorded !== 'object' || Array.isArray(recorded))
|
|
168
|
+
return {};
|
|
169
|
+
const out = {};
|
|
170
|
+
for (const [name, value] of Object.entries(recorded)) {
|
|
171
|
+
const preferred = config.PRESET_PORTS[name];
|
|
172
|
+
if (preferred === undefined || !Array.isArray(value) || value.length !== preferred.length)
|
|
173
|
+
continue;
|
|
174
|
+
const ports = value.map(hostPort);
|
|
175
|
+
if (ports.every((port) => port !== null))
|
|
176
|
+
out[name] = ports;
|
|
177
|
+
}
|
|
178
|
+
return out;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Monitoring's recorded host ports, by POSITION as `extra.monitoring_ports` holds them: Docker
|
|
182
|
+
* publishes `[prometheus, grafana]`, Kubernetes forwards Grafana alone, `[grafana]`. Absent --
|
|
183
|
+
* never monitored, or a public workspace -- is the preferred pair.
|
|
184
|
+
*/
|
|
185
|
+
function monitoringPorts(meta) {
|
|
186
|
+
const recorded = (meta.extra ?? {}).monitoring_ports;
|
|
187
|
+
if (!Array.isArray(recorded) || recorded.length === 0 || recorded.length > 2)
|
|
188
|
+
return [];
|
|
189
|
+
const ports = recorded.map(hostPort);
|
|
190
|
+
return ports.every((port) => port !== null) ? ports : [];
|
|
191
|
+
}
|
|
192
|
+
/** The workspace's Grafana host port: its last recorded monitoring port, else the preferred. */
|
|
193
|
+
function grafanaPortOf(meta) {
|
|
194
|
+
return monitoringPorts(meta).at(-1) ?? config.MONITOR_PORTS[1];
|
|
195
|
+
}
|
|
196
|
+
/** The workspace's Prometheus host port: the first of a recorded pair, else the preferred. */
|
|
197
|
+
function prometheusPortOf(meta) {
|
|
198
|
+
const ports = monitoringPorts(meta);
|
|
199
|
+
return ports.length === 2 ? ports[0] : config.MONITOR_PORTS[0];
|
|
200
|
+
}
|
|
201
|
+
/** Who owns it, as `ownership.ownerOf` reads it, for a message: '' when the record names nobody. */
|
|
202
|
+
function recordedOwner(meta) {
|
|
203
|
+
const extra = meta.extra ?? {};
|
|
204
|
+
const owner = typeof extra.owner === 'string' && extra.owner !== '' ? extra.owner : extra.created_by;
|
|
205
|
+
return typeof owner === 'string' ? owner : '';
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* The admin password a workspace brought back with its data must keep, or null when there is
|
|
209
|
+
* no record. Rocket.Chat reads ADMIN_PASS only when it first fills an empty database, so a new
|
|
210
|
+
* one minted on a rebuild was recorded and accepted by nothing: after `up --force`, or `up`
|
|
211
|
+
* after `down` on Kubernetes, every `api`, `token` and `seed` answered 401.
|
|
212
|
+
*
|
|
213
|
+
* ponytail: a loopback workspace rebuilt public keeps its database's shared password; houston
|
|
214
|
+
* now says so instead of printing one that does not work. Changing it takes the admin API.
|
|
215
|
+
*/
|
|
216
|
+
async function keptAdminPassword(name) {
|
|
217
|
+
try {
|
|
218
|
+
return (await readMeta(name)).adminPassword;
|
|
219
|
+
}
|
|
220
|
+
catch {
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/** The record as the JSON document that goes on disk, in the established field order. */
|
|
225
|
+
function toDocument(meta) {
|
|
226
|
+
const document = {};
|
|
227
|
+
for (const [property, key] of exports.META_FIELDS)
|
|
228
|
+
document[key] = meta[property];
|
|
229
|
+
return document;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* A document from disk as a record.
|
|
233
|
+
*
|
|
234
|
+
* Unknown keys are dropped rather than raising: a repro.json written by a NEWER houston
|
|
235
|
+
* carrying an added field would otherwise fail, and `listMeta` swallows that -- silently
|
|
236
|
+
* making the repro vanish from `houston list`.
|
|
237
|
+
*/
|
|
238
|
+
function fromDocument(document) {
|
|
239
|
+
const values = {};
|
|
240
|
+
const kept = [];
|
|
241
|
+
for (const [property, key] of exports.META_FIELDS) {
|
|
242
|
+
if (Object.prototype.hasOwnProperty.call(document, key)) {
|
|
243
|
+
values[property] = document[key];
|
|
244
|
+
const held = (0, json_text_1.spelled)(document, key);
|
|
245
|
+
if (held !== document[key])
|
|
246
|
+
kept.push([property, key, document[key], held]);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
const meta = metadata(values);
|
|
250
|
+
if (kept.length > 0)
|
|
251
|
+
READ_SPELLINGS.set(meta, kept);
|
|
252
|
+
return meta;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* What `fromDocument` copied out of a document that the copy could not hold, per record.
|
|
256
|
+
*
|
|
257
|
+
* A float read stays a float, and each field is written back as it was read: a hand-edited
|
|
258
|
+
* `"host_port": 3100.0` or `"pinned": 1.0` has always survived every record update. `loads`
|
|
259
|
+
* keeps that spelling beside the DOCUMENT, and the fields are copied out of it onto the
|
|
260
|
+
* record, so a rewrite through this build -- a Kubernetes `stop` dropping its port-forward
|
|
261
|
+
* pid, a `chown`, an `env --set` -- wrote `3100` and `1`. The nested
|
|
262
|
+
* `extra` needed nothing: it is the object `loads` built, table and all.
|
|
263
|
+
*
|
|
264
|
+
* Kept beside the record rather than in it, for the reason `json-text` keeps it beside the
|
|
265
|
+
* value: `hostPort` is a number to every reader, and only the writer needs to know more.
|
|
266
|
+
* `serialise` writes a field's spelling while the field still holds what was read, and the
|
|
267
|
+
* field itself once something has changed it.
|
|
268
|
+
*/
|
|
269
|
+
const READ_SPELLINGS = new WeakMap();
|
|
270
|
+
/**
|
|
271
|
+
* The record in the bytes earlier releases write it in -- indented by 2, fields in order --
|
|
272
|
+
* byte for byte.
|
|
273
|
+
*
|
|
274
|
+
* `JSON.stringify` wrote the same document in different bytes: raw UTF-8 where the
|
|
275
|
+
* established form writes `\u00e9` (everything past ASCII escaped), `null` where it writes
|
|
276
|
+
* `NaN` or `Infinity` -- which a later read got back as null -- and `1e-7` where the
|
|
277
|
+
* established float spelling is `1e-07`. And because `updateMeta` rewrites the whole file,
|
|
278
|
+
* one `chown` or `env --set` through this build re-spelled every character and number an
|
|
279
|
+
* earlier release had written, in every workspace it touched. Every writer of repro.json
|
|
280
|
+
* goes through this one, the Kubernetes path's included.
|
|
281
|
+
*/
|
|
282
|
+
function serialise(meta) {
|
|
283
|
+
const document = toDocument(meta);
|
|
284
|
+
for (const [property, key, read, held] of READ_SPELLINGS.get(meta) ?? []) {
|
|
285
|
+
if (Object.is(meta[property], read))
|
|
286
|
+
document[key] = held;
|
|
287
|
+
}
|
|
288
|
+
return (0, json_text_1.dumps)(document, { indent: 2 });
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Load a repro's metadata.
|
|
292
|
+
*
|
|
293
|
+
* A TYPED error, not a raw ENOENT. `exists` accepts either marker and this needs
|
|
294
|
+
* repro.json, so a directory left with only a compose file -- a SIGKILL, an OOM or a
|
|
295
|
+
* host reboot between the two writes -- resolved fine and then raised out of
|
|
296
|
+
* `detail`/`describe` on the request thread, which in `serve` is a 500 with a stack trace
|
|
297
|
+
* rather than the documented ReproError -> status mapping. It is now a 404 that says
|
|
298
|
+
* how to finish or remove it.
|
|
299
|
+
*/
|
|
300
|
+
async function readMeta(name) {
|
|
301
|
+
const record = (0, home_1.joinPath)(paths.workspace(name), 'repro.json');
|
|
302
|
+
// Whether it exists, then its text, read as strict UTF-8 and parsed by `loads`. A read
|
|
303
|
+
// that failed for ANY reason was "no repro.json" here (exit 4, and skipped by `list`),
|
|
304
|
+
// where only absence is that: a record that may not be read, a directory in its place,
|
|
305
|
+
// or bytes that are not UTF-8 are each an unhandled error naming the file, exit 1, as they
|
|
306
|
+
// always were -- and a NaN in it is a value to
|
|
307
|
+
// `loads`, where JSON.parse refused the record.
|
|
308
|
+
if (!(0, format_1.pathExists)(record)) {
|
|
309
|
+
throw new errors_1.MissingRecordError(`${(0, format_1.quotedText)(name)} has no repro.json, so it is a half-written workspace rather than one ` +
|
|
310
|
+
`houston can act on — finish it with \`houston up --version <version> --name ${name}\`, or remove ` +
|
|
311
|
+
`it with \`houston down --name ${name} --volumes\``);
|
|
312
|
+
}
|
|
313
|
+
let bytes;
|
|
314
|
+
try {
|
|
315
|
+
bytes = await fs.readFile(record);
|
|
316
|
+
}
|
|
317
|
+
catch (error) {
|
|
318
|
+
throw (0, format_1.fileErrorOf)(error, record);
|
|
319
|
+
}
|
|
320
|
+
const blob = (0, json_text_1.loads)((0, format_1.decodeUtf8Strict)(bytes, record));
|
|
321
|
+
if (blob === null || typeof blob !== 'object' || Array.isArray(blob)) {
|
|
322
|
+
throw new TypeError('repro.json is not a JSON object');
|
|
323
|
+
}
|
|
324
|
+
// A Metadata from the document: the ten fields with no default are REQUIRED, and a record
|
|
325
|
+
// missing one is refused, naming them -- a truncated repro.json is not a workspace with empty
|
|
326
|
+
// fields. An earlier version filled defaults, so `info --json` on `{"name": "trunc"}`
|
|
327
|
+
// answered ok:true.
|
|
328
|
+
const missing = REQUIRED_FIELDS.filter((key) => !Object.hasOwn(blob, key));
|
|
329
|
+
if (missing.length > 0) {
|
|
330
|
+
const list = missing.length <= 2
|
|
331
|
+
? missing.join(' and ')
|
|
332
|
+
: `${missing.slice(0, -1).join(', ')}, and ${missing[missing.length - 1] ?? ''}`;
|
|
333
|
+
throw new TypeError(`${record} is missing ${String(missing.length)} required ` +
|
|
334
|
+
`field${missing.length === 1 ? '' : 's'}: ${list}`);
|
|
335
|
+
}
|
|
336
|
+
return fromDocument(blob);
|
|
337
|
+
}
|
|
338
|
+
/** The record fields with no default, in declaration order. */
|
|
339
|
+
const REQUIRED_FIELDS = Object.freeze([
|
|
340
|
+
'name',
|
|
341
|
+
'project',
|
|
342
|
+
'rc_version',
|
|
343
|
+
'rc_image',
|
|
344
|
+
'mongo_tag',
|
|
345
|
+
'mongo_flavor',
|
|
346
|
+
'preset',
|
|
347
|
+
'root_url',
|
|
348
|
+
'host_port',
|
|
349
|
+
'version_source',
|
|
350
|
+
]);
|
|
351
|
+
/**
|
|
352
|
+
* A value this workspace WROTE DOWN when it was created, or "" if there is none.
|
|
353
|
+
*
|
|
354
|
+
* Reads the record field first and falls back to the `extra` bag, because the three
|
|
355
|
+
* identities that matter here were persisted in two different places for historical
|
|
356
|
+
* reasons and a caller should not have to know which.
|
|
357
|
+
*
|
|
358
|
+
* Never throws. Every caller has a mint-time default to fall back on, and a workspace
|
|
359
|
+
* that is half-written, unreadable, or written by a newer houston must degrade to
|
|
360
|
+
* "derive it" rather than turn a name lookup into an error.
|
|
361
|
+
*/
|
|
362
|
+
async function recorded(name, field) {
|
|
363
|
+
let meta;
|
|
364
|
+
try {
|
|
365
|
+
meta = await readMeta(name);
|
|
366
|
+
}
|
|
367
|
+
catch {
|
|
368
|
+
return '';
|
|
369
|
+
}
|
|
370
|
+
// EITHER SPELLING FINDS THE RECORD'S OWN FIELD. Every caller of this helper names the
|
|
371
|
+
// value by its on-disk key -- `public_url`, `project`, `namespace` -- and the bare-key
|
|
372
|
+
// lookup found nothing for `public_url`, so it silently fell through to the `extra` bag.
|
|
373
|
+
// Mapping through META_FIELDS first is what makes the record's own field win; the
|
|
374
|
+
// property spelling stays accepted because the record spec already promised it.
|
|
375
|
+
const property = exports.META_FIELDS.find(([name, key]) => key === field || name === field)?.[0];
|
|
376
|
+
// WIDENED TO `unknown` FIRST. The interface's field union carries no `undefined`, so
|
|
377
|
+
// the compiler is sure the missing-key case cannot happen -- and a half-written record
|
|
378
|
+
// is exactly where it does.
|
|
379
|
+
const direct = property === undefined ? undefined : meta[property];
|
|
380
|
+
const value = direct === undefined || direct === null || direct === '' ? meta.extra[field] : direct;
|
|
381
|
+
return value === undefined || value === null || value === false ? '' : String(value);
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* The Compose project this workspace's containers ACTUALLY live under.
|
|
385
|
+
*
|
|
386
|
+
* RECORDED, not derived. `PROJECT_PREFIX` says what a new workspace gets; it does not
|
|
387
|
+
* describe one that already exists. Deriving it here made the prefix and the containers
|
|
388
|
+
* on the daemon two independent sources of truth that merely happened to agree -- and
|
|
389
|
+
* they stop agreeing the moment the prefix changes, which is not hypothetical: this
|
|
390
|
+
* tool was renamed. At that point `list` reads the recorded project and reports the
|
|
391
|
+
* workspace running, while `down` derives a different one and tears down nothing,
|
|
392
|
+
* leaking the containers along with their ports and the customer's Mongo volume.
|
|
393
|
+
*/
|
|
394
|
+
async function projectName(name) {
|
|
395
|
+
return (await recorded(name, 'project')) || paths.mintProjectName(name);
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Write a workspace: its record, its compose document, and any preset-generated files.
|
|
399
|
+
*
|
|
400
|
+
* THE RECORD FIRST, and the order is the whole point. Each write is individually
|
|
401
|
+
* atomic; the PAIR is not, and a kill between them leaves a directory that `exists`
|
|
402
|
+
* accepts. Compose-first left the half that `listMeta` skips and `readMeta` cannot
|
|
403
|
+
* read -- a workspace invisible to `list`, `prune` and port allocation while still
|
|
404
|
+
* occupying its name. Record-first leaves the half that is fully visible and whose
|
|
405
|
+
* compose file `up` regenerates anyway, which is already this tool's contract for that
|
|
406
|
+
* document.
|
|
407
|
+
*
|
|
408
|
+
* A file in `keep` is written only when absent (`Preset.keepFiles`): a person edits it.
|
|
409
|
+
*/
|
|
410
|
+
async function write(name, composeYaml, meta, files = [], keep = new Set()) {
|
|
411
|
+
const ws = paths.workspace(name);
|
|
412
|
+
await fs.mkdir(ws, { recursive: true });
|
|
413
|
+
// The generated compose file carries ADMIN_PASS and, when set, REG_TOKEN, and preset
|
|
414
|
+
// files carry LDAP and MinIO credentials -- all of it written at the process umask,
|
|
415
|
+
// which on a normal box leaves them readable by every local user. Applied on every
|
|
416
|
+
// write, so workspaces created before this are tightened when next touched.
|
|
417
|
+
await paths.restrict(ws);
|
|
418
|
+
await paths.atomicWrite((0, home_1.joinPath)(ws, 'repro.json'), serialise(meta));
|
|
419
|
+
await paths.atomicWrite((0, home_1.joinPath)(ws, 'docker-compose.yml'), composeYaml);
|
|
420
|
+
for (const [relative, content] of files) {
|
|
421
|
+
const target = (0, home_1.joinPath)(ws, relative);
|
|
422
|
+
if (keep.has(relative)) {
|
|
423
|
+
const found = await fs.stat(target).catch(() => null);
|
|
424
|
+
if (found?.isFile() === true)
|
|
425
|
+
continue; // a kept file someone may have edited
|
|
426
|
+
// The empty folder Docker creates at a bind mount whose file was deleted: not an edit.
|
|
427
|
+
// A folder with something in it is someone's, and rmdir refuses it, loudly.
|
|
428
|
+
if (found?.isDirectory() === true)
|
|
429
|
+
await fs.rmdir(target);
|
|
430
|
+
}
|
|
431
|
+
await fs.mkdir(path.dirname(target), { recursive: true });
|
|
432
|
+
// The ADVERTISED url, falling back to the loopback one. A generated file carrying
|
|
433
|
+
// this placeholder is read by a BROWSER, and `meta.rootUrl` is the address houston
|
|
434
|
+
// uses for its own API calls -- always loopback, by contract. Substituting that
|
|
435
|
+
// shipped a livechat demo page that only worked on the machine docker runs on.
|
|
436
|
+
const advertised = String(meta.extra.advertised_url ?? '') || meta.rootUrl;
|
|
437
|
+
await fs.writeFile(target, content.split('{{ROOT_URL}}').join(advertised), 'utf8');
|
|
438
|
+
}
|
|
439
|
+
await paths.restrict(ws); // again: covers the files just written, and their dirs
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Write just `repro.json`, for a workspace that has no compose document.
|
|
443
|
+
*
|
|
444
|
+
* The Kubernetes path has no docker-compose.yml to write, so it called `atomicWrite`
|
|
445
|
+
* directly -- and `restrict` lives in `write`, which it therefore never reached. That
|
|
446
|
+
* left the whole workspace directory at the process umask on the one runtime that ALSO
|
|
447
|
+
* writes `kubernetes/values.yaml` carrying ADMIN_PASS, so a generated per-workspace
|
|
448
|
+
* admin password was readable by every local user.
|
|
449
|
+
*/
|
|
450
|
+
async function writeRecord(name, meta) {
|
|
451
|
+
const ws = paths.workspace(name);
|
|
452
|
+
await fs.mkdir(ws, { recursive: true });
|
|
453
|
+
await paths.restrict(ws);
|
|
454
|
+
await paths.atomicWrite((0, home_1.joinPath)(ws, 'repro.json'), serialise(meta));
|
|
455
|
+
await paths.restrict(ws); // again: covers anything written into it since
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Read-modify-write repro.json under the repro lock.
|
|
459
|
+
*
|
|
460
|
+
* Every other mutator holds this lock while it rewrites the workspace, so a metadata
|
|
461
|
+
* edit that skipped it could be lost by a concurrent `up --force` rewriting the same
|
|
462
|
+
* file from the spec. `mutate(meta)` edits in place.
|
|
463
|
+
*/
|
|
464
|
+
async function updateMeta(name, mutate) {
|
|
465
|
+
return await (0, locks_1.reproLock)(name, async () => {
|
|
466
|
+
const meta = await readMeta(name);
|
|
467
|
+
mutate(meta);
|
|
468
|
+
await paths.atomicWrite((0, home_1.joinPath)(paths.workspace(name), 'repro.json'), serialise(meta));
|
|
469
|
+
return meta;
|
|
470
|
+
}, { timeoutMs: 60000 });
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Load a repro's generated docker-compose.yml as a document, for in-place edits like
|
|
474
|
+
* attaching or detaching the monitoring stack.
|
|
475
|
+
*/
|
|
476
|
+
async function readCompose(name) {
|
|
477
|
+
// Strict UTF-8, as `readMeta` reads the record: an fs error is `fileErrorOf`'s, named for
|
|
478
|
+
// the file, and bytes that are not UTF-8 are a `NotUtf8` refusal. An earlier version let
|
|
479
|
+
// Node's own error out --
|
|
480
|
+
// `Error: ENOENT: ..., open '<path>'` for the compose file a kill between `runner.write`'s
|
|
481
|
+
// two writes leaves missing, and `EISDIR: illegal operation on a directory, read`, which
|
|
482
|
+
// names no file at all -- and read a stray non-UTF-8 byte as U+FFFD, which `env --set` then
|
|
483
|
+
// wrote back.
|
|
484
|
+
const file = (0, home_1.joinPath)(paths.workspace(name), 'docker-compose.yml');
|
|
485
|
+
let bytes;
|
|
486
|
+
try {
|
|
487
|
+
bytes = await fs.readFile(file);
|
|
488
|
+
}
|
|
489
|
+
catch (error) {
|
|
490
|
+
throw (0, format_1.fileErrorOf)(error, file);
|
|
491
|
+
}
|
|
492
|
+
const raw = (0, format_1.decodeUtf8Strict)(bytes, file);
|
|
493
|
+
// `safeLoadYaml`, the YAML 1.1 grammar cell for cell. This read was YAML 1.2, and the file
|
|
494
|
+
// it reads is the one the YAML 1.1 emitter wrote for every workspace an earlier release
|
|
495
|
+
// made: it leaves `1e8`, `0o17`, `1e-3`, `-.5` and `1e+8` unquoted, since YAML 1.1 types
|
|
496
|
+
// none of them as numbers, and YAML 1.2 types every one -- so `info` showed
|
|
497
|
+
// `up --env X=1e8` as `100000000`, and `monitor attach` and `env --set` wrote it back
|
|
498
|
+
// that way, changing the value in the container.
|
|
499
|
+
// A stray bare `yes` is a boolean here, as YAML 1.1 has it; `compose.ts` quotes one.
|
|
500
|
+
// Timestamps stay text, because this document is written back (`YAML11_TIMESTAMP_TEXT`).
|
|
501
|
+
const document = config.safeLoadYaml(raw, { timestampsAsText: true });
|
|
502
|
+
return document === null || typeof document !== 'object' || Array.isArray(document)
|
|
503
|
+
? {}
|
|
504
|
+
: document;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* The records under `repros/`, sorted by code point. A directory reached through a SYMLINK
|
|
508
|
+
* is one (`pathIsDir` follows the link, where a Dirent does not, and the workspace vanished
|
|
509
|
+
* from `list`, from `prune` and from port allocation); a `repros/` that cannot be listed
|
|
510
|
+
* is an error, not an empty box; and only the records a half-written or foreign directory
|
|
511
|
+
* leaves -- none, one that is not JSON, one that is not a Metadata -- are skipped. Anything
|
|
512
|
+
* else is the error it is.
|
|
513
|
+
*/
|
|
514
|
+
async function listMeta() {
|
|
515
|
+
const root = config.reprosDir();
|
|
516
|
+
if (!(0, format_1.pathExists)(root))
|
|
517
|
+
return [];
|
|
518
|
+
let names;
|
|
519
|
+
try {
|
|
520
|
+
names = await fs.readdir(root);
|
|
521
|
+
}
|
|
522
|
+
catch (error) {
|
|
523
|
+
throw (0, format_1.fileErrorOf)(error, root);
|
|
524
|
+
}
|
|
525
|
+
const out = [];
|
|
526
|
+
for (const name of names.sort(format_1.compareCodePoints)) {
|
|
527
|
+
if (!(0, format_1.pathIsDir)((0, home_1.joinPath)(root, name)))
|
|
528
|
+
continue;
|
|
529
|
+
try {
|
|
530
|
+
out.push(await readMeta(name));
|
|
531
|
+
}
|
|
532
|
+
catch (error) {
|
|
533
|
+
if (error instanceof errors_1.MissingRecordError ||
|
|
534
|
+
error instanceof json_text_1.JsonSyntaxError ||
|
|
535
|
+
error instanceof TypeError) {
|
|
536
|
+
continue; // skip half-written / foreign dirs
|
|
537
|
+
}
|
|
538
|
+
throw error;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
return out;
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* The repro's Rocket.Chat service names, read from its compose file.
|
|
545
|
+
*
|
|
546
|
+
* A multi-instance repro has rocketchat-1..N rather than one `rocketchat`, and
|
|
547
|
+
* quiescing only the first would leave the others writing during a dump.
|
|
548
|
+
*/
|
|
549
|
+
async function rcServices(name) {
|
|
550
|
+
let document;
|
|
551
|
+
try {
|
|
552
|
+
document = await readCompose(name);
|
|
553
|
+
}
|
|
554
|
+
catch {
|
|
555
|
+
return [];
|
|
556
|
+
}
|
|
557
|
+
const services = document.services;
|
|
558
|
+
if (services === null || typeof services !== 'object')
|
|
559
|
+
return [];
|
|
560
|
+
return Object.keys(services)
|
|
561
|
+
.filter((service) => service === 'rocketchat' || service.startsWith('rocketchat-'))
|
|
562
|
+
.sort();
|
|
563
|
+
}
|