@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,635 @@
|
|
|
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.reproState = reproState;
|
|
37
|
+
exports.kubernetesState = kubernetesState;
|
|
38
|
+
exports.degradedReason = degradedReason;
|
|
39
|
+
exports.uptimeHealth = uptimeHealth;
|
|
40
|
+
exports.forwardGap = forwardGap;
|
|
41
|
+
exports.reproLinks = reproLinks;
|
|
42
|
+
exports.grafanaUrlOf = grafanaUrlOf;
|
|
43
|
+
exports.grafanaFrameOrigins = grafanaFrameOrigins;
|
|
44
|
+
exports.clusterOf = clusterOf;
|
|
45
|
+
exports.summary = summary;
|
|
46
|
+
exports.describe = describe;
|
|
47
|
+
exports.rowFor = rowFor;
|
|
48
|
+
exports.listRepros = listRepros;
|
|
49
|
+
/**
|
|
50
|
+
* What a workspace IS right now: its state, its health, its links, and the list.
|
|
51
|
+
*
|
|
52
|
+
* Tier 3. Reads the on-disk record and the engine; never changes either. `detail` lives next
|
|
53
|
+
* door in `payload` because it is the payload-shape trap -- the browser suite renders from a
|
|
54
|
+
* fixture of it, so a key that drifts from what this layer really returns breaks the panel in
|
|
55
|
+
* production with the whole suite green.
|
|
56
|
+
*/
|
|
57
|
+
const config = __importStar(require("../../lib/config"));
|
|
58
|
+
const map_limit_1 = require("../../lib/map-limit");
|
|
59
|
+
const monitoring_1 = require("../../lib/monitoring");
|
|
60
|
+
const capabilities_1 = require("../kube/capabilities");
|
|
61
|
+
const context_1 = require("../kube/context");
|
|
62
|
+
const forward_1 = require("../kube/forward");
|
|
63
|
+
const names_1 = require("../kube/names");
|
|
64
|
+
const namespace_1 = require("../kube/namespace");
|
|
65
|
+
const release_1 = require("../kube/release");
|
|
66
|
+
const status_1 = require("../kube/status");
|
|
67
|
+
const host_1 = require("../runner/host");
|
|
68
|
+
const queries_1 = require("../runner/queries");
|
|
69
|
+
const record_1 = require("../runner/record");
|
|
70
|
+
const topology = __importStar(require("../topology"));
|
|
71
|
+
const naming = __importStar(require("./naming"));
|
|
72
|
+
const notes = __importStar(require("./notes"));
|
|
73
|
+
const request_1 = require("./request");
|
|
74
|
+
const types_1 = require("./types");
|
|
75
|
+
const common_1 = require("../../lib/presets/common");
|
|
76
|
+
const composite_1 = require("../../lib/presets/composite");
|
|
77
|
+
const public_1 = require("../../lib/presets/public");
|
|
78
|
+
const versions_1 = require("../../lib/versions");
|
|
79
|
+
function bag(value) {
|
|
80
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
81
|
+
? value
|
|
82
|
+
: {};
|
|
83
|
+
}
|
|
84
|
+
function isTruthy(value) {
|
|
85
|
+
if (value === null || value === undefined || value === false)
|
|
86
|
+
return false;
|
|
87
|
+
if (typeof value === 'string')
|
|
88
|
+
return value !== '';
|
|
89
|
+
if (typeof value === 'number')
|
|
90
|
+
return value !== 0;
|
|
91
|
+
if (Array.isArray(value))
|
|
92
|
+
return value.length > 0;
|
|
93
|
+
if (typeof value === 'object')
|
|
94
|
+
return Object.keys(value).length > 0;
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* The state to report for a repro, from its Rocket.Chat container's docker `Status`
|
|
99
|
+
* string ("Up 2 hours (healthy)", "Restarting (1) 5 seconds ago", ...).
|
|
100
|
+
*
|
|
101
|
+
* BOTH the list and the detail panel must derive state from this, because they used to
|
|
102
|
+
* disagree. The list read compose's PROJECT-level aggregate, where the always-running
|
|
103
|
+
* Mongo put "running(" in the string and made a crash-looping RC report "running"; the
|
|
104
|
+
* panel checked only whether RC was literally "running" and flattened everything else to
|
|
105
|
+
* "stopped".
|
|
106
|
+
*
|
|
107
|
+
* `hasContainers` separates "the stack is gone" (down) from "containers exist but
|
|
108
|
+
* Rocket.Chat has none" (stopped).
|
|
109
|
+
*/
|
|
110
|
+
function reproState(rcStatus, hasContainers) {
|
|
111
|
+
const s = (rcStatus || '').trim();
|
|
112
|
+
if (!s)
|
|
113
|
+
return hasContainers ? 'stopped' : 'down';
|
|
114
|
+
const low = s.toLowerCase();
|
|
115
|
+
if (low.startsWith('up')) {
|
|
116
|
+
// docker reports a paused container as "Up 3 days (Paused)".
|
|
117
|
+
return low.includes('(paused)') ? 'paused' : 'running';
|
|
118
|
+
}
|
|
119
|
+
if (low.startsWith('exited'))
|
|
120
|
+
return 'stopped';
|
|
121
|
+
// "Restarting (1) 5 seconds ago" -> restarting; "Created"/"Dead" -> as-is.
|
|
122
|
+
return low.split(' (')[0]?.split(' ')[0] || 'down';
|
|
123
|
+
}
|
|
124
|
+
const scopedKubernetesReads = {
|
|
125
|
+
workloadReplicas: status_1.workloadReplicas,
|
|
126
|
+
workspaceReady: status_1.workspaceReady,
|
|
127
|
+
terminalPodFailure: status_1.terminalPodFailure,
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* `running` / `down` for a Kubernetes workspace.
|
|
131
|
+
*
|
|
132
|
+
* `reproState()` asks docker whether the project's containers exist, so it called a live
|
|
133
|
+
* Kubernetes workspace `down` -- the state column was reporting on the wrong runtime
|
|
134
|
+
* entirely.
|
|
135
|
+
*/
|
|
136
|
+
async function kubernetesState(name, meta, namespaces = capabilities_1.workspaceNamespaces, reads = scopedKubernetesReads) {
|
|
137
|
+
const extra = bag(meta.extra);
|
|
138
|
+
const context = isTruthy(extra[config.EXTRA_CONTEXT])
|
|
139
|
+
? String(extra[config.EXTRA_CONTEXT])
|
|
140
|
+
: names_1.CONTEXT;
|
|
141
|
+
// "?" ON A REFUSED READ, which is the word the Docker branch one function up already
|
|
142
|
+
// uses when the daemon is unreachable. Without it a healthy workspace read as `down`
|
|
143
|
+
// whenever the cluster could not be asked. `down` is the word that invites `up --force`
|
|
144
|
+
// and `down --volumes`, so it is the worst available guess.
|
|
145
|
+
//
|
|
146
|
+
// ONE ROUND OF QUESTIONS, NOT FOUR IN A ROW. On EKS every kubectl call first fetches a
|
|
147
|
+
// token, so asking the namespace, the workload, its replicas and its pods one after
|
|
148
|
+
// another made each `list` -- which the GUI asks for every four seconds -- and each
|
|
149
|
+
// workspace panel cost four round trips. The three reads are independent; their answers
|
|
150
|
+
// are taken in the order the rule needs, so a missing namespace still decides first and
|
|
151
|
+
// a refused workload read still raises only once the namespace is known to be there.
|
|
152
|
+
const [held, workload, ready] = await Promise.all([
|
|
153
|
+
namespaces(context),
|
|
154
|
+
reads.workloadReplicas(name, { context }).then((replicas) => ({ replicas, failure: null }), (failure) => ({ replicas: null, failure })),
|
|
155
|
+
reads.workspaceReady(name, { context }),
|
|
156
|
+
]);
|
|
157
|
+
if (held === null)
|
|
158
|
+
return '?';
|
|
159
|
+
if (!held.includes(await (0, namespace_1.namespaceFor)(name)))
|
|
160
|
+
return 'down';
|
|
161
|
+
if (workload.failure !== null)
|
|
162
|
+
throw workload.failure;
|
|
163
|
+
// The namespace EXISTING is not the workspace running. A plain `down` keeps the
|
|
164
|
+
// namespace and its PVC on purpose and uninstalls the release, so a torn-down workspace
|
|
165
|
+
// reported "starting" -- and would have reported it forever.
|
|
166
|
+
if (workload.replicas === null)
|
|
167
|
+
return 'down';
|
|
168
|
+
// Scaled to zero is STOPPED, not starting. `stop` is implemented as scale-to-zero and
|
|
169
|
+
// without this the column said "starting" for a workspace that was deliberately
|
|
170
|
+
// stopped and was never going to move.
|
|
171
|
+
if (workload.replicas === 0)
|
|
172
|
+
return 'stopped';
|
|
173
|
+
if (ready)
|
|
174
|
+
return 'running';
|
|
175
|
+
// NOT-READY IS NOT ALWAYS STARTING. For a wedged `pending-install` release or a pod in
|
|
176
|
+
// ImagePullBackOff / CreateContainerConfigError nothing is coming. A refused read must
|
|
177
|
+
// not manufacture a failure, so each probe is guarded and falls back to the honest
|
|
178
|
+
// "starting".
|
|
179
|
+
try {
|
|
180
|
+
if ((await reads.terminalPodFailure(name, { context })) !== null)
|
|
181
|
+
return 'failed';
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
// a refused probe is not evidence of failure
|
|
185
|
+
}
|
|
186
|
+
try {
|
|
187
|
+
const [state] = await (0, release_1.releaseState)(names_1.RELEASE, await (0, namespace_1.namespaceFor)(name), context);
|
|
188
|
+
if (release_1.PENDING_STATES.includes(state) || state === 'failed')
|
|
189
|
+
return 'failed';
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
// same
|
|
193
|
+
}
|
|
194
|
+
return 'starting';
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Why a workspace that LOOKS running is not usable, or "".
|
|
198
|
+
*
|
|
199
|
+
* `services` is {service: docker Status string}. Reported as a distinct health rather
|
|
200
|
+
* than as a state, because the workspace genuinely is running -- what is wrong is that
|
|
201
|
+
* something it needs is not.
|
|
202
|
+
*/
|
|
203
|
+
function degradedReason(services) {
|
|
204
|
+
for (const svc of types_1.ESSENTIAL_SERVICES) {
|
|
205
|
+
const status = services[svc];
|
|
206
|
+
if (status !== undefined && !status.startsWith('Up ')) {
|
|
207
|
+
const first = status.split(' (')[0]?.trim().toLowerCase() || 'not running';
|
|
208
|
+
return `${svc} is ${first}`;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return '';
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Parse a docker `Status` string -> (uptime, health).
|
|
215
|
+
* "Up 2 hours (healthy)" -> ("2 hours", "healthy"); "Exited (0) ..." -> ("", "").
|
|
216
|
+
*/
|
|
217
|
+
function uptimeHealth(status) {
|
|
218
|
+
if (!status)
|
|
219
|
+
return ['', ''];
|
|
220
|
+
const match = /\(([^)]+)\)/u.exec(status);
|
|
221
|
+
let health = match !== null && status.startsWith('Up ') ? match[1] : '';
|
|
222
|
+
// Docker spells the transitional one "health: starting" inside the Status string, and
|
|
223
|
+
// a bare "healthy"/"unhealthy" for the settled ones. Taken verbatim the panel rendered
|
|
224
|
+
// "Health: health: starting".
|
|
225
|
+
if (health.startsWith('health: '))
|
|
226
|
+
health = health.slice('health: '.length);
|
|
227
|
+
const up = status.startsWith('Up ') ? (status.slice(3).split(' (')[0]?.trim() ?? '') : '';
|
|
228
|
+
return [up, health];
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Why a running Kubernetes workspace's URL will not answer, or "".
|
|
232
|
+
*
|
|
233
|
+
* Only where a pid was actually recorded: `forwardAlive(null)` is false, and reading that
|
|
234
|
+
* as "nothing is running" is the confusion this release spent itself removing.
|
|
235
|
+
*/
|
|
236
|
+
async function forwardGap(meta) {
|
|
237
|
+
const extra = bag(meta.extra);
|
|
238
|
+
const pid = extra.port_forward_pid;
|
|
239
|
+
if (!isTruthy(pid))
|
|
240
|
+
return '';
|
|
241
|
+
const ns = isTruthy(extra.namespace) ? String(extra.namespace) : await (0, namespace_1.namespaceFor)(meta.name);
|
|
242
|
+
if (await (0, forward_1.forwardAlive)(Number(pid), { namespace: ns, hostPort: meta.hostPort }))
|
|
243
|
+
return '';
|
|
244
|
+
return ('no port-forward, so the URL will not answer — ' +
|
|
245
|
+
`\`houston ready --name ${meta.name}\` re-establishes it`);
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Clickable URLs for a repro: RC, extra instances, preset sidecars (S3, Keycloak,
|
|
249
|
+
* Mailpit, widget), and monitoring -- [{label, url, kind}].
|
|
250
|
+
*/
|
|
251
|
+
/**
|
|
252
|
+
* A composed workspace's presets as a list, for a reader that should not split the string.
|
|
253
|
+
* ABSENT for one preset, so every other workspace's payload is byte for byte what it was.
|
|
254
|
+
*/
|
|
255
|
+
function presetsOf(meta) {
|
|
256
|
+
const names = (0, composite_1.namesOf)(scenarioOf(meta));
|
|
257
|
+
return names.length > 1 ? { presets: names } : {};
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* The presets without the deployment. Compose builds multi-instance through that preset, so
|
|
261
|
+
* the record lists it among them, and the panel showed it as a preset chip beside the
|
|
262
|
+
* deployment that already says so: it is the deployment, not a preset.
|
|
263
|
+
*/
|
|
264
|
+
function scenarioOf(meta) {
|
|
265
|
+
return String(topology.axesOfMeta(meta).preset ?? meta.preset);
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* What the panel badges: the CI build a workspace runs (its ghcr tag, or ''), whether it
|
|
269
|
+
* was given a license, and whether Rocket.Chat refused it when `ready` last asked. Always
|
|
270
|
+
* present, so the panel reads one shape.
|
|
271
|
+
*/
|
|
272
|
+
function buildAndLicense(meta) {
|
|
273
|
+
const prefix = `${versions_1.BUILD_IMAGE}:`;
|
|
274
|
+
const tag = meta.rcImage.startsWith(prefix) ? meta.rcImage.slice(prefix.length) : '';
|
|
275
|
+
const extra = bag(meta.extra);
|
|
276
|
+
return {
|
|
277
|
+
ci_build: (0, versions_1.isBuildTag)(tag) ? tag : '',
|
|
278
|
+
licensed: extra.licensed === true,
|
|
279
|
+
license_refused: extra.license_status === 'refused',
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
/** The side ports and replicas are published on the workspace's recorded bind. */
|
|
283
|
+
function linkHost(meta) {
|
|
284
|
+
const recorded = bag(meta.extra).bind_host;
|
|
285
|
+
if (typeof recorded === 'string' && recorded.trim() !== '')
|
|
286
|
+
return (0, request_1.callHost)(recorded);
|
|
287
|
+
// Older records predate bind_host but already carry the address readiness uses.
|
|
288
|
+
try {
|
|
289
|
+
return (0, request_1.callHost)(new URL(meta.rootUrl).hostname);
|
|
290
|
+
}
|
|
291
|
+
catch {
|
|
292
|
+
return 'localhost';
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
function reproLinks(meta) {
|
|
296
|
+
const links = [{ label: 'Rocket.Chat', url: (0, record_1.externalUrl)(meta), kind: 'rc' }];
|
|
297
|
+
const extra = bag(meta.extra);
|
|
298
|
+
const host = linkHost(meta);
|
|
299
|
+
if ((0, record_1.externalUrl)(meta) !== meta.rootUrl) {
|
|
300
|
+
// Keep the plain http way in as well: with the local CA the browser warns until
|
|
301
|
+
// `trust-ca` has run, and behind a proxy or tunnel this is the link that works here.
|
|
302
|
+
links.push({ label: 'direct HTTP', url: meta.rootUrl, kind: 'rc' });
|
|
303
|
+
}
|
|
304
|
+
const n = extra.instances;
|
|
305
|
+
if (typeof n === 'number' && Number.isInteger(n) && n > 1) {
|
|
306
|
+
for (let i = 1; i <= n; i += 1) {
|
|
307
|
+
links.push({
|
|
308
|
+
label: `instance ${String(i)}`,
|
|
309
|
+
url: `http://${host}:${String(meta.hostPort + i)}`,
|
|
310
|
+
kind: 'rc',
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
// Every preset of a composed workspace, in its canonical order, on ITS ports: a second
|
|
315
|
+
// workspace with the same preset was given others, and the registry's open someone else's.
|
|
316
|
+
const held = (0, record_1.sidePortsOf)(meta);
|
|
317
|
+
for (const name of (0, composite_1.namesOf)(meta.preset)) {
|
|
318
|
+
const linked = types_1.PRESET_LINKS[name] ?? [];
|
|
319
|
+
const ports = linked.length > 0 ? (0, common_1.presetPorts)(name, held) : [];
|
|
320
|
+
for (const [label, idx] of linked) {
|
|
321
|
+
if (idx < ports.length) {
|
|
322
|
+
links.push({ label, url: `http://${host}:${String(ports[idx])}`, kind: 'sidecar' });
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
// The webhook inbox, at the session the receiver chose: linked once post-ready recorded
|
|
327
|
+
// it, because the receiver's root page would open a new, empty one.
|
|
328
|
+
const inbox = notes.inboxUrl(meta);
|
|
329
|
+
if (inbox !== '')
|
|
330
|
+
links.push({ label: 'Webhook inbox', url: inbox, kind: 'sidecar' });
|
|
331
|
+
// ldap's OWN Keycloak, when it federates the directory (`--set idp=saml|oidc`): it is
|
|
332
|
+
// published on the IdP preset's port, and linked by preset name only, so the console that
|
|
333
|
+
// holds the directory's SSO users had no link -- unless HTTPS added its path.
|
|
334
|
+
if ((0, composite_1.namesOf)(meta.preset).includes('ldap') && !links.some((link) => link.label === 'Keycloak')) {
|
|
335
|
+
const idp = String(bag(extra.params).idp ?? bag(bag(extra.preset_params).ldap).idp ?? '').toLowerCase();
|
|
336
|
+
const port = idp === 'saml' || idp === 'oidc' ? (0, common_1.presetPort)(idp, 0, held) : undefined;
|
|
337
|
+
if (port !== undefined) {
|
|
338
|
+
links.push({ label: 'Keycloak', url: `http://${host}:${String(port)}`, kind: 'sidecar' });
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
// Over HTTPS, a preset's own UIs at paths of the name (`lib/presets/public.ts`). Mailpit,
|
|
342
|
+
// Keycloak and the MinIO console then answer only under their path, so their link IS the
|
|
343
|
+
// public one, as is phpLDAPadmin's; the demo page keeps its own port (the cross-origin one)
|
|
344
|
+
// and gains the same-origin path beside it.
|
|
345
|
+
if (meta.publicUrl) {
|
|
346
|
+
const base = meta.publicUrl.replace(/\/+$/u, '');
|
|
347
|
+
for (const p of (0, public_1.publicPathsOf)(extra)) {
|
|
348
|
+
const url = `${base}${p.path}/`;
|
|
349
|
+
const label = {
|
|
350
|
+
mailpit: 'Mailpit',
|
|
351
|
+
keycloak: 'Keycloak',
|
|
352
|
+
'widget-site': 'Widget site',
|
|
353
|
+
'minio-ui': 'MinIO console',
|
|
354
|
+
phpldapadmin: 'phpLDAPadmin',
|
|
355
|
+
}[p.service] ?? p.service;
|
|
356
|
+
const at = links.findIndex((link) => link.label === label);
|
|
357
|
+
if (p.service !== 'widget-site' && at >= 0)
|
|
358
|
+
links[at] = { label, url, kind: 'sidecar' };
|
|
359
|
+
else
|
|
360
|
+
links.push({
|
|
361
|
+
label: p.service === 'widget-site' ? `${label} (same origin)` : label,
|
|
362
|
+
url,
|
|
363
|
+
kind: 'sidecar',
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
if (isTruthy(extra.monitoring)) {
|
|
368
|
+
links.push({
|
|
369
|
+
label: 'Grafana',
|
|
370
|
+
url: grafanaUrlOf(meta),
|
|
371
|
+
kind: 'monitor',
|
|
372
|
+
});
|
|
373
|
+
// Docker's alone: Kubernetes forwards Grafana and nothing else, so this link led nowhere.
|
|
374
|
+
if (topology.ofMeta(meta) !== topology.KUBERNETES) {
|
|
375
|
+
links.push({
|
|
376
|
+
label: 'Prometheus',
|
|
377
|
+
url: `http://localhost:${String((0, record_1.prometheusPortOf)(meta))}`,
|
|
378
|
+
kind: 'monitor',
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
return links;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Only houston-served TLS publishes Grafana; every cluster stack uses the sub-path. On the
|
|
386
|
+
* workspace's own Grafana port: a second monitored workspace's is not the preferred one.
|
|
387
|
+
*/
|
|
388
|
+
function grafanaUrlOf(meta) {
|
|
389
|
+
const publicUrl = isTruthy(bag(meta.extra).tls) ? meta.publicUrl : '';
|
|
390
|
+
return (0, monitoring_1.grafanaUrl)(publicUrl, topology.ofMeta(meta) === topology.KUBERNETES || !!publicUrl, (0, record_1.grafanaPortOf)(meta));
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Origins the GUI may embed, derived from monitored workspaces: the public name of one served
|
|
394
|
+
* by houston over HTTPS, and the loopback Grafana of every other, on its own port.
|
|
395
|
+
*/
|
|
396
|
+
async function grafanaFrameOrigins() {
|
|
397
|
+
const origins = new Set();
|
|
398
|
+
for (const meta of await (0, record_1.listMeta)()) {
|
|
399
|
+
if (!isTruthy(bag(meta.extra).monitoring))
|
|
400
|
+
continue;
|
|
401
|
+
try {
|
|
402
|
+
const url = new URL(grafanaUrlOf(meta));
|
|
403
|
+
if (url.protocol === 'https:' || url.hostname === 'localhost')
|
|
404
|
+
origins.add(url.origin);
|
|
405
|
+
}
|
|
406
|
+
catch {
|
|
407
|
+
// A hand-edited invalid URL grants no iframe origin.
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
return [...origins].sort();
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* DERIVED here, not read out of the record. Every workspace created before the groups
|
|
414
|
+
* existed -- and every workspace created before the next wording fix -- gets the current
|
|
415
|
+
* shape and the current words, because this is a read.
|
|
416
|
+
*
|
|
417
|
+
* The recorded flat list is the fallback, and it is only reached by a workspace that has
|
|
418
|
+
* notes no group accounts for (a preset that has since been deleted, a note some older
|
|
419
|
+
* release appended by hand).
|
|
420
|
+
*/
|
|
421
|
+
/**
|
|
422
|
+
* The cluster a Kubernetes workspace runs in: the context a command needs, and the short
|
|
423
|
+
* name a person recognises. Both '' for a Compose workspace, and ALWAYS present -- a key
|
|
424
|
+
* that appears only sometimes is how a payload drifts from what the tests render.
|
|
425
|
+
*/
|
|
426
|
+
function clusterOf(meta) {
|
|
427
|
+
const extra = bag(meta.extra);
|
|
428
|
+
if (topology.ofMeta(meta) !== topology.KUBERNETES)
|
|
429
|
+
return { context: '', cluster: '' };
|
|
430
|
+
const context = isTruthy(extra[config.EXTRA_CONTEXT]) ? String(extra[config.EXTRA_CONTEXT]) : '';
|
|
431
|
+
return { context, cluster: context === '' ? '' : (0, context_1.shortName)(context) };
|
|
432
|
+
}
|
|
433
|
+
async function summary(meta) {
|
|
434
|
+
const groups = await notes.noteGroupsOf(meta);
|
|
435
|
+
const extra = bag(meta.extra);
|
|
436
|
+
const recorded = Array.isArray(extra.notes) ? extra.notes : [];
|
|
437
|
+
const d = {
|
|
438
|
+
notes: groups.length > 0 ? notes.flattenNotes(groups) : recorded,
|
|
439
|
+
note_groups: groups,
|
|
440
|
+
name: meta.name,
|
|
441
|
+
rc_version: meta.rcVersion,
|
|
442
|
+
mongo_tag: meta.mongoTag,
|
|
443
|
+
mongo_flavor: meta.mongoFlavor,
|
|
444
|
+
preset: scenarioOf(meta),
|
|
445
|
+
...presetsOf(meta),
|
|
446
|
+
...buildAndLicense(meta),
|
|
447
|
+
root_url: meta.rootUrl,
|
|
448
|
+
// The address a person opens, when the workspace has one: `up`'s result and the GUI's
|
|
449
|
+
// create dialog offered only `root_url`, the http://localhost port, which from any other
|
|
450
|
+
// machine is that machine's own. "" without HTTPS, as the list row and the panel say.
|
|
451
|
+
public_url: meta.publicUrl,
|
|
452
|
+
// What a person OPENS: the https name, else the address `--root-url` advertised (a
|
|
453
|
+
// proxy's, a tunnel's), else the loopback port. Every "Open" took `public_url || root_url`,
|
|
454
|
+
// which behind a tunnel is http://localhost -- the one address nobody outside can use.
|
|
455
|
+
open_url: (0, record_1.externalUrl)(meta),
|
|
456
|
+
host_port: meta.hostPort,
|
|
457
|
+
login: { user: config.ADMIN_USERNAME, password: meta.adminPassword || config.ADMIN_PASSWORD },
|
|
458
|
+
pinned: meta.pinned,
|
|
459
|
+
// Which runtime, and how Rocket.Chat is arranged inside it. `listRepros` has carried
|
|
460
|
+
// the runtime all along and the DETAIL payload had neither, so the panel rendered
|
|
461
|
+
// every workspace as though it were Compose -- and offered actions the Kubernetes
|
|
462
|
+
// path can only refuse.
|
|
463
|
+
runtime: topology.ofMeta(meta),
|
|
464
|
+
deployment: String(topology.axesOfMeta(meta).deployment ?? ''),
|
|
465
|
+
...clusterOf(meta),
|
|
466
|
+
};
|
|
467
|
+
// Whether this workspace HAS sample data, and whether the readback agreed. Always
|
|
468
|
+
// present, never conditional -- a key that appears only sometimes is how the panel's
|
|
469
|
+
// payload drifts from what the tests render.
|
|
470
|
+
const seed = bag(extra.seed);
|
|
471
|
+
d.seed =
|
|
472
|
+
Object.keys(seed).length > 0
|
|
473
|
+
? {
|
|
474
|
+
profile: seed.profile ?? '',
|
|
475
|
+
at: seed.at ?? '',
|
|
476
|
+
ok: bag(seed.verification).ok === true
|
|
477
|
+
? true
|
|
478
|
+
: bag(seed.verification).ok === false
|
|
479
|
+
? false
|
|
480
|
+
: null,
|
|
481
|
+
}
|
|
482
|
+
: null;
|
|
483
|
+
const n = extra.instances;
|
|
484
|
+
if (isTruthy(n)) {
|
|
485
|
+
const count = Number(n);
|
|
486
|
+
d.instances = count;
|
|
487
|
+
d.instance_urls = Array.from({ length: count }, (_unused, index) => `http://${linkHost(meta)}:${String(meta.hostPort + index + 1)}`);
|
|
488
|
+
}
|
|
489
|
+
if (isTruthy(extra.monitoring)) {
|
|
490
|
+
d.monitoring = true;
|
|
491
|
+
d.grafana_url = grafanaUrlOf(meta);
|
|
492
|
+
}
|
|
493
|
+
return d;
|
|
494
|
+
}
|
|
495
|
+
async function describe(name) {
|
|
496
|
+
return await summary(await (0, record_1.readMeta)(await naming.resolveName(name)));
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* One workspace as `list` and the GUI table see it.
|
|
500
|
+
*
|
|
501
|
+
* Its own function because the two runtimes answer "what state is this in" from
|
|
502
|
+
* different places, and the branch that decides is three lines inside fifty.
|
|
503
|
+
*/
|
|
504
|
+
async function rowFor(meta, { default: defaultName, dockerUp, states, statusMap, svcMap, namespaces, kubeReads, }) {
|
|
505
|
+
// Compose's answer is a Docker workspace's alone: one left under a Kubernetes record (as
|
|
506
|
+
// 2.1.1's takeover left them) lent that row its own uptime and health.
|
|
507
|
+
const rcStatus = topology.ofMeta(meta) === topology.KUBERNETES ? '' : (statusMap[meta.project] ?? '');
|
|
508
|
+
// `states` is only consulted for "does this project have ANY container", never for the
|
|
509
|
+
// state itself -- see reproState. A Kubernetes workspace has no compose project, so
|
|
510
|
+
// asking docker whether its containers exist answered `down` for a workspace that was
|
|
511
|
+
// running.
|
|
512
|
+
let state;
|
|
513
|
+
if (topology.ofMeta(meta) === topology.KUBERNETES) {
|
|
514
|
+
state = await kubernetesState(meta.name, meta, namespaces, kubeReads);
|
|
515
|
+
}
|
|
516
|
+
else {
|
|
517
|
+
state = dockerUp ? reproState(rcStatus, Boolean(states[meta.project])) : '?';
|
|
518
|
+
}
|
|
519
|
+
const [uptime, health] = uptimeHealth(rcStatus);
|
|
520
|
+
let degradedWhy;
|
|
521
|
+
if (topology.ofMeta(meta) === topology.KUBERNETES) {
|
|
522
|
+
// `list` printed `running` beside a URL that refused connections, and only `info`
|
|
523
|
+
// said otherwise. A port-forward dies with its pod, so this is the NORMAL state after
|
|
524
|
+
// any restart. Carried in `degraded`, the field both front-ends already render for
|
|
525
|
+
// the Compose side.
|
|
526
|
+
degradedWhy = state === 'running' ? await forwardGap(meta) : '';
|
|
527
|
+
}
|
|
528
|
+
else {
|
|
529
|
+
degradedWhy = state === 'running' ? degradedReason(svcMap[meta.project] ?? {}) : '';
|
|
530
|
+
}
|
|
531
|
+
const degraded = degradedWhy ? 'degraded' : '';
|
|
532
|
+
const runtime = topology.ofMeta(meta);
|
|
533
|
+
const extra = bag(meta.extra);
|
|
534
|
+
const monitored = isTruthy(extra.monitoring);
|
|
535
|
+
const owner = isTruthy(extra.owner)
|
|
536
|
+
? String(extra.owner)
|
|
537
|
+
: isTruthy(extra.created_by)
|
|
538
|
+
? String(extra.created_by)
|
|
539
|
+
: '';
|
|
540
|
+
return {
|
|
541
|
+
name: meta.name,
|
|
542
|
+
created_by: owner,
|
|
543
|
+
owner,
|
|
544
|
+
made_by: isTruthy(extra.created_by) ? String(extra.created_by) : '',
|
|
545
|
+
rc_version: meta.rcVersion,
|
|
546
|
+
mongo_tag: meta.mongoTag,
|
|
547
|
+
host_port: meta.hostPort,
|
|
548
|
+
root_url: meta.rootUrl,
|
|
549
|
+
state,
|
|
550
|
+
runtime,
|
|
551
|
+
...clusterOf(meta),
|
|
552
|
+
// The https URL when `up --https` was used; "" otherwise.
|
|
553
|
+
public_url: meta.publicUrl,
|
|
554
|
+
open_url: (0, record_1.externalUrl)(meta),
|
|
555
|
+
tls: isTruthy(extra.tls) ? String(extra.tls) : '',
|
|
556
|
+
preset: scenarioOf(meta),
|
|
557
|
+
...presetsOf(meta),
|
|
558
|
+
pinned: meta.pinned,
|
|
559
|
+
default: meta.name === defaultName,
|
|
560
|
+
monitoring: monitored,
|
|
561
|
+
created_at: meta.createdAt,
|
|
562
|
+
uptime,
|
|
563
|
+
health: degraded || health || (state === 'running' ? state : ''),
|
|
564
|
+
degraded: degradedWhy,
|
|
565
|
+
grafana_url: monitored ? grafanaUrlOf(meta) : null,
|
|
566
|
+
links: reproLinks(meta),
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
function shareContextRead(probe) {
|
|
570
|
+
const reads = new Map();
|
|
571
|
+
return (context) => {
|
|
572
|
+
const held = reads.get(context);
|
|
573
|
+
if (held !== undefined)
|
|
574
|
+
return held;
|
|
575
|
+
const reading = probe(context);
|
|
576
|
+
reads.set(context, reading);
|
|
577
|
+
return reading;
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
async function listRepros() {
|
|
581
|
+
const metas = await (0, record_1.listMeta)();
|
|
582
|
+
const fallback = config.loadConfig().default_repro;
|
|
583
|
+
const defaultName = isTruthy(fallback) ? String(fallback) : '';
|
|
584
|
+
const dockerUp = await (0, host_1.dockerAvailable)();
|
|
585
|
+
const [states, svcMap] = dockerUp
|
|
586
|
+
? await Promise.all([(0, queries_1.projectStates)().then((value) => value ?? {}), (0, queries_1.servicesByProject)()])
|
|
587
|
+
: [{}, {}];
|
|
588
|
+
// ONE docker ps for every service of every project, so the list and the panel cannot
|
|
589
|
+
// disagree about whether a workspace is degraded -- which is exactly how they came to
|
|
590
|
+
// disagree about `state` before reproState existed.
|
|
591
|
+
const statusMap = dockerUp ? await (0, queries_1.rcStatusByProject)(svcMap) : {};
|
|
592
|
+
// Share a cluster read only within this list. Every poll asks again so a deleted
|
|
593
|
+
// namespace or an unavailable cluster is never hidden behind an older answer.
|
|
594
|
+
const reads = new Map();
|
|
595
|
+
const namespaces = (context) => {
|
|
596
|
+
const held = reads.get(context ?? '');
|
|
597
|
+
if (held !== undefined)
|
|
598
|
+
return held;
|
|
599
|
+
const reading = (0, capabilities_1.workspaceNamespaces)(context);
|
|
600
|
+
reads.set(context ?? '', reading);
|
|
601
|
+
return reading;
|
|
602
|
+
};
|
|
603
|
+
// A list needs current answers, but not one kubectl process per row and per question.
|
|
604
|
+
// Keep these snapshots inside this call; a later poll must read the cluster again.
|
|
605
|
+
// Broad RBAC is optional: a refused collection falls back to the original scoped probe.
|
|
606
|
+
const replicas = shareContextRead(status_1.workspaceReplicasByNamespace);
|
|
607
|
+
const pods = shareContextRead(status_1.workspacePodsByNamespace);
|
|
608
|
+
const kubeReads = {
|
|
609
|
+
workloadReplicas: async (name, options) => {
|
|
610
|
+
const [seen, namespace] = await Promise.all([replicas(options.context), (0, namespace_1.namespaceFor)(name)]);
|
|
611
|
+
return seen === null ? await (0, status_1.workloadReplicas)(name, options) : (seen.get(namespace) ?? null);
|
|
612
|
+
},
|
|
613
|
+
workspaceReady: async (name, options) => {
|
|
614
|
+
const [seen, namespace] = await Promise.all([pods(options.context), (0, namespace_1.namespaceFor)(name)]);
|
|
615
|
+
return seen === null
|
|
616
|
+
? await (0, status_1.workspaceReady)(name, options)
|
|
617
|
+
: (0, status_1.workspacePodsReady)(seen.get(namespace) ?? []);
|
|
618
|
+
},
|
|
619
|
+
terminalPodFailure: async (name, options) => {
|
|
620
|
+
const [seen, namespace] = await Promise.all([pods(options.context), (0, namespace_1.namespaceFor)(name)]);
|
|
621
|
+
return seen === null
|
|
622
|
+
? await (0, status_1.terminalPodFailure)(name, options)
|
|
623
|
+
: (0, status_1.terminalFailureOfPods)(seen.get(namespace) ?? []);
|
|
624
|
+
},
|
|
625
|
+
};
|
|
626
|
+
return await (0, map_limit_1.mapLimit)(metas, 4, async (meta) => rowFor(meta, {
|
|
627
|
+
default: defaultName,
|
|
628
|
+
dockerUp,
|
|
629
|
+
states,
|
|
630
|
+
statusMap,
|
|
631
|
+
svcMap,
|
|
632
|
+
namespaces,
|
|
633
|
+
kubeReads,
|
|
634
|
+
}));
|
|
635
|
+
}
|