@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,1518 @@
|
|
|
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.RUN_ORDER = exports.INOTIFY_PER_CLUSTER = exports.Report = exports.CHECKS = void 0;
|
|
37
|
+
exports.majorVersion = majorVersion;
|
|
38
|
+
exports.inotifyInUse = inotifyInUse;
|
|
39
|
+
exports.inotifyHeadroom = inotifyHeadroom;
|
|
40
|
+
exports.mongoKernelConflict = mongoKernelConflict;
|
|
41
|
+
exports.checkDocker = checkDocker;
|
|
42
|
+
exports.checkCompose = checkCompose;
|
|
43
|
+
exports.checkKernel = checkKernel;
|
|
44
|
+
exports.checkHub = checkHub;
|
|
45
|
+
exports.checkDisk = checkDisk;
|
|
46
|
+
exports.checkMemory = checkMemory;
|
|
47
|
+
exports.checkVersions = checkVersions;
|
|
48
|
+
exports.checkPorts = checkPorts;
|
|
49
|
+
exports.checkInstall = checkInstall;
|
|
50
|
+
exports.checkLegacy = checkLegacy;
|
|
51
|
+
exports.checkEdge = checkEdge;
|
|
52
|
+
exports.checkIdentity = checkIdentity;
|
|
53
|
+
exports.checkWork = checkWork;
|
|
54
|
+
exports.checkPresets = checkPresets;
|
|
55
|
+
exports.checkKubernetes = checkKubernetes;
|
|
56
|
+
exports.runEveryCheck = runEveryCheck;
|
|
57
|
+
exports.runChecks = runChecks;
|
|
58
|
+
/**
|
|
59
|
+
* Preflight environment checks, shared by `houston doctor` and the web GUI.
|
|
60
|
+
*
|
|
61
|
+
* Both front-ends run the IDENTICAL checks: the CLI colours and prints the rows, the API
|
|
62
|
+
* serves them as JSON. Checks never raise — each degrades to a `warn` row — because the whole
|
|
63
|
+
* point is to run when the environment is broken.
|
|
64
|
+
*
|
|
65
|
+
* The previous implementation splits the checks into one module per subject because its
|
|
66
|
+
* check runner was a single 1,044-line function with a rolling `subject` variable; this
|
|
67
|
+
* module keeps the subject boundary as one `check*` function per subject and the same
|
|
68
|
+
* `CHECKS` vocabulary, which is the published contract (`doctor --json`). `row()` is still
|
|
69
|
+
* the only way to add a row, so a subject cannot forget its id.
|
|
70
|
+
*/
|
|
71
|
+
const fs = __importStar(require("node:fs"));
|
|
72
|
+
const path = __importStar(require("node:path"));
|
|
73
|
+
const composite_1 = require("../lib/presets/composite");
|
|
74
|
+
const config = __importStar(require("../lib/config"));
|
|
75
|
+
const home_1 = require("../lib/home");
|
|
76
|
+
const jsonout_1 = require("../lib/jsonout");
|
|
77
|
+
const mongo_kernel_1 = require("../lib/mongo-kernel");
|
|
78
|
+
const format_1 = require("../lib/format");
|
|
79
|
+
const docker_cli_1 = require("../seams/docker-cli");
|
|
80
|
+
const rcapi_1 = require("./rcapi");
|
|
81
|
+
const host_1 = require("./runner/host");
|
|
82
|
+
const ports_1 = require("./runner/ports");
|
|
83
|
+
const record_1 = require("./runner/record");
|
|
84
|
+
const skill = __importStar(require("./skill"));
|
|
85
|
+
const users = __importStar(require("./users"));
|
|
86
|
+
const sessions = __importStar(require("./sessions"));
|
|
87
|
+
const eventlog = __importStar(require("./eventlog"));
|
|
88
|
+
const journal = __importStar(require("./journal"));
|
|
89
|
+
const sizing_1 = require("./lifecycle/sizing");
|
|
90
|
+
const types_1 = require("./lifecycle/types");
|
|
91
|
+
const journal_1 = require("./journal");
|
|
92
|
+
const tls_1 = require("./tls");
|
|
93
|
+
const migrate_1 = require("./migrate");
|
|
94
|
+
const topology = __importStar(require("./topology"));
|
|
95
|
+
/**
|
|
96
|
+
* Every check id `runChecks` can report, in report order.
|
|
97
|
+
*
|
|
98
|
+
* A published contract, the machine-readable half of `doctor --json`. A caller watches
|
|
99
|
+
* an ID; the message beside it is prose. One id per SUBJECT, not per outcome.
|
|
100
|
+
*
|
|
101
|
+
* A CONST TUPLE, so `CheckId` below is the closed set and `Report.line` can only be
|
|
102
|
+
* handed a member of it. In the previous implementation this is three separate walks --
|
|
103
|
+
* one per check module asserting `SUBJECT in doctor.CHECKS`, one asserting the subjects
|
|
104
|
+
* are unique, and one reading `doctor --json`'s rows back -- and none of them could see a
|
|
105
|
+
* row filed under a literal that no module declared as its SUBJECT. Here every one of the
|
|
106
|
+
* ninety-odd `line(...)` call sites is checked by the compiler, including the ones that
|
|
107
|
+
* override the id with `check:`.
|
|
108
|
+
*/
|
|
109
|
+
exports.CHECKS = Object.freeze([
|
|
110
|
+
'preflight', // the report itself could not be assembled
|
|
111
|
+
'docker',
|
|
112
|
+
'compose',
|
|
113
|
+
'engine-kernel',
|
|
114
|
+
'hub-auth',
|
|
115
|
+
'disk',
|
|
116
|
+
'memory',
|
|
117
|
+
'swap',
|
|
118
|
+
'version-lookup',
|
|
119
|
+
'ports',
|
|
120
|
+
'edge',
|
|
121
|
+
'edge-routes-stale',
|
|
122
|
+
'edge-routes-unreachable',
|
|
123
|
+
'gui-accounts',
|
|
124
|
+
'gui-admin',
|
|
125
|
+
'gui-roles',
|
|
126
|
+
'gui-create-policy',
|
|
127
|
+
'state-file-perms',
|
|
128
|
+
'home-perms',
|
|
129
|
+
'home-writable',
|
|
130
|
+
'sessions-file',
|
|
131
|
+
'identity',
|
|
132
|
+
'kubernetes',
|
|
133
|
+
'kubernetes-tools',
|
|
134
|
+
'kubernetes-cluster',
|
|
135
|
+
'kubernetes-storage',
|
|
136
|
+
'kubernetes-ingress',
|
|
137
|
+
'kubernetes-loadbalancer',
|
|
138
|
+
'kubernetes-metrics',
|
|
139
|
+
'kubernetes-other-clusters',
|
|
140
|
+
'inotify',
|
|
141
|
+
'kubernetes-cert-manager',
|
|
142
|
+
'kubernetes-edge-port',
|
|
143
|
+
'kubernetes-chart-repo',
|
|
144
|
+
'kubernetes-https',
|
|
145
|
+
'kubernetes-helm-reach',
|
|
146
|
+
'kubernetes-cloud',
|
|
147
|
+
'kubernetes-skew',
|
|
148
|
+
'kubernetes-cloud-owned',
|
|
149
|
+
'install-fresh',
|
|
150
|
+
'agent-skill',
|
|
151
|
+
'edge-config-drift',
|
|
152
|
+
'preset-browser-host',
|
|
153
|
+
'interrupted-work',
|
|
154
|
+
'event-log',
|
|
155
|
+
'legacy-artifacts',
|
|
156
|
+
]);
|
|
157
|
+
function bagOf(value) {
|
|
158
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
159
|
+
return {};
|
|
160
|
+
return value;
|
|
161
|
+
}
|
|
162
|
+
/** The rows one check produced, and the only way to add one. */
|
|
163
|
+
class Report {
|
|
164
|
+
constructor() {
|
|
165
|
+
this.rows = [];
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Add a row. `subject` is the check id unless `check` overrides it.
|
|
169
|
+
*
|
|
170
|
+
* `elsewhere` names a place the GUI shows this fact PERMANENTLY; the web report drops
|
|
171
|
+
* those rows. Only ever set on an `ok` row.
|
|
172
|
+
*/
|
|
173
|
+
line(subject, status, msg, { elsewhere = '', check = '' } = {}) {
|
|
174
|
+
const cid = check !== '' ? check : subject;
|
|
175
|
+
// Declared, not free-form: a typo would be a check that silently stops being
|
|
176
|
+
// watchable. Falls back to `preflight` rather than throwing -- a diagnostic must
|
|
177
|
+
// never answer a mis-declared id with a 500.
|
|
178
|
+
//
|
|
179
|
+
// UNREACHABLE FROM PRODUCTION AND DELIBERATELY KEPT. `CheckId` makes a mis-declared
|
|
180
|
+
// id a compile error at every call site in this module, which is the point of the
|
|
181
|
+
// type; this branch is what still happens when one arrives anyway -- from a caller
|
|
182
|
+
// that cast, or from a future dynamic id -- and `doctor --json`'s promise that every
|
|
183
|
+
// row carries a watchable id is what it protects. Deleting it because the compiler
|
|
184
|
+
// says it cannot fire would trade a diagnostic's 200 for a 500.
|
|
185
|
+
if (!exports.CHECKS.includes(cid)) {
|
|
186
|
+
this.rows.push({
|
|
187
|
+
check: 'preflight',
|
|
188
|
+
status: 'warn',
|
|
189
|
+
message: `internal: check id ${(0, format_1.quotedText)(cid)} is not in ` +
|
|
190
|
+
`doctor.CHECKS, so this row is unwatchable — ${msg}`,
|
|
191
|
+
});
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const row = { check: cid, status, message: msg };
|
|
195
|
+
if (elsewhere !== '')
|
|
196
|
+
row.elsewhere = elsewhere;
|
|
197
|
+
this.rows.push(row);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
exports.Report = Report;
|
|
201
|
+
// --- probes -------------------------------------------------------------------
|
|
202
|
+
/**
|
|
203
|
+
* Leading integer of a version string ('v2.29.1' -> 2, '5.3.1' -> 5), or null.
|
|
204
|
+
*
|
|
205
|
+
* Comparing only the first CHARACTER reported every Compose release newer than v2 as
|
|
206
|
+
* unsupported.
|
|
207
|
+
*/
|
|
208
|
+
function majorVersion(version) {
|
|
209
|
+
const m = /^v?(\d+)/u.exec((version ?? '').trim());
|
|
210
|
+
return m === null ? null : Number.parseInt(m[1], 10);
|
|
211
|
+
}
|
|
212
|
+
exports.INOTIFY_PER_CLUSTER = 60;
|
|
213
|
+
/** How many inotify instances this UID already holds, or null if unknowable. */
|
|
214
|
+
function inotifyInUse(proc = '/proc') {
|
|
215
|
+
let uid;
|
|
216
|
+
let pids;
|
|
217
|
+
try {
|
|
218
|
+
uid = process.getuid !== undefined ? process.getuid() : -1;
|
|
219
|
+
pids = fs.readdirSync(proc).filter((entry) => /^\d+$/u.test(entry));
|
|
220
|
+
}
|
|
221
|
+
catch {
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
let total = 0;
|
|
225
|
+
for (const pid of pids) {
|
|
226
|
+
const base = `${proc}/${pid}`;
|
|
227
|
+
try {
|
|
228
|
+
if (fs.statSync(base).uid !== uid)
|
|
229
|
+
continue;
|
|
230
|
+
for (const fd of fs.readdirSync(`${base}/fd`)) {
|
|
231
|
+
try {
|
|
232
|
+
if (fs.readlinkSync(`${base}/fd/${fd}`) === 'anon_inode:inotify')
|
|
233
|
+
total += 1;
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
catch {
|
|
241
|
+
continue; // the process went away, or is not ours
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return total;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Whether the kernel will let another watcher start.
|
|
248
|
+
*
|
|
249
|
+
* Linux-only by construction: the file does not exist elsewhere, and a missing file is
|
|
250
|
+
* silence rather than a warning about a limit that does not apply.
|
|
251
|
+
*/
|
|
252
|
+
function inotifyHeadroom(clusters = 1, file = '/proc/sys/fs/inotify/max_user_instances', inUse = null) {
|
|
253
|
+
let limit;
|
|
254
|
+
try {
|
|
255
|
+
// `toInt` of the file's text: `parseInt` accepted `1024abc` and emitted a row where
|
|
256
|
+
// `toInt` throws and the check stays silent.
|
|
257
|
+
limit = (0, format_1.toInt)(fs.readFileSync(file, 'utf8'));
|
|
258
|
+
}
|
|
259
|
+
catch {
|
|
260
|
+
return [];
|
|
261
|
+
}
|
|
262
|
+
const need = Math.max(1, clusters) * exports.INOTIFY_PER_CLUSTER;
|
|
263
|
+
const used = inUse === null ? inotifyInUse() : inUse;
|
|
264
|
+
const free = used === null ? limit : Math.max(0, limit - used);
|
|
265
|
+
const seen = used === null ? '' : `, ${String(used)} already in use by this user`;
|
|
266
|
+
if (free < need) {
|
|
267
|
+
return [
|
|
268
|
+
[
|
|
269
|
+
'fail',
|
|
270
|
+
`inotify instances: ${String(limit)}${seen} — about ${String(free)} left for the ` +
|
|
271
|
+
`~${String(need)} that ${String(Math.max(1, clusters))} cluster(s) want. Traefik will ` +
|
|
272
|
+
`start, load NO dynamic configuration and serve its own ` +
|
|
273
|
+
`default certificate, which looks like a broken route rather ` +
|
|
274
|
+
`than a kernel limit. \`sudo sysctl -w ` +
|
|
275
|
+
`fs.inotify.max_user_instances=1024\``,
|
|
276
|
+
],
|
|
277
|
+
];
|
|
278
|
+
}
|
|
279
|
+
if (free < need * 2) {
|
|
280
|
+
return [
|
|
281
|
+
[
|
|
282
|
+
'warn',
|
|
283
|
+
`inotify instances: ${String(limit)}${seen} — about ${String(free)} left against ` +
|
|
284
|
+
`the ~${String(need)} wanted, which is tight. A watcher that cannot ` +
|
|
285
|
+
`start makes Traefik serve its own default certificate. ` +
|
|
286
|
+
`\`sudo sysctl -w fs.inotify.max_user_instances=1024\``,
|
|
287
|
+
],
|
|
288
|
+
];
|
|
289
|
+
}
|
|
290
|
+
return [
|
|
291
|
+
[
|
|
292
|
+
'ok',
|
|
293
|
+
`inotify instances: ${String(limit)}${seen} (kind and Traefik watch files; ` +
|
|
294
|
+
`~${String(need)} needed here)`,
|
|
295
|
+
],
|
|
296
|
+
];
|
|
297
|
+
}
|
|
298
|
+
/** Why this MongoDB cannot start on this engine, or "" if it can. */
|
|
299
|
+
function mongoKernelConflict(mongoTag, kernel) {
|
|
300
|
+
return (0, mongo_kernel_1.mongoKernelConflict)(mongoTag, kernel);
|
|
301
|
+
}
|
|
302
|
+
// --- docker / compose / kernel / hub / disk / memory / versions / ports -------
|
|
303
|
+
async function checkDocker(ctx) {
|
|
304
|
+
const report = new Report();
|
|
305
|
+
const line = report.line.bind(report);
|
|
306
|
+
// maxAge 0: somebody running `doctor` has explicitly asked whether Docker is up RIGHT
|
|
307
|
+
// NOW -- answering that from a cache is how a diagnostic tells you the opposite of
|
|
308
|
+
// the truth.
|
|
309
|
+
ctx.dockerUp = await (0, host_1.dockerAvailable)({ maxAgeMs: 0 });
|
|
310
|
+
const found = ctx.dockerUp ? await (0, host_1.engine)() : null;
|
|
311
|
+
if (found !== null && found.kind === 'podman') {
|
|
312
|
+
// Podman answering as `docker`: said as itself, with the one difference that stops
|
|
313
|
+
// workspaces outright.
|
|
314
|
+
line('docker', 'ok', `Podman ${found.version || '?'} answering as docker` +
|
|
315
|
+
`${found.rootless ? ', rootless' : ''}${found.shim ? ', through the podman-docker shim' : ''}`);
|
|
316
|
+
if (!found.healthchecks) {
|
|
317
|
+
line('docker', 'warn', `Podman runs no container healthchecks here (cgroup manager '${found.cgroupDriver || '?'}'): ` +
|
|
318
|
+
'a workspace on MongoDB 8 or with several instances waits on one and will not start. ' +
|
|
319
|
+
'Use cgroup_manager = "systemd" under a systemd user session, a Podman machine, or Docker.');
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
else if (ctx.dockerUp) {
|
|
323
|
+
// The server version, or '?' when it is empty: an empty-but-successful probe is '?',
|
|
324
|
+
// as it always was, where `??` kept the empty string.
|
|
325
|
+
const version = await (0, host_1.dockerServerVersion)();
|
|
326
|
+
line('docker', 'ok', `Docker daemon running (${version !== null && version !== '' ? version : '?'})`);
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
line('docker', 'fail', 'Docker daemon not running — start Docker Desktop / dockerd');
|
|
330
|
+
}
|
|
331
|
+
return report.rows;
|
|
332
|
+
}
|
|
333
|
+
async function checkCompose(_ctx) {
|
|
334
|
+
const report = new Report();
|
|
335
|
+
const line = report.line.bind(report);
|
|
336
|
+
const cv = await (0, host_1.composeVersion)();
|
|
337
|
+
const cvMajor = majorVersion(cv);
|
|
338
|
+
if (cv !== null && cv.toLowerCase().includes('podman-compose')) {
|
|
339
|
+
line('compose', 'fail', `docker compose is ${cv}: houston needs the Compose v2 plugin`);
|
|
340
|
+
}
|
|
341
|
+
else if (cvMajor !== null && cvMajor >= 2) {
|
|
342
|
+
line('compose', 'ok', `docker compose v${String(cvMajor)} (${String(cv)})`);
|
|
343
|
+
}
|
|
344
|
+
else if (cv !== null && cv !== '') {
|
|
345
|
+
line('compose', 'warn', `docker compose ${cv} — houston needs Compose v2 or newer`);
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
line('compose', 'warn', "couldn't detect `docker compose` — install Compose v2 or newer");
|
|
349
|
+
}
|
|
350
|
+
return report.rows;
|
|
351
|
+
}
|
|
352
|
+
async function checkKernel(ctx) {
|
|
353
|
+
const report = new Report();
|
|
354
|
+
const line = report.line.bind(report);
|
|
355
|
+
if (ctx.dockerUp) {
|
|
356
|
+
const kv = await (0, host_1.dockerKernelVersion)();
|
|
357
|
+
if (mongoKernelConflict('8.0', kv) !== '') {
|
|
358
|
+
line('engine-kernel', 'warn', `engine kernel ${String(kv)} — MongoDB 8 and newer will not start (SERVER-121912); ` +
|
|
359
|
+
'use an engine on kernel 7.0.14 or newer for RC versions that require Mongo 8');
|
|
360
|
+
}
|
|
361
|
+
else if (kv !== null && kv !== '') {
|
|
362
|
+
line('engine-kernel', 'ok', `engine kernel ${kv}`);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return report.rows;
|
|
366
|
+
}
|
|
367
|
+
async function checkHub(_ctx) {
|
|
368
|
+
const report = new Report();
|
|
369
|
+
const line = report.line.bind(report);
|
|
370
|
+
const hub = await (0, host_1.hubLoggedIn)();
|
|
371
|
+
if (hub === true) {
|
|
372
|
+
line('hub-auth', 'ok', 'logged in to Docker Hub (avoids anonymous pull-rate limits)');
|
|
373
|
+
}
|
|
374
|
+
else if (hub === false) {
|
|
375
|
+
line('hub-auth', 'warn', 'not logged in to Docker Hub — anonymous pulls can hit the rate ' +
|
|
376
|
+
'limit; run `docker login`. registry.rocket.chat counts against Hub too');
|
|
377
|
+
}
|
|
378
|
+
return report.rows;
|
|
379
|
+
}
|
|
380
|
+
async function checkDisk(_ctx) {
|
|
381
|
+
const report = new Report();
|
|
382
|
+
const line = report.line.bind(report);
|
|
383
|
+
try {
|
|
384
|
+
const stat = fs.statfsSync(path.dirname(config.home()));
|
|
385
|
+
const freeGb = (Number(stat.bavail) * Number(stat.bsize)) / 1e9;
|
|
386
|
+
if (freeGb >= 10) {
|
|
387
|
+
line('disk', 'ok', `Disk: ${(0, format_1.formatFixed)(freeGb, 0)} GB free`);
|
|
388
|
+
}
|
|
389
|
+
else {
|
|
390
|
+
line('disk', 'warn', `Disk: only ${(0, format_1.formatFixed)(freeGb, 0)} GB free — images are ~1.5 GB each`);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
catch {
|
|
394
|
+
line('disk', 'warn', "couldn't check disk space");
|
|
395
|
+
}
|
|
396
|
+
return report.rows;
|
|
397
|
+
}
|
|
398
|
+
async function checkMemory(_ctx) {
|
|
399
|
+
const report = new Report();
|
|
400
|
+
const line = report.line.bind(report);
|
|
401
|
+
// Memory headroom, in workspaces rather than megabytes -- "3.2 GB available" does not
|
|
402
|
+
// tell you whether you can start another one, and that is the only question anybody
|
|
403
|
+
// is actually asking.
|
|
404
|
+
const cap = await (0, sizing_1.capacity)();
|
|
405
|
+
if (cap.known) {
|
|
406
|
+
const totalMb = cap.total_mb ?? 0;
|
|
407
|
+
const availMb = cap.available_mb ?? 0;
|
|
408
|
+
const swapMb = cap.swap_mb ?? 0;
|
|
409
|
+
const room = cap.room ?? 0;
|
|
410
|
+
const detail = `${String(availMb)} MB available of ${String(totalMb)} MB`;
|
|
411
|
+
if (room >= 2) {
|
|
412
|
+
line('memory', 'ok', `Memory: ${detail}`);
|
|
413
|
+
}
|
|
414
|
+
else if (room === 1) {
|
|
415
|
+
line('memory', 'warn', `Memory: ${detail} — room for about 1 more workspace`);
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
line('memory', 'warn', `Memory: ${detail} — NOT enough for another workspace. ` +
|
|
419
|
+
'`houston stop --name <it>` frees memory and keeps the data');
|
|
420
|
+
}
|
|
421
|
+
if (swapMb === 0) {
|
|
422
|
+
line('memory', 'warn', 'No swap: memory pressure becomes an OOM kill rather than ' +
|
|
423
|
+
'slowdown, and the kernel picks its own victim', { check: 'swap' });
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
return report.rows;
|
|
427
|
+
}
|
|
428
|
+
async function checkVersions(_ctx) {
|
|
429
|
+
const report = new Report();
|
|
430
|
+
const line = report.line.bind(report);
|
|
431
|
+
// Live version lookup reachability. Through `rcapi`, which is the one module allowed
|
|
432
|
+
// to make requests. `null` is a transport failure -- NO response at all -- and saying
|
|
433
|
+
// "returned non-200" for a box with no network would name the wrong fault.
|
|
434
|
+
const status = await (0, rcapi_1.releasesReachable)();
|
|
435
|
+
if (status === null) {
|
|
436
|
+
line('version-lookup', 'warn', 'releases.rocket.chat unreachable — use `--offline` (falls back to shipped map)');
|
|
437
|
+
}
|
|
438
|
+
else if (status === 200) {
|
|
439
|
+
line('version-lookup', 'ok', 'releases.rocket.chat reachable (live version lookup available)');
|
|
440
|
+
}
|
|
441
|
+
else {
|
|
442
|
+
line('version-lookup', 'warn', 'releases.rocket.chat returned non-200 — use `--offline` if needed');
|
|
443
|
+
}
|
|
444
|
+
return report.rows;
|
|
445
|
+
}
|
|
446
|
+
async function checkPorts(_ctx) {
|
|
447
|
+
const report = new Report();
|
|
448
|
+
const line = report.line.bind(report);
|
|
449
|
+
try {
|
|
450
|
+
const free = await (0, ports_1.pickPort)();
|
|
451
|
+
if (await (0, ports_1.portFree)(3000)) {
|
|
452
|
+
line('ports', 'ok', `Port 3000 free (workspaces auto-pick from 3000; next free: ${String(free)})`);
|
|
453
|
+
}
|
|
454
|
+
else {
|
|
455
|
+
line('ports', 'warn', `Port 3000 in use — \`up\` will auto-pick the next free port (${String(free)})`);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
catch (exc) {
|
|
459
|
+
// bounded scan found nothing bindable
|
|
460
|
+
line('ports', 'fail', String(exc.message));
|
|
461
|
+
}
|
|
462
|
+
return report.rows;
|
|
463
|
+
}
|
|
464
|
+
// --- install / legacy ---------------------------------------------------------
|
|
465
|
+
async function checkInstall(_ctx) {
|
|
466
|
+
const report = new Report();
|
|
467
|
+
const line = report.line.bind(report);
|
|
468
|
+
try {
|
|
469
|
+
const reported = (0, jsonout_1.getHoustonVersion)();
|
|
470
|
+
// THE CHECKOUT BESIDE THE RUNNING BUILD, derived from this module's own location --
|
|
471
|
+
// not the current working directory. houston may be invoked from anywhere, and
|
|
472
|
+
// reading `./package.json` from a random project directory both misses the real
|
|
473
|
+
// checkout and warns about the wrong tree's version. The previous implementation read
|
|
474
|
+
// its own manifest the same way; that file now belongs to it, and THIS build's version
|
|
475
|
+
// lives in package.json at the package root. A checkout is a root that still has src/
|
|
476
|
+
// beside dist/: an installed tarball ships neither src/ nor a tree a fix could be made
|
|
477
|
+
// in, so there is nothing to compare against and the row says so.
|
|
478
|
+
const root = path.resolve(__dirname, '..', '..');
|
|
479
|
+
const source = path.join(root, 'package.json');
|
|
480
|
+
if (fs.existsSync(source) && fs.existsSync(path.join(root, 'src'))) {
|
|
481
|
+
let checkout = '';
|
|
482
|
+
try {
|
|
483
|
+
const manifest = JSON.parse(fs.readFileSync(source, 'utf8'));
|
|
484
|
+
checkout = typeof manifest.version === 'string' ? manifest.version : '';
|
|
485
|
+
}
|
|
486
|
+
catch {
|
|
487
|
+
checkout = '';
|
|
488
|
+
}
|
|
489
|
+
if (checkout !== '' && checkout !== reported) {
|
|
490
|
+
// The TypeScript build reports `jsonout`'s registry value, which the front door
|
|
491
|
+
// sets from the package; the placeholder is `0.0.0` until this build is
|
|
492
|
+
// packaged. The comparison still catches a stale link, which is the point.
|
|
493
|
+
line('install-fresh', 'warn', `running houston ${reported}, but the checkout at ${path.dirname(source)} ` +
|
|
494
|
+
`is ${checkout} — the build is reporting a different version, so a fix in ` +
|
|
495
|
+
`that tree may NOT be what is answering. Rebuild so the two agree`);
|
|
496
|
+
}
|
|
497
|
+
else {
|
|
498
|
+
line('install-fresh', 'ok', `houston ${reported}, matching the checkout at ${path.dirname(source)}`);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
else {
|
|
502
|
+
line('install-fresh', 'ok', `houston ${reported} (installed, no checkout alongside)`);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
catch {
|
|
506
|
+
line('install-fresh', 'warn', 'could not determine which houston build is running');
|
|
507
|
+
}
|
|
508
|
+
try {
|
|
509
|
+
skillCopies(line);
|
|
510
|
+
}
|
|
511
|
+
catch {
|
|
512
|
+
line('agent-skill', 'warn', 'could not check the agent skill — `houston skill status` shows it');
|
|
513
|
+
}
|
|
514
|
+
return report.rows;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* The agent skill's copies against this build. Upgrading houston leaves the copies `skill
|
|
518
|
+
* install` wrote as they were, and Claude Code reads a user copy ahead of a project one, so a
|
|
519
|
+
* stale copy goes on teaching an agent another build's flags with nothing to say so.
|
|
520
|
+
*/
|
|
521
|
+
function skillCopies(line) {
|
|
522
|
+
const version = (0, jsonout_1.getHoustonVersion)();
|
|
523
|
+
const copies = Object.values(skill.state().hosts).filter((copy) => copy.status !== 'absent');
|
|
524
|
+
const odd = copies.filter((copy) => copy.status !== 'current');
|
|
525
|
+
for (const copy of odd) {
|
|
526
|
+
if (copy.status === 'modified') {
|
|
527
|
+
line('agent-skill', 'ok', `the agent skill at ${copy.path} was edited locally, so \`houston skill install\` ` +
|
|
528
|
+
'leaves it alone (`--force` replaces it)');
|
|
529
|
+
}
|
|
530
|
+
else if (copy.status === 'stale' && copy.scope === 'user') {
|
|
531
|
+
// The sidecar's version is the build that installed it; the same number means the
|
|
532
|
+
// text moved on without a version bump, which a checkout does between releases.
|
|
533
|
+
const from = copy.version !== '' && copy.version !== version ? ` (installed by ${copy.version})` : '';
|
|
534
|
+
line('agent-skill', 'warn', `${copy.path} is not the agent skill houston ${version} ships${from} — an agent ` +
|
|
535
|
+
'reading it may use flags this build does not have; `houston skill install` updates it');
|
|
536
|
+
}
|
|
537
|
+
else if (copy.status === 'stale') {
|
|
538
|
+
line('agent-skill', 'warn', `${copy.path} does not match houston ${version} — copy ${skill.packaged()} over it, ` +
|
|
539
|
+
'or delete it');
|
|
540
|
+
}
|
|
541
|
+
else {
|
|
542
|
+
line('agent-skill', 'warn', 'could not read an installed agent skill — `houston skill status` shows which');
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
if (copies.length === 0) {
|
|
546
|
+
line('agent-skill', 'ok', 'no agent skill installed — `houston skill install` lets Claude Code and other agents ' +
|
|
547
|
+
'drive houston');
|
|
548
|
+
}
|
|
549
|
+
else if (odd.length === 0) {
|
|
550
|
+
line('agent-skill', 'ok', `agent skill matches houston ${version}: ${copies.map((copy) => copy.path).join(', ')}`);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
/** A pre-rename edge still holding :80/:443, which stops the new one starting. */
|
|
554
|
+
async function legacyEdgeContainers(line) {
|
|
555
|
+
if (!(await (0, host_1.dockerAvailable)()))
|
|
556
|
+
return;
|
|
557
|
+
let seen;
|
|
558
|
+
try {
|
|
559
|
+
const result = await (0, docker_cli_1.docker)([
|
|
560
|
+
'ps',
|
|
561
|
+
'--filter',
|
|
562
|
+
`label=com.docker.compose.project=${migrate_1.LEGACY_EDGE_PROJECT}`,
|
|
563
|
+
'--filter',
|
|
564
|
+
'status=running',
|
|
565
|
+
'--format',
|
|
566
|
+
'{{.Names}}',
|
|
567
|
+
], { capture: true, timeoutMs: 15000 });
|
|
568
|
+
seen = String(result.stdout ?? '');
|
|
569
|
+
}
|
|
570
|
+
catch {
|
|
571
|
+
seen = '';
|
|
572
|
+
}
|
|
573
|
+
const held = seen
|
|
574
|
+
.trim()
|
|
575
|
+
.split(/\r?\n/u)
|
|
576
|
+
.filter((entry) => entry !== '');
|
|
577
|
+
if (held.length > 0) {
|
|
578
|
+
line('legacy-artifacts', 'warn', `${held[0]} is the pre-rename edge and still holds :80 and ` +
|
|
579
|
+
`:443, so the new one cannot start — \`docker compose -p ` +
|
|
580
|
+
`${migrate_1.LEGACY_EDGE_PROJECT} down\` then \`houston edge start\``, { check: 'legacy-artifacts' });
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
/** A CA anchor installed under the previous name. */
|
|
584
|
+
function legacyCaAnchor(line) {
|
|
585
|
+
for (const anchorDir of [
|
|
586
|
+
'/usr/local/share/ca-certificates',
|
|
587
|
+
'/etc/pki/ca-trust/source/anchors',
|
|
588
|
+
]) {
|
|
589
|
+
const oldCa = path.join(anchorDir, 'rc-repro-local-ca.crt');
|
|
590
|
+
if (!fs.existsSync(oldCa))
|
|
591
|
+
continue;
|
|
592
|
+
// NOT stale, and saying so would be actively harmful. `ensureCa` is idempotent, so
|
|
593
|
+
// the migration carried the SAME certificate authority across.
|
|
594
|
+
line('legacy-artifacts', 'ok', `${oldCa} still carries the local CA in use — it keeps ` +
|
|
595
|
+
`working under its old name. \`houston trust-ca\` installs ` +
|
|
596
|
+
`the same certificate under its new name; remove the old ` +
|
|
597
|
+
`file only after that, and only for tidiness`, { check: 'legacy-artifacts' });
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
async function checkLegacy(_ctx) {
|
|
601
|
+
const report = new Report();
|
|
602
|
+
const line = report.line.bind(report);
|
|
603
|
+
// WHAT THE RENAME COULD NOT MOVE. Silent when clean.
|
|
604
|
+
try {
|
|
605
|
+
// `LEGACY_HOME_DIRNAME` under the user's home, joined by `joinPath`: `path.join`
|
|
606
|
+
// folded a `..` in HOME and warned about a directory the kernel -- and every earlier
|
|
607
|
+
// release -- does not find.
|
|
608
|
+
const legacyState = (0, home_1.joinPath)((0, home_1.pathHome)(), migrate_1.LEGACY_HOME_DIRNAME);
|
|
609
|
+
if (fs.existsSync(legacyState) && fs.statSync(legacyState).isDirectory()) {
|
|
610
|
+
line('legacy-artifacts', 'warn', `${legacyState} is still here. It is adopted automatically ` +
|
|
611
|
+
`unless HOUSTON_HOME is set, which it is — unset it and run ` +
|
|
612
|
+
`any houston command, or move it by hand`, { check: 'legacy-artifacts' });
|
|
613
|
+
}
|
|
614
|
+
const staleEnv = config.legacyEnvUsed();
|
|
615
|
+
if (staleEnv.length > 0) {
|
|
616
|
+
line('legacy-artifacts', 'warn', `reading the pre-rename ${staleEnv.join(', ')}; rename to ` +
|
|
617
|
+
`HOUSTON_* — the old names will stop being read`, { check: 'legacy-artifacts' });
|
|
618
|
+
}
|
|
619
|
+
const unit = '/etc/systemd/system/rc-repro.service';
|
|
620
|
+
if (fs.existsSync(unit)) {
|
|
621
|
+
line('legacy-artifacts', 'warn', `${unit} is the pre-rename service and will fail at boot — ` +
|
|
622
|
+
`\`sudo systemctl disable --now rc-repro && sudo rm ${unit}\`, ` +
|
|
623
|
+
`then \`houston serve --print-service\` for the new one`, { check: 'legacy-artifacts' });
|
|
624
|
+
}
|
|
625
|
+
for (const hostDir of ['.claude/skills', '.agents/skills']) {
|
|
626
|
+
// `rc-repro` under the host's directory in the user's home, joined as the legacy
|
|
627
|
+
// state above is.
|
|
628
|
+
const oldSkill = (0, home_1.joinPath)((0, home_1.pathHome)(), hostDir, 'rc-repro');
|
|
629
|
+
if (fs.existsSync(oldSkill) && fs.statSync(oldSkill).isDirectory()) {
|
|
630
|
+
line('legacy-artifacts', 'warn', `${oldSkill} still teaches agents to run \`rc-repro\`, a ` +
|
|
631
|
+
`command that no longer exists — \`rm -rf ${oldSkill}\` ` +
|
|
632
|
+
`and \`houston skill install\``, { check: 'legacy-artifacts' });
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
// Deliberately NOT flagged: `rcrepro-<name>` containers. The edge is the exception,
|
|
636
|
+
// because it is a singleton.
|
|
637
|
+
await legacyEdgeContainers(line);
|
|
638
|
+
legacyCaAnchor(line);
|
|
639
|
+
}
|
|
640
|
+
catch {
|
|
641
|
+
line('legacy-artifacts', 'warn', 'could not check for pre-rename leftovers', {
|
|
642
|
+
check: 'legacy-artifacts',
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
return report.rows;
|
|
646
|
+
}
|
|
647
|
+
// --- edge ---------------------------------------------------------------------
|
|
648
|
+
/** Every route the edge is serving: the ones whose workspace is gone, and the ones
|
|
649
|
+
* nothing answers on. */
|
|
650
|
+
async function edgeRoutes(line, ctx, routes) {
|
|
651
|
+
const networks = await Promise.resolve().then(() => __importStar(require('./edge/networks')));
|
|
652
|
+
if (!ctx.dockerUp)
|
|
653
|
+
return;
|
|
654
|
+
// A route whose workspace is gone points the edge at nothing.
|
|
655
|
+
const known = new Set((await (0, record_1.listMeta)()).map((m) => m.name));
|
|
656
|
+
const stale = routes.filter((r) => !known.has(r));
|
|
657
|
+
if (stale.length > 0) {
|
|
658
|
+
const sorted = [...stale].sort();
|
|
659
|
+
const hosts = sorted.slice(0, 5).map((r) => {
|
|
660
|
+
const routesMod = require('./edge/routes');
|
|
661
|
+
return routesMod.routeHost(r) || r;
|
|
662
|
+
});
|
|
663
|
+
line('edge', 'warn', `${String(stale.length)} edge route(s) with no workspace: ` +
|
|
664
|
+
`${sorted.slice(0, 5).join(', ')} — \`down\` cannot ` +
|
|
665
|
+
`remove these, the workspace is what is gone. ` +
|
|
666
|
+
`\`houston edge delete ${hosts[0]}\` forgets a name, ` +
|
|
667
|
+
`its certificate and its key`);
|
|
668
|
+
}
|
|
669
|
+
// A route the edge cannot REACH is a 502 rather than an error.
|
|
670
|
+
const engine = await Promise.resolve().then(() => __importStar(require('./edge/engine')));
|
|
671
|
+
if (await engine.running()) {
|
|
672
|
+
const attached = await networks.attachedNetworks();
|
|
673
|
+
const orphan = [];
|
|
674
|
+
for (const route of routes) {
|
|
675
|
+
if (!known.has(route))
|
|
676
|
+
continue;
|
|
677
|
+
if (!attached.has(await networks.workspaceNetwork(route)))
|
|
678
|
+
orphan.push(route);
|
|
679
|
+
}
|
|
680
|
+
if (orphan.length > 0) {
|
|
681
|
+
line('edge', 'warn', `${String(orphan.length)} route(s) the edge cannot reach: ` +
|
|
682
|
+
`${[...orphan].sort().slice(0, 5).join(', ')} — they answer 502. ` +
|
|
683
|
+
'`houston edge restart` re-attaches them');
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
async function checkEdge(ctx) {
|
|
688
|
+
const report = new Report();
|
|
689
|
+
const line = report.line.bind(report);
|
|
690
|
+
try {
|
|
691
|
+
const edge = await Promise.resolve().then(() => __importStar(require('./edge/spec')));
|
|
692
|
+
const engine = await Promise.resolve().then(() => __importStar(require('./edge/engine')));
|
|
693
|
+
if (edge.installed()) {
|
|
694
|
+
const served = edge.servedDomain();
|
|
695
|
+
const where = served !== '' ? ` (${served})` : '';
|
|
696
|
+
const routes = (await Promise.resolve().then(() => __importStar(require('./edge/routes')))).registered();
|
|
697
|
+
if (!ctx.dockerUp) {
|
|
698
|
+
line('edge', 'warn', `Edge${where} installed — cannot check it, Docker is down`);
|
|
699
|
+
}
|
|
700
|
+
else if (await engine.running()) {
|
|
701
|
+
line('edge', 'ok', `Edge running${where} — holds :80/:443, ` + `${String(routes.length)} workspace route(s)`, { elsewhere: 'the edge chip in the header' });
|
|
702
|
+
}
|
|
703
|
+
else if (routes.length === 0 && served === '') {
|
|
704
|
+
// NOTHING TO REACH. A stopped edge with no https workspace and no GUI name on it
|
|
705
|
+
// breaks nothing, and `fail` made `doctor` exit 1 on a box that had simply finished
|
|
706
|
+
// with HTTPS -- "every https name (0 route(s)) is unreachable" about no names at all.
|
|
707
|
+
line('edge', 'ok', 'Edge installed and stopped — no https workspace uses it. ' +
|
|
708
|
+
'`houston edge start` when one does');
|
|
709
|
+
}
|
|
710
|
+
else {
|
|
711
|
+
const holder = await engine.portHolder(443);
|
|
712
|
+
const because = holder !== '' ? ` — ${holder} is holding :443` : '';
|
|
713
|
+
line('edge', 'fail', `Edge${where} is NOT running${because}. Every https ` +
|
|
714
|
+
`name on this box (${String(routes.length)} route(s)) is ` +
|
|
715
|
+
'unreachable. `houston edge start`');
|
|
716
|
+
}
|
|
717
|
+
if (ctx.dockerUp && (await engine.running())) {
|
|
718
|
+
const [staleCfg, liveOnly] = await edge.configDrift();
|
|
719
|
+
if (staleCfg.length > 0 || liveOnly.length > 0) {
|
|
720
|
+
const shown = [...staleCfg, ...liveOnly].slice(0, 3);
|
|
721
|
+
line('edge', 'warn', `the edge's configuration on disk and the running ` +
|
|
722
|
+
`container disagree (${shown.join(', ')}` +
|
|
723
|
+
`${staleCfg.length + liveOnly.length > 3 ? '…' : ''}). ` +
|
|
724
|
+
`Whatever was changed has not been applied — ` +
|
|
725
|
+
'`houston edge restart`', { check: 'edge-config-drift' });
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
await edgeRoutes(line, ctx, routes);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
catch {
|
|
732
|
+
line('edge', 'warn', 'Edge status could not be determined');
|
|
733
|
+
}
|
|
734
|
+
return report.rows;
|
|
735
|
+
}
|
|
736
|
+
// --- identity / event log / work -----------------------------------------------
|
|
737
|
+
/** Who can sign in, and with what role. */
|
|
738
|
+
function identityAccounts(line) {
|
|
739
|
+
if (!users.anyUsers()) {
|
|
740
|
+
line('identity', 'warn', 'No GUI accounts — `houston serve` will refuse to start on ' +
|
|
741
|
+
'anything but loopback (`houston users add <name>`)', { check: 'gui-accounts' });
|
|
742
|
+
}
|
|
743
|
+
else {
|
|
744
|
+
const admins = users.admins();
|
|
745
|
+
if (admins.length > 0) {
|
|
746
|
+
line('identity', 'ok', `${String(users.listUsers().length)} GUI account(s), ` + `admin: ${admins.join(', ')}`, { elsewhere: 'the People page', check: 'gui-accounts' });
|
|
747
|
+
}
|
|
748
|
+
else {
|
|
749
|
+
line('identity', 'fail', 'No admin account — nobody can manage people from the ' +
|
|
750
|
+
'GUI. `houston users role <name> admin`', { check: 'gui-admin' });
|
|
751
|
+
}
|
|
752
|
+
const implicit = users.implicitAdmins();
|
|
753
|
+
if (implicit.length > 0) {
|
|
754
|
+
line('identity', 'warn', `admin by default (blank role column): ` +
|
|
755
|
+
`${implicit.join(', ')} — that is the migration for ` +
|
|
756
|
+
'accounts made before roles existed, not a choice. ' +
|
|
757
|
+
`\`houston users role ${implicit[0]} member\``, { check: 'gui-roles' });
|
|
758
|
+
}
|
|
759
|
+
// Reported rather than warned about: this is the default and it is a deliberate one,
|
|
760
|
+
// but "what may a member actually do on this box?" should be answerable without
|
|
761
|
+
// reading source.
|
|
762
|
+
// THE KEY `houston config set gui.create_policy` WRITES, `lifecycle.CREATE_POLICY_KEY`.
|
|
763
|
+
// This read `gui_create_policy`, which nothing writes, so after an admin narrowed the
|
|
764
|
+
// policy the row still told them members may set those fields.
|
|
765
|
+
if (config.loadConfig()[types_1.CREATE_POLICY_KEY] === 'admin') {
|
|
766
|
+
line('identity', 'ok', 'members may not set --rc-image/--reg-token/--bind ' + '(gui.create_policy admin)', { elsewhere: 'which fields the New workspace form offers', check: 'gui-create-policy' });
|
|
767
|
+
}
|
|
768
|
+
else {
|
|
769
|
+
line('identity', 'ok', 'members may set --rc-image/--reg-token/--bind — narrow ' +
|
|
770
|
+
'it with `houston config set gui.create_policy admin`', { elsewhere: 'which fields the New workspace form offers', check: 'gui-create-policy' });
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
/** Where the history is, and whether it is being written. */
|
|
775
|
+
function identityEventLog(line) {
|
|
776
|
+
try {
|
|
777
|
+
const logPath = eventlog.logPath();
|
|
778
|
+
if (eventlog.maxBytes() <= 0) {
|
|
779
|
+
line('identity', 'warn', 'Event log disabled (HOUSTON_LOG_MAX_MB=0) — nothing is ' + 'recording what houston did', { check: 'event-log' });
|
|
780
|
+
}
|
|
781
|
+
else if (fs.existsSync(logPath)) {
|
|
782
|
+
const mb = fs.statSync(logPath).size / 1048576;
|
|
783
|
+
line('identity', 'ok', `Event log: ${logPath} (${(0, format_1.formatFixed)(mb, 1)} MB of ` +
|
|
784
|
+
`${(0, format_1.formatFixed)(eventlog.maxBytes() / 1048576, 0)} MB, then one ` +
|
|
785
|
+
'rotation)', { check: 'event-log' });
|
|
786
|
+
}
|
|
787
|
+
else {
|
|
788
|
+
line('identity', 'ok', `Event log: ${logPath} — written from the first command that ` + 'reports progress', { check: 'event-log' });
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
catch {
|
|
792
|
+
line('identity', 'warn', 'Event log status could not be determined', {
|
|
793
|
+
check: 'event-log',
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
/** Whether the files that DECIDE who can sign in are sound. */
|
|
798
|
+
function identityStateFiles(line) {
|
|
799
|
+
for (const file of [
|
|
800
|
+
users.usersFile(),
|
|
801
|
+
sessions.sessionsFile(),
|
|
802
|
+
// Joined component by component, a `..` kept, as every path under the home is.
|
|
803
|
+
(0, home_1.joinPath)(config.home(), 'audit.log'),
|
|
804
|
+
(0, home_1.joinPath)((0, tls_1.acmeDir)(), 'dns.env'),
|
|
805
|
+
(0, home_1.joinPath)(config.home(), 'ca', 'ca.key'),
|
|
806
|
+
]) {
|
|
807
|
+
if (fs.existsSync(file) && (fs.statSync(file).mode & 0o077) !== 0) {
|
|
808
|
+
line('identity', 'warn', `${file} is readable by other local users ` +
|
|
809
|
+
`(mode ${(fs.statSync(file).mode & 0o777).toString(8).padStart(3, '0')}); it should be 0600`, { check: 'state-file-perms' });
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
const home = config.home();
|
|
813
|
+
// WRITABLE, WHICH IS A DIFFERENT QUESTION FROM 0700. Probed rather than derived from
|
|
814
|
+
// st_mode: a read-only mount, a full disk or a container's user mapping all deny a
|
|
815
|
+
// write with the bits looking fine.
|
|
816
|
+
identityEventLog(line);
|
|
817
|
+
for (const [label, target] of [
|
|
818
|
+
['state root', home],
|
|
819
|
+
['workspaces', (0, home_1.joinPath)(home, 'repros')],
|
|
820
|
+
['locks', (0, home_1.joinPath)(home, 'locks')],
|
|
821
|
+
['journal', (0, journal_1.journalDir)()],
|
|
822
|
+
]) {
|
|
823
|
+
try {
|
|
824
|
+
fs.mkdirSync(target, { recursive: true });
|
|
825
|
+
const probe = (0, home_1.joinPath)(target, '.houston-write-probe');
|
|
826
|
+
fs.writeFileSync(probe, 'x');
|
|
827
|
+
fs.unlinkSync(probe);
|
|
828
|
+
}
|
|
829
|
+
catch (error) {
|
|
830
|
+
// The C library's reason, "Permission denied", where Node's own message was
|
|
831
|
+
// "EACCES: permission denied, open '...'".
|
|
832
|
+
line('identity', 'fail', `${target} is not writable (${(0, format_1.strerrorText)(error, target)}) — every ` +
|
|
833
|
+
`command that creates or records anything will fail the same way. ` +
|
|
834
|
+
`houston's ${label}.`, { check: 'home-writable' });
|
|
835
|
+
break;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
if (fs.existsSync(home) && (fs.statSync(home).mode & 0o077) !== 0) {
|
|
839
|
+
line('identity', 'warn', `${home} is 0${(fs.statSync(home).mode & 0o777).toString(8)}, so another ` +
|
|
840
|
+
'local user can read the accounts and sessions inside it ' +
|
|
841
|
+
'— `serve` tightens it to 0700 at startup', { check: 'home-perms' });
|
|
842
|
+
}
|
|
843
|
+
// A state file written by a NEWER houston must not be half-understood.
|
|
844
|
+
const marker = '# houston-state: ';
|
|
845
|
+
let sessionText;
|
|
846
|
+
try {
|
|
847
|
+
sessionText = fs.readFileSync(sessions.sessionsFile(), 'utf8');
|
|
848
|
+
}
|
|
849
|
+
catch {
|
|
850
|
+
// A failed read: nothing to read, nothing to say
|
|
851
|
+
return;
|
|
852
|
+
}
|
|
853
|
+
// NOT inside the `catch` above. Only a failed read is caught there, so a marker line that
|
|
854
|
+
// is not an integer throws `toInt`'s RangeError out of the whole check -- which degrades to
|
|
855
|
+
// "Identity status could not be determined". Swallowing it would silently ignore a
|
|
856
|
+
// file this build does not understand.
|
|
857
|
+
for (const ln of (0, format_1.splitTextLines)(sessionText)) {
|
|
858
|
+
if (ln.startsWith(marker)) {
|
|
859
|
+
const seen = (0, format_1.toInt)(ln.slice(marker.length));
|
|
860
|
+
if (seen > sessions.STATE_VERSION) {
|
|
861
|
+
line('identity', 'fail', `${sessions.sessionsFile()} was written by a ` +
|
|
862
|
+
`newer houston (state v${String(seen)}, this reads ` +
|
|
863
|
+
`v${String(sessions.STATE_VERSION)}) — upgrade rather ` +
|
|
864
|
+
'than run against it', { check: 'sessions-file' });
|
|
865
|
+
}
|
|
866
|
+
break;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
async function checkIdentity(_ctx) {
|
|
871
|
+
const report = new Report();
|
|
872
|
+
const line = report.line.bind(report);
|
|
873
|
+
// ONE try around both halves: a failure reading the accounts must skip the file checks
|
|
874
|
+
// too and produce exactly one row.
|
|
875
|
+
try {
|
|
876
|
+
identityAccounts(line);
|
|
877
|
+
identityStateFiles(line);
|
|
878
|
+
}
|
|
879
|
+
catch {
|
|
880
|
+
line('identity', 'warn', 'Identity status could not be determined');
|
|
881
|
+
}
|
|
882
|
+
return report.rows;
|
|
883
|
+
}
|
|
884
|
+
async function checkWork(_ctx) {
|
|
885
|
+
const report = new Report();
|
|
886
|
+
const line = report.line.bind(report);
|
|
887
|
+
// SIDE EFFECTS NOBODY MEANT TO LEAVE. The journal is the only durable trace.
|
|
888
|
+
try {
|
|
889
|
+
const stranded = journal.abandoned();
|
|
890
|
+
if (stranded.length > 0) {
|
|
891
|
+
for (const entry of stranded.slice(0, 5)) {
|
|
892
|
+
// The suffix has to match what recovery will actually DO.
|
|
893
|
+
const tail = journal.ADVISORY.includes(entry.kind)
|
|
894
|
+
? ''
|
|
895
|
+
: ' — `houston serve` repairs this at startup, or fix it by hand';
|
|
896
|
+
line('interrupted-work', 'warn', journal.describe(entry) + tail, {
|
|
897
|
+
check: 'interrupted-work',
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
else if (journal.openEntries().length > 0) {
|
|
902
|
+
// Open but owned by a live process: a job is running right now, which is not a
|
|
903
|
+
// fault and must not read as one.
|
|
904
|
+
line('interrupted-work', 'ok', `${String(journal.openEntries().length)} operation(s) in progress ` +
|
|
905
|
+
'(a running job holds them)', { check: 'interrupted-work' });
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
catch {
|
|
909
|
+
// a check must never break the report
|
|
910
|
+
}
|
|
911
|
+
return report.rows;
|
|
912
|
+
}
|
|
913
|
+
// --- presets ------------------------------------------------------------------
|
|
914
|
+
async function checkPresets(_ctx) {
|
|
915
|
+
const report = new Report();
|
|
916
|
+
const line = report.line.bind(report);
|
|
917
|
+
// THE WORKSPACES ALREADY OUT THERE. `up` warns about this at create time now, but
|
|
918
|
+
// every workspace made before that is silent.
|
|
919
|
+
const hostParam = {
|
|
920
|
+
saml: 'idp_host',
|
|
921
|
+
oidc: 'idp_host',
|
|
922
|
+
s3_minio: 's3_host',
|
|
923
|
+
};
|
|
924
|
+
try {
|
|
925
|
+
for (const meta of await (0, record_1.listMeta)()) {
|
|
926
|
+
// OWN keys only of the host-parameter table. A preset named `constructor` -- a legal
|
|
927
|
+
// name -- found Object.prototype's here and printed a bogus `--set function Object()
|
|
928
|
+
// { [native code] }=...` row.
|
|
929
|
+
const extra = bagOf(meta.extra);
|
|
930
|
+
// `toText` of the recorded bind: a falsy recorded value is the empty bind, not the
|
|
931
|
+
// string "false".
|
|
932
|
+
const bind = (0, format_1.toText)(extra.bind_host);
|
|
933
|
+
if (bind === '' || bind === '127.0.0.1' || bind === 'localhost')
|
|
934
|
+
continue;
|
|
935
|
+
// Each preset of a composed workspace, whose params are recorded per preset.
|
|
936
|
+
const names = (0, composite_1.namesOf)((meta.preset || '').trim());
|
|
937
|
+
for (const preset of names) {
|
|
938
|
+
const param = Object.hasOwn(hostParam, preset) ? hostParam[preset] : undefined;
|
|
939
|
+
if (param === undefined)
|
|
940
|
+
continue;
|
|
941
|
+
const own = names.length > 1 ? bagOf(bagOf(extra.preset_params)[preset]) : bagOf(extra.params);
|
|
942
|
+
if ((0, format_1.isTruthy)(own[param]))
|
|
943
|
+
continue; // someone said where the browser is
|
|
944
|
+
const key = names.length > 1 ? `${preset}.${param}` : param;
|
|
945
|
+
line('preset-browser-host', 'warn', `${(0, format_1.quotedText)(meta.name)} is bound to ${bind} but its ${(0, format_1.quotedText)(preset)} ` +
|
|
946
|
+
`preset still points the browser at this machine. From ` +
|
|
947
|
+
`anywhere else that address is the visitor's own laptop and ` +
|
|
948
|
+
`login fails silently. Re-create with ` +
|
|
949
|
+
`\`--set ${key}=<the host people type>\``, { check: 'preset-browser-host' });
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
catch {
|
|
954
|
+
// a check must never break the report
|
|
955
|
+
}
|
|
956
|
+
return report.rows;
|
|
957
|
+
}
|
|
958
|
+
// --- kubernetes ---------------------------------------------------------------
|
|
959
|
+
/** Whether TLS can be issued, and what address a workspace would actually answer on. */
|
|
960
|
+
async function reportCertmanagerAndEndpoints(line, pre) {
|
|
961
|
+
const { certManagerInstalled } = await Promise.resolve().then(() => __importStar(require('./kube/certmanager')));
|
|
962
|
+
const { endpointString, ingressEndpoint } = await Promise.resolve().then(() => __importStar(require('./kube/endpoints')));
|
|
963
|
+
// ASKED ONCE, because this is a CRD read against a remote API server.
|
|
964
|
+
let cm;
|
|
965
|
+
try {
|
|
966
|
+
cm = await certManagerInstalled(pre.context);
|
|
967
|
+
}
|
|
968
|
+
catch {
|
|
969
|
+
cm = false;
|
|
970
|
+
}
|
|
971
|
+
if (cm) {
|
|
972
|
+
line('kubernetes', 'ok', 'cert-manager: installed — a Certificate can be issued in this cluster', { check: 'kubernetes-cert-manager' });
|
|
973
|
+
}
|
|
974
|
+
else {
|
|
975
|
+
line('kubernetes', 'ok', 'cert-manager: not installed — installed on first use by a workspace that asks ' +
|
|
976
|
+
"for a certificate, with the guide's own `kubectl apply`", { check: 'kubernetes-cert-manager' });
|
|
977
|
+
}
|
|
978
|
+
let endpoint;
|
|
979
|
+
try {
|
|
980
|
+
endpoint = await ingressEndpoint(pre.context);
|
|
981
|
+
}
|
|
982
|
+
catch {
|
|
983
|
+
endpoint = null;
|
|
984
|
+
}
|
|
985
|
+
if (endpoint === null) {
|
|
986
|
+
line('kubernetes', 'ok', 'https: not servable yet — this cluster publishes no ' +
|
|
987
|
+
':443 Service reachable from outside it. A workspace ' +
|
|
988
|
+
'that asks for a name installs an ingress controller; ' +
|
|
989
|
+
'port-forward needs none', { check: 'kubernetes-https' });
|
|
990
|
+
}
|
|
991
|
+
else {
|
|
992
|
+
const owner = endpoint.local && endpoint.port === 443 ? "the CLUSTER's own ingress" : "houston's edge";
|
|
993
|
+
const via = endpoint.local && endpoint.port === 443
|
|
994
|
+
? 'directly'
|
|
995
|
+
: `passed through by SNI to ${endpointString(endpoint)}`;
|
|
996
|
+
const where = cm
|
|
997
|
+
? 'TLS terminates in the cluster, from a cert-manager Secret'
|
|
998
|
+
: 'a name would be servable here once cert-manager is installed';
|
|
999
|
+
line('kubernetes', 'ok', `https: ${owner} answers this host's :443, and a ` +
|
|
1000
|
+
`workspace name is served ${via} — ${where} ` +
|
|
1001
|
+
`(${endpoint.source} ${endpointString(endpoint)}, ${endpoint.service})`, { check: 'kubernetes-https' });
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
/** Helm, cert-manager and the endpoints a workspace would be reached on. */
|
|
1005
|
+
async function clusterAddons(line, pre) {
|
|
1006
|
+
const { kube, helmEnv } = await Promise.resolve().then(() => __importStar(require('./kube/exec')));
|
|
1007
|
+
const { CHART } = await Promise.resolve().then(() => __importStar(require('./kube/names')));
|
|
1008
|
+
try {
|
|
1009
|
+
const repo = await kube.run(['helm', 'search', 'repo', CHART, '-o', 'json'], {
|
|
1010
|
+
env: helmEnv(pre.context),
|
|
1011
|
+
});
|
|
1012
|
+
if (repo.returncode === 0 && !['', '[]'].includes(repo.stdout.trim())) {
|
|
1013
|
+
line('kubernetes', 'ok', `chart ${CHART} resolves in houston's Helm home`, {
|
|
1014
|
+
check: 'kubernetes-chart-repo',
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
else {
|
|
1018
|
+
line('kubernetes', 'warn', `chart ${CHART} does not resolve in the Helm ` +
|
|
1019
|
+
`home houston installs from — \`up\` adds the repo ` +
|
|
1020
|
+
`itself, so this matters only if a create fails ` +
|
|
1021
|
+
`naming it`, { check: 'kubernetes-chart-repo' });
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
catch {
|
|
1025
|
+
// a check must never break the report
|
|
1026
|
+
}
|
|
1027
|
+
// HELM'S OWN ANSWER, because houston drives two clients and this check only ever
|
|
1028
|
+
// asked one.
|
|
1029
|
+
if (pre.helmReachable !== '') {
|
|
1030
|
+
line('kubernetes', 'fail', `helm cannot reach cluster ${(0, format_1.quotedText)(pre.context)} although ` +
|
|
1031
|
+
`kubectl can — every Kubernetes create will fail at ` +
|
|
1032
|
+
`the chart, after MongoDB, and roll back. helm said: ` +
|
|
1033
|
+
`${pre.helmReachable}. A kubeconfig left over from a ` +
|
|
1034
|
+
`previous install of the same cluster does this; ` +
|
|
1035
|
+
`regenerate it (k3s: \`sudo cat ` +
|
|
1036
|
+
`/etc/rancher/k3s/k3s.yaml > ~/.kube/config\`, kind: ` +
|
|
1037
|
+
'`kind export kubeconfig --name <cluster>`)', { check: 'kubernetes-helm-reach' });
|
|
1038
|
+
}
|
|
1039
|
+
await reportCertmanagerAndEndpoints(line, pre);
|
|
1040
|
+
}
|
|
1041
|
+
/** The two capabilities a workspace cannot be created without. */
|
|
1042
|
+
function reportStorageAndIngress(line, needed, pre) {
|
|
1043
|
+
if (pre.unreadable.includes('storage')) {
|
|
1044
|
+
line('kubernetes', needed, `Cluster ${(0, format_1.quotedText)(pre.context)} would not let houston read ` +
|
|
1045
|
+
`its StorageClasses, so whether a workspace's volume ` +
|
|
1046
|
+
`can bind is unknown — check the credential in your ` +
|
|
1047
|
+
'kubeconfig has read access', { check: 'kubernetes-storage' });
|
|
1048
|
+
}
|
|
1049
|
+
else if (pre.defaultStorageClass === '') {
|
|
1050
|
+
line('kubernetes', needed, `Cluster ${(0, format_1.quotedText)(pre.context)} has no default ` +
|
|
1051
|
+
`StorageClass — a workspace's volume would stay ` +
|
|
1052
|
+
'Pending with no error naming storage', { check: 'kubernetes-storage' });
|
|
1053
|
+
}
|
|
1054
|
+
else {
|
|
1055
|
+
line('kubernetes', 'ok', `Storage: ${pre.defaultStorageClass} (default)`, {
|
|
1056
|
+
check: 'kubernetes-storage',
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1059
|
+
if (pre.unreadable.includes('ingress')) {
|
|
1060
|
+
line('kubernetes', 'warn', `Cluster ${(0, format_1.quotedText)(pre.context)} would not let houston read ` +
|
|
1061
|
+
'its IngressClasses — whether a hostname can be ' +
|
|
1062
|
+
'served from it is unknown', { check: 'kubernetes-ingress' });
|
|
1063
|
+
}
|
|
1064
|
+
else if (pre.ingressClasses.length > 0) {
|
|
1065
|
+
line('kubernetes', 'ok', `Ingress: ${pre.ingressClasses.join(', ')} — a hostname can be served from this cluster`, {
|
|
1066
|
+
check: 'kubernetes-ingress',
|
|
1067
|
+
});
|
|
1068
|
+
}
|
|
1069
|
+
else {
|
|
1070
|
+
line('kubernetes', 'ok', 'Ingress: none installed — workspaces are reached by ' +
|
|
1071
|
+
'port-forward, which needs no controller', { check: 'kubernetes-ingress' });
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
/** Version skew, storage, ingress, load balancer and metrics. */
|
|
1075
|
+
async function clusterCapabilities(line, needed, pre) {
|
|
1076
|
+
const { skew, KUBECTL_SKEW } = await Promise.resolve().then(() => __importStar(require('./kube/probe')));
|
|
1077
|
+
const gap = await skew(pre.context);
|
|
1078
|
+
if (gap !== null && !gap.ok) {
|
|
1079
|
+
const cv = gap.client.slice(0, 2).join('.');
|
|
1080
|
+
const sv = gap.server.slice(0, 2).join('.');
|
|
1081
|
+
line('kubernetes', needed, `kubectl ${cv} is outside the supported ±${String(KUBECTL_SKEW)} ` +
|
|
1082
|
+
`window for this cluster's API server (${sv}) — calls do not fail cleanly ` +
|
|
1083
|
+
`across that gap, they fail on a field one side does not ` +
|
|
1084
|
+
`know, which reads as a bug in whatever was being deployed`, { check: 'kubernetes-skew' });
|
|
1085
|
+
}
|
|
1086
|
+
else if (gap !== null) {
|
|
1087
|
+
line('kubernetes', 'ok', `kubectl matches the API server (${gap.server.slice(0, 2).join('.')})`, {
|
|
1088
|
+
check: 'kubernetes-skew',
|
|
1089
|
+
});
|
|
1090
|
+
}
|
|
1091
|
+
reportStorageAndIngress(line, needed, pre);
|
|
1092
|
+
if (pre.loadbalancer !== '') {
|
|
1093
|
+
line('kubernetes', 'ok', `Load balancer: working — ${pre.loadbalancer}`, {
|
|
1094
|
+
check: 'kubernetes-loadbalancer',
|
|
1095
|
+
});
|
|
1096
|
+
}
|
|
1097
|
+
else {
|
|
1098
|
+
line('kubernetes', 'ok', 'Load balancer: not confirmed — no LoadBalancer Service ' + 'here has an address', { check: 'kubernetes-loadbalancer' });
|
|
1099
|
+
}
|
|
1100
|
+
if (pre.metrics) {
|
|
1101
|
+
line('kubernetes', 'ok', 'Metrics: metrics-server answering — `houston stats` works here', {
|
|
1102
|
+
check: 'kubernetes-metrics',
|
|
1103
|
+
});
|
|
1104
|
+
}
|
|
1105
|
+
else {
|
|
1106
|
+
line('kubernetes', 'ok', 'Metrics: no metrics-server — `houston stats` refuses ' + 'and says how to install it', { check: 'kubernetes-metrics' });
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
/** Which cluster this is, what shape it is, and whose it is. */
|
|
1110
|
+
async function clusterIdentity(line, pre) {
|
|
1111
|
+
const { CLUSTER_NAME, PROVIDER_EXTERNAL } = await Promise.resolve().then(() => __importStar(require('./kube/names')));
|
|
1112
|
+
const count = pre.namespaces.length > 0 ? `, ${String(pre.namespaces.length)} workspace namespace(s)` : '';
|
|
1113
|
+
// WHAT it is and what SHAPE it is, on the line that names it. "0 nodes" WAS PRINTED
|
|
1114
|
+
// FOR A CLUSTER NOBODY COULD READ, beside a tick.
|
|
1115
|
+
const shapeParts = [];
|
|
1116
|
+
if (pre.unreadable.includes('nodes')) {
|
|
1117
|
+
shapeParts.push('node count unknown');
|
|
1118
|
+
}
|
|
1119
|
+
else {
|
|
1120
|
+
shapeParts.push(`${String(pre.nodeCount)} node${pre.nodeCount === 1 ? '' : 's'}`);
|
|
1121
|
+
}
|
|
1122
|
+
if (pre.architectures.length > 0)
|
|
1123
|
+
shapeParts.push(pre.architectures.join(', '));
|
|
1124
|
+
const shape = shapeParts.join(', ');
|
|
1125
|
+
const where = (shape !== ''
|
|
1126
|
+
? ` (${pre.distribution || 'unknown'}, ${shape})`
|
|
1127
|
+
: ` (${pre.distribution || 'unknown'})`) + count;
|
|
1128
|
+
if (pre.provider === PROVIDER_EXTERNAL) {
|
|
1129
|
+
line('kubernetes', 'ok', `Using cluster ${(0, format_1.quotedText)(pre.context)}${where} — houston creates namespaces ` +
|
|
1130
|
+
'in it; only `houston cluster delete` removes a cluster, and only one houston built', { check: 'kubernetes-cluster' });
|
|
1131
|
+
}
|
|
1132
|
+
else {
|
|
1133
|
+
line('kubernetes', 'ok', `Cluster ${(0, format_1.quotedText)(CLUSTER_NAME)} reachable${where}`, {
|
|
1134
|
+
check: 'kubernetes-cluster',
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
/** Who holds the shared edge, and whether this box can still reach it. */
|
|
1139
|
+
function reportEdgeClaim(claim, harmed, installedEdge, line) {
|
|
1140
|
+
if (!installedEdge)
|
|
1141
|
+
return;
|
|
1142
|
+
const what = harmed.length > 0
|
|
1143
|
+
? `${harmed.slice(0, 3).join(', ')}${harmed.length > 3 ? '…' : ''}`
|
|
1144
|
+
: 'every name it is given';
|
|
1145
|
+
const took = claim.ports
|
|
1146
|
+
.filter((p) => p === 80 || p === 443)
|
|
1147
|
+
.map((p) => `:${String(p)}`)
|
|
1148
|
+
.join(', ');
|
|
1149
|
+
const hurts = [];
|
|
1150
|
+
if (claim.ports.includes(443))
|
|
1151
|
+
hurts.push('serving https', 'the tls-alpn challenge');
|
|
1152
|
+
if (claim.ports.includes(80))
|
|
1153
|
+
hurts.push('the http-01 challenge', 'the :80 redirect');
|
|
1154
|
+
const broken = hurts.length > 1
|
|
1155
|
+
? `${hurts.slice(0, -1).join(', ')} and ${hurts[hurts.length - 1]}`
|
|
1156
|
+
: hurts.length === 1
|
|
1157
|
+
? hurts[0]
|
|
1158
|
+
: "the edge's ports";
|
|
1159
|
+
line('kubernetes', 'warn', `cluster ${(0, format_1.quotedText)(claim.context)} holds this host's ${took} at ` +
|
|
1160
|
+
`${claim.address} (${claim.service}), so houston's edge cannot ` +
|
|
1161
|
+
`receive there: ${what} answers from the cluster through the host ` +
|
|
1162
|
+
`— a 404 and the cluster's own certificate — while the ` +
|
|
1163
|
+
`edge itself is fine and bound. This breaks ` +
|
|
1164
|
+
`${broken}. A box serves HTTPS for one runtime at a ` +
|
|
1165
|
+
`time: remove the edge on a Kubernetes box, or give the host ` +
|
|
1166
|
+
`ports back with \`kubectl -n kube-system patch svc ` +
|
|
1167
|
+
`${claim.service.split('/').at(-1)} -p ` +
|
|
1168
|
+
`'{"spec":{"type":"NodePort"}}'\` — which the ` +
|
|
1169
|
+
`next k3s install undoes, so make it permanent with \`--disable ` +
|
|
1170
|
+
`traefik --disable servicelb\``, { check: 'kubernetes-edge-port' });
|
|
1171
|
+
}
|
|
1172
|
+
/** No cluster yet: say what `up` would build, and what is already on this box. */
|
|
1173
|
+
async function reportClusterToCreate(inUse, k8sWorkspaces, line, pre) {
|
|
1174
|
+
const { CLUSTER_NAME } = await Promise.resolve().then(() => __importStar(require('./kube/names')));
|
|
1175
|
+
const { activeContext } = await Promise.resolve().then(() => __importStar(require('./kube/context')));
|
|
1176
|
+
const { reachable } = await Promise.resolve().then(() => __importStar(require('./kube/reachability')));
|
|
1177
|
+
const { distribution } = await Promise.resolve().then(() => __importStar(require('./kube/context')));
|
|
1178
|
+
const { pretty } = await Promise.resolve().then(() => __importStar(require('./kube/tools')));
|
|
1179
|
+
const kind = pre.tools.kind;
|
|
1180
|
+
// `pretty(kind)`, not `.raw`: the raw line is `kind version 0.32.0 ...`, which read as
|
|
1181
|
+
// "by kind kind version ...". The same fix `reportToolVersions` already carries.
|
|
1182
|
+
const by = kind !== undefined && kind.path !== '' ? ` by kind ${pretty(kind)}` : '';
|
|
1183
|
+
const stale = [...k8sWorkspaces].sort().slice(0, 3).join(', ');
|
|
1184
|
+
const more = k8sWorkspaces.length > 3 ? '…' : '';
|
|
1185
|
+
line('kubernetes', inUse ? 'warn' : 'ok', inUse
|
|
1186
|
+
? `Cluster ${(0, format_1.quotedText)(CLUSTER_NAME)} is gone, so ${String(k8sWorkspaces.length)} ` +
|
|
1187
|
+
`record(s) point at nothing (${stale}${more}). Their data went ` +
|
|
1188
|
+
`with it; \`houston down --name <it> --volumes\` clears each ` +
|
|
1189
|
+
`record, and the next \`up\` builds a fresh cluster.`
|
|
1190
|
+
: `No cluster yet — ${(0, format_1.quotedText)(CLUSTER_NAME)} is created on first use${by}`, { check: 'kubernetes-cluster' });
|
|
1191
|
+
// The box that has BOTH.
|
|
1192
|
+
const other = await activeContext();
|
|
1193
|
+
if (other !== '' && other !== pre.context && (await reachable(other))) {
|
|
1194
|
+
line('kubernetes', 'ok', `Cluster ${(0, format_1.quotedText)(other)} ` +
|
|
1195
|
+
`(${(await distribution(other)) || 'unknown'}) is running and ` +
|
|
1196
|
+
`will NOT be used by default — houston creates its own ` +
|
|
1197
|
+
`while kind is installed. Use it with ` +
|
|
1198
|
+
`\`--context ${other}\`, or make it this box's default ` +
|
|
1199
|
+
`with \`houston config set kubernetes.context ${other}\``, { check: 'kubernetes-other-clusters' });
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
/** The cloud clusters this box remembers making, and what each still costs. */
|
|
1203
|
+
function reportOwnedClusters(cloud, line, remembered) {
|
|
1204
|
+
const eks = require('./eks');
|
|
1205
|
+
for (const owned of remembered) {
|
|
1206
|
+
const left = eks.daysUntil(String(owned.expires ?? ''));
|
|
1207
|
+
// PAST ITS DATE is a louder answer than "still running".
|
|
1208
|
+
const when = left === null
|
|
1209
|
+
? ''
|
|
1210
|
+
: left >= 0
|
|
1211
|
+
? ` — ${String(left)} day(s) left on its expiry`
|
|
1212
|
+
: ` — ${String(-left)} day(s) PAST the expiry it was created with`;
|
|
1213
|
+
line('kubernetes', 'warn', `houston built the ${String(owned.provider ?? 'cloud')} cluster ` +
|
|
1214
|
+
`${(0, format_1.quotedText)(String(owned.name))} in ${String(owned.region)} ` +
|
|
1215
|
+
`(account ${String(owned.account)}) on ` +
|
|
1216
|
+
`${String(owned.created_at ?? '').slice(0, 10)}${when} — it is billing ` +
|
|
1217
|
+
`until \`houston cluster delete ${String(owned.name)}\` removes it`, { check: 'kubernetes-cloud-owned' });
|
|
1218
|
+
}
|
|
1219
|
+
// AND WHEN THE RECORD IS EMPTY BUT THE ACCOUNT IS RIGHT HERE.
|
|
1220
|
+
// `cloudReady`, not a `.ready` attribute: the TypeScript preflight carries the facts
|
|
1221
|
+
// and the helper decides readiness, so reading a missing property would make this
|
|
1222
|
+
// warning unreachable.
|
|
1223
|
+
const ready = eks.cloudReady(cloud);
|
|
1224
|
+
if (remembered.length === 0 && ready) {
|
|
1225
|
+
line('kubernetes', 'warn', 'this box has no local record of a cloud cluster, which is not ' +
|
|
1226
|
+
'the same as there being none — the record is best-effort and a ' +
|
|
1227
|
+
'fresh HOUSTON_HOME, a rebuilt box or a create made elsewhere ' +
|
|
1228
|
+
`all lose it. The account (${eks.identityPretty(cloud.identity)}) is reachable ` +
|
|
1229
|
+
'from here, so ask AWS instead: `houston cluster list` sweeps ' +
|
|
1230
|
+
'every enabled region by tag.', { check: 'kubernetes-cloud-owned' });
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
/** The cloud side: what AWS can be asked, and what this box remembers owning. */
|
|
1234
|
+
async function reportCloudClusters(ctx, line, pre) {
|
|
1235
|
+
const eks = await Promise.resolve().then(() => __importStar(require('./eks')));
|
|
1236
|
+
// Started at the top of runChecks; usually finished by now.
|
|
1237
|
+
const cloud = ctx.cloud !== null
|
|
1238
|
+
? (await ctx.cloud)
|
|
1239
|
+
: (await eks.aws.preflight());
|
|
1240
|
+
const remembered = ctx.owned !== null ? (await ctx.owned) : eks.remembered();
|
|
1241
|
+
reportOwnedClusters(cloud, line, remembered);
|
|
1242
|
+
const tools = Object.values(bagOf(cloud.tools));
|
|
1243
|
+
const onEks = (pre.distribution || '') === 'eks';
|
|
1244
|
+
if (onEks || tools.some((tool) => (tool.path ?? '') !== '')) {
|
|
1245
|
+
const ready = eks.cloudReady(cloud);
|
|
1246
|
+
if (ready) {
|
|
1247
|
+
// WHICH STAGE, of the six the Clusters page and the overview show: ready is stage 1
|
|
1248
|
+
// done, and the row says what stage 2 is and how to do it, or that it is done too.
|
|
1249
|
+
const account = String(bagOf(cloud.identity).account ?? '');
|
|
1250
|
+
const approved = account !== '' && config.approvedAwsAccounts().has(account);
|
|
1251
|
+
const stage = approved
|
|
1252
|
+
? ` — account approved; stage 3 is \`houston cluster create <name> --region ${String(cloud.region ?? '')} --zone <your zone>\``
|
|
1253
|
+
: ` — stage 2, approve the account for spending: \`houston config set ` +
|
|
1254
|
+
`cluster.approved_accounts ${account || '<account id>'}\``;
|
|
1255
|
+
line('kubernetes', 'ok', `AWS ready — ${eks.identityPretty(cloud.identity)}, region ` +
|
|
1256
|
+
`${String(cloud.region ?? '')}${stage}`, { check: 'kubernetes-cloud' });
|
|
1257
|
+
}
|
|
1258
|
+
else {
|
|
1259
|
+
// `fail` only when a cluster in use NEEDS it.
|
|
1260
|
+
for (const blocker of eks.blockers(cloud, { toBuild: true })) {
|
|
1261
|
+
line('kubernetes', onEks ? 'fail' : 'warn', `AWS: ${blocker}`, {
|
|
1262
|
+
check: 'kubernetes-cloud',
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
/** Which of the Kubernetes tools are here, and which are too old to trust. */
|
|
1269
|
+
async function reportToolVersions(k8sWorkspaces, line, needed, pre) {
|
|
1270
|
+
const { missingTools, outdatedTools } = await Promise.resolve().then(() => __importStar(require('./kube/tools')));
|
|
1271
|
+
const { TOOL_FLOOR_REASON, DEFAULT_FLOOR_REASON } = await Promise.resolve().then(() => __importStar(require('./kube/names')));
|
|
1272
|
+
const { tools: allTools } = await Promise.resolve().then(() => __importStar(require('./kube/names')));
|
|
1273
|
+
const missing = missingTools(pre);
|
|
1274
|
+
if (missing.length > 0) {
|
|
1275
|
+
line('kubernetes', 'fail', `${String(k8sWorkspaces.length)} Kubernetes workspace(s) exist but ` +
|
|
1276
|
+
`${missing.join(', ')} is not installed — they ` +
|
|
1277
|
+
'cannot be reached or torn down', { check: 'kubernetes-tools' });
|
|
1278
|
+
}
|
|
1279
|
+
const { pretty: prettyTool, toolsReady } = await Promise.resolve().then(() => __importStar(require('./kube/tools')));
|
|
1280
|
+
for (const name of outdatedTools(pre)) {
|
|
1281
|
+
const got = pre.tools[name];
|
|
1282
|
+
const floor = (allTools()[name] ?? []).join('.');
|
|
1283
|
+
const whyFloor = TOOL_FLOOR_REASON[name] ?? DEFAULT_FLOOR_REASON;
|
|
1284
|
+
// `Tool.pretty` -- the parsed dotted version when there is one, not the raw first
|
|
1285
|
+
// line of the tool's own output.
|
|
1286
|
+
line('kubernetes', needed, `${name} ${prettyTool(got)} is older than ${floor}, ${whyFloor}`, { check: 'kubernetes-tools' });
|
|
1287
|
+
}
|
|
1288
|
+
if (toolsReady(pre)) {
|
|
1289
|
+
line('kubernetes', 'ok', 'Kubernetes tools present (' +
|
|
1290
|
+
Object.values(pre.tools)
|
|
1291
|
+
.filter((tool) => tool.path !== '')
|
|
1292
|
+
.map((tool) => `${tool.name} ${prettyTool(tool)}`)
|
|
1293
|
+
.join(', ') +
|
|
1294
|
+
')', { check: 'kubernetes-tools' });
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
/** The shared edge, the other clusters on this box, and the inotify headroom. */
|
|
1298
|
+
async function reportEdgeAndNeighbours(line, pre, k8sMethods) {
|
|
1299
|
+
const { portClaimingCluster } = await Promise.resolve().then(() => __importStar(require('./kube/endpoints')));
|
|
1300
|
+
let claim;
|
|
1301
|
+
try {
|
|
1302
|
+
claim = await portClaimingCluster({
|
|
1303
|
+
contexts: [pre.context, await k8sMethods.activeContext()].filter((c) => c !== ''),
|
|
1304
|
+
});
|
|
1305
|
+
}
|
|
1306
|
+
catch {
|
|
1307
|
+
claim = null;
|
|
1308
|
+
}
|
|
1309
|
+
if (claim !== null) {
|
|
1310
|
+
try {
|
|
1311
|
+
const edgeSpec = await Promise.resolve().then(() => __importStar(require('./edge/spec')));
|
|
1312
|
+
const installedEdge = edgeSpec.installed();
|
|
1313
|
+
const fd = installedEdge ? edgeSpec.current() : null;
|
|
1314
|
+
const registered = (await Promise.resolve().then(() => __importStar(require('./edge/routes')))).registered();
|
|
1315
|
+
// The GUI's own name is served by the edge too, and on the box where this was
|
|
1316
|
+
// measured it was the ONLY affected name.
|
|
1317
|
+
const harmed = installedEdge
|
|
1318
|
+
? [...(fd !== null && fd.domain !== '' ? [fd.domain] : []), ...registered]
|
|
1319
|
+
: [];
|
|
1320
|
+
reportEdgeClaim(claim, harmed, installedEdge, line);
|
|
1321
|
+
}
|
|
1322
|
+
catch {
|
|
1323
|
+
// a check must not break the report
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
// "Other" must exclude the one we just said we are USING.
|
|
1327
|
+
const others = pre.otherClusters.filter((c) => `kind-${c}` !== pre.context);
|
|
1328
|
+
if (others.length > 0) {
|
|
1329
|
+
line('kubernetes', 'ok', `${String(others.length)} other kind cluster(s) on this box ` +
|
|
1330
|
+
`(${others.join(', ')}) — houston never deletes ` +
|
|
1331
|
+
'a cluster it did not create', { check: 'kubernetes-other-clusters' });
|
|
1332
|
+
}
|
|
1333
|
+
for (const row of inotifyHeadroom(others.length + 1)) {
|
|
1334
|
+
line('kubernetes', row[0], row[1], { check: 'inotify' });
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
/** The cluster row and everything under it. */
|
|
1338
|
+
async function reportCluster(ctx, inUse, k8sWorkspaces, line, needed, pre) {
|
|
1339
|
+
const { CLUSTER_NAME, CONTEXT } = await Promise.resolve().then(() => __importStar(require('./kube/names')));
|
|
1340
|
+
const { missingTools, toolsReady } = await Promise.resolve().then(() => __importStar(require('./kube/tools')));
|
|
1341
|
+
const missing = missingTools(pre);
|
|
1342
|
+
if (missing.length > 0 && !inUse) {
|
|
1343
|
+
// One line, not five.
|
|
1344
|
+
line('kubernetes', 'ok', `Kubernetes not set up (${missing.join(', ')} ` +
|
|
1345
|
+
`not installed) — Compose workspaces are unaffected`, { check: 'kubernetes-tools' });
|
|
1346
|
+
}
|
|
1347
|
+
else {
|
|
1348
|
+
await reportToolVersions(k8sWorkspaces, line, needed, pre);
|
|
1349
|
+
await reportCloudClusters(ctx, line, pre);
|
|
1350
|
+
if (pre.clusterReachable) {
|
|
1351
|
+
await clusterIdentity(line, pre);
|
|
1352
|
+
await clusterCapabilities(line, needed, pre);
|
|
1353
|
+
await clusterAddons(line, pre);
|
|
1354
|
+
}
|
|
1355
|
+
else if (pre.probeFailed !== '') {
|
|
1356
|
+
// NOT "does not exist". `kind` talks to Docker, so this is what a stopped Docker
|
|
1357
|
+
// looks like.
|
|
1358
|
+
line('kubernetes', needed, `Could not tell whether cluster ${(0, format_1.quotedText)(CLUSTER_NAME)} ` +
|
|
1359
|
+
`exists (${pre.probeFailed}) — kind needs Docker`, { check: 'kubernetes-cluster' });
|
|
1360
|
+
}
|
|
1361
|
+
else if (pre.willCreate) {
|
|
1362
|
+
await reportClusterToCreate(inUse, k8sWorkspaces, line, pre);
|
|
1363
|
+
}
|
|
1364
|
+
else if (pre.context === CONTEXT && pre.clusterExists) {
|
|
1365
|
+
line('kubernetes', 'ok', `Cluster ${(0, format_1.quotedText)(CLUSTER_NAME)} exists and this ` +
|
|
1366
|
+
`HOUSTON_HOME has not used it yet, so its kubeconfig is ` +
|
|
1367
|
+
`not exported here — the next \`houston up\` exports it ` +
|
|
1368
|
+
`and reuses the cluster`, { check: 'kubernetes-cluster' });
|
|
1369
|
+
}
|
|
1370
|
+
else if (pre.context !== '') {
|
|
1371
|
+
// NAMED IS NOT CONFIGURED. `doctor --context no-such-context` passed, calling a context
|
|
1372
|
+
// the kubeconfig does not hold "configured but not answering"; `cluster status` says
|
|
1373
|
+
// the true thing, and so does this now -- a failure when it was asked for by name.
|
|
1374
|
+
const { contexts } = await Promise.resolve().then(() => __importStar(require('./kube/context')));
|
|
1375
|
+
const [named, unread] = await contexts();
|
|
1376
|
+
if (unread === '' && !named.includes(pre.context)) {
|
|
1377
|
+
line('kubernetes', ctx.context !== '' ? 'fail' : needed, `No kubeconfig context named ${(0, format_1.quotedText)(pre.context)}` +
|
|
1378
|
+
(named.length > 0
|
|
1379
|
+
? `. This machine can see: ${named.map((name) => (0, format_1.quotedText)(name)).join(', ')}`
|
|
1380
|
+
: ', and the kubeconfig names none'), { check: 'kubernetes-cluster' });
|
|
1381
|
+
}
|
|
1382
|
+
else {
|
|
1383
|
+
line('kubernetes', needed, `Cluster ${(0, format_1.quotedText)(pre.context)} is configured but its API ` +
|
|
1384
|
+
'server is not answering', { check: 'kubernetes-cluster' });
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
else if (toolsReady(pre)) {
|
|
1388
|
+
// CONTEXTS BUT NO CURRENT ONE is not "nothing configured": a deleted cluster that was
|
|
1389
|
+
// current leaves exactly this, and the Clusters page lists the rest as running. houston
|
|
1390
|
+
// never picks one by itself, so it says how -- against the file it actually reads.
|
|
1391
|
+
const { contexts } = await Promise.resolve().then(() => __importStar(require('./kube/context')));
|
|
1392
|
+
const [named] = await contexts();
|
|
1393
|
+
if (named.length > 0) {
|
|
1394
|
+
const { userEnv } = await Promise.resolve().then(() => __importStar(require('./kube/exec')));
|
|
1395
|
+
const file = userEnv()?.KUBECONFIG ?? '';
|
|
1396
|
+
const first = named[0];
|
|
1397
|
+
line('kubernetes', needed, 'kubectl has no current context, so houston has no cluster to use by default. ' +
|
|
1398
|
+
`The kubeconfig names ${named.map((name) => (0, format_1.quotedText)(name)).join(', ')}: ` +
|
|
1399
|
+
`\`kubectl ${file === '' ? '' : `--kubeconfig ${file} `}config use-context ${first}\` ` +
|
|
1400
|
+
`makes one the default, or pass \`--context ${first}\` to the command that needs it`, { check: 'kubernetes-cluster' });
|
|
1401
|
+
}
|
|
1402
|
+
else {
|
|
1403
|
+
line('kubernetes', needed, 'No Kubernetes cluster configured — install kind so ' +
|
|
1404
|
+
'houston can create one, or point kubectl at an ' +
|
|
1405
|
+
'existing cluster (k3s, minikube, Docker Desktop)', { check: 'kubernetes-cluster' });
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
async function checkKubernetes(ctx) {
|
|
1411
|
+
const report = new Report();
|
|
1412
|
+
const line = report.line.bind(report);
|
|
1413
|
+
// Severity depends on whether anything USES Kubernetes.
|
|
1414
|
+
try {
|
|
1415
|
+
const { preflight } = await Promise.resolve().then(() => __importStar(require('./kube/probe')));
|
|
1416
|
+
const { activeContext } = await Promise.resolve().then(() => __importStar(require('./kube/context')));
|
|
1417
|
+
const k8sWorkspaces = (await (0, record_1.listMeta)())
|
|
1418
|
+
.filter((m) => topology.ofMeta(m) === topology.KUBERNETES)
|
|
1419
|
+
.map((m) => m.name);
|
|
1420
|
+
const inUse = k8sWorkspaces.length > 0;
|
|
1421
|
+
const needed = inUse ? 'fail' : 'warn';
|
|
1422
|
+
const pre = await preflight(ctx.context !== '' ? ctx.context : config.defaultKubeContext());
|
|
1423
|
+
await reportCluster(ctx, inUse, k8sWorkspaces, line, needed, pre);
|
|
1424
|
+
await reportEdgeAndNeighbours(line, pre, { activeContext });
|
|
1425
|
+
}
|
|
1426
|
+
catch {
|
|
1427
|
+
line('kubernetes', 'warn', 'Kubernetes status could not be determined');
|
|
1428
|
+
}
|
|
1429
|
+
return report.rows;
|
|
1430
|
+
}
|
|
1431
|
+
// --- orchestration ------------------------------------------------------------
|
|
1432
|
+
/** Module name -> check. Run in this order; the report is read top to bottom. */
|
|
1433
|
+
exports.RUN_ORDER = Object.freeze([
|
|
1434
|
+
['docker', checkDocker],
|
|
1435
|
+
['compose', checkCompose],
|
|
1436
|
+
['kernel', checkKernel],
|
|
1437
|
+
['hub', checkHub],
|
|
1438
|
+
['disk', checkDisk],
|
|
1439
|
+
['memory', checkMemory],
|
|
1440
|
+
['versions', checkVersions],
|
|
1441
|
+
['ports', checkPorts],
|
|
1442
|
+
['install', checkInstall],
|
|
1443
|
+
['legacy', checkLegacy],
|
|
1444
|
+
['edge', checkEdge],
|
|
1445
|
+
['identity', checkIdentity],
|
|
1446
|
+
['k8s', checkKubernetes],
|
|
1447
|
+
['work', checkWork],
|
|
1448
|
+
['presets', checkPresets],
|
|
1449
|
+
]);
|
|
1450
|
+
/** Every check in RUN_ORDER, with its rows concatenated. */
|
|
1451
|
+
async function runEveryCheck(ctx) {
|
|
1452
|
+
const rows = [];
|
|
1453
|
+
for (const [, check] of exports.RUN_ORDER) {
|
|
1454
|
+
rows.push(...(await check(ctx)));
|
|
1455
|
+
}
|
|
1456
|
+
return rows;
|
|
1457
|
+
}
|
|
1458
|
+
/**
|
|
1459
|
+
* Run every preflight check and return the findings.
|
|
1460
|
+
*
|
|
1461
|
+
* `context` names the cluster to report on, defaulting to the box's
|
|
1462
|
+
* `kubernetes.context`. It must be honoured: a preflight whose job is to predict a boot
|
|
1463
|
+
* must not be a second opinion about it.
|
|
1464
|
+
*/
|
|
1465
|
+
async function runChecks(context = '') {
|
|
1466
|
+
const ctx = { context, dockerUp: false, cloud: null, owned: null };
|
|
1467
|
+
// THE AWS PROBE, STARTED NOW AND READ LATER. It is by far the slowest thing this
|
|
1468
|
+
// report does (MEASURED at 1783ms of a 2485ms run) and shares nothing with the local
|
|
1469
|
+
// checks. Errors are carried, not raised: awaiting inside the
|
|
1470
|
+
// check that reads it re-raises there, inside the same `try` the sequential call was
|
|
1471
|
+
// in, so a broken `aws` still degrades exactly as it did.
|
|
1472
|
+
try {
|
|
1473
|
+
const { aws, remembered } = await Promise.resolve().then(() => __importStar(require('./eks')));
|
|
1474
|
+
// The promise is CARRIED, so a rejection re-raises where it is awaited, not where it
|
|
1475
|
+
// started. A no-op handler is attached to each so the
|
|
1476
|
+
// rejection is not ALSO an unhandled-rejection event when a code path (the
|
|
1477
|
+
// missing-tools one-liner) never reaches the await; the stored promise keeps
|
|
1478
|
+
// rejecting, because `catch` returns a NEW promise and the original is what is kept.
|
|
1479
|
+
const cloud = aws.preflight();
|
|
1480
|
+
const owned = Promise.resolve(remembered());
|
|
1481
|
+
void cloud.catch(() => undefined);
|
|
1482
|
+
void owned.catch(() => undefined);
|
|
1483
|
+
ctx.cloud = cloud;
|
|
1484
|
+
ctx.owned = owned;
|
|
1485
|
+
}
|
|
1486
|
+
catch {
|
|
1487
|
+
// a report must not fail to start over this
|
|
1488
|
+
ctx.cloud = null;
|
|
1489
|
+
ctx.owned = null;
|
|
1490
|
+
}
|
|
1491
|
+
const rows = await runEveryCheck(ctx);
|
|
1492
|
+
const counts = { ok: 0, warn: 0, fail: 0 };
|
|
1493
|
+
for (const row of rows) {
|
|
1494
|
+
const status = String(row.status);
|
|
1495
|
+
if (status in counts)
|
|
1496
|
+
counts[status] = (counts[status] ?? 0) + 1;
|
|
1497
|
+
}
|
|
1498
|
+
const verdict = (counts.fail ?? 0) > 0 ? 'fail' : (counts.warn ?? 0) > 0 ? 'warn' : 'ok';
|
|
1499
|
+
// Repro tally. Counted through `listRepros()` so doctor's idea of "running" is the
|
|
1500
|
+
// dashboard's, not a second opinion.
|
|
1501
|
+
let repros = null;
|
|
1502
|
+
if (ctx.dockerUp) {
|
|
1503
|
+
try {
|
|
1504
|
+
const { listRepros } = await Promise.resolve().then(() => __importStar(require('./lifecycle/inspect')));
|
|
1505
|
+
const listed = await listRepros();
|
|
1506
|
+
if (listed.length > 0) {
|
|
1507
|
+
repros = {
|
|
1508
|
+
total: listed.length,
|
|
1509
|
+
running: listed.filter((r) => r.state === 'running').length,
|
|
1510
|
+
};
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
catch {
|
|
1514
|
+
repros = null;
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
return { checks: rows, counts, verdict, repros };
|
|
1518
|
+
}
|