@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,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KUBECTL_SKEW = void 0;
|
|
4
|
+
exports.serverVersion = serverVersion;
|
|
5
|
+
exports.skew = skew;
|
|
6
|
+
exports.preflight = preflight;
|
|
7
|
+
/**
|
|
8
|
+
* Everything `doctor` needs about Kubernetes, in one pass, changing nothing.
|
|
9
|
+
*
|
|
10
|
+
* Tier k2 and the top of it: this module asks every other probe and assembles the answer.
|
|
11
|
+
*/
|
|
12
|
+
const errors_1 = require("../../lib/errors");
|
|
13
|
+
const capabilities_1 = require("./capabilities");
|
|
14
|
+
const context_1 = require("./context");
|
|
15
|
+
const endpoints_1 = require("./endpoints");
|
|
16
|
+
const exec_1 = require("./exec");
|
|
17
|
+
const names_1 = require("./names");
|
|
18
|
+
const reachability_1 = require("./reachability");
|
|
19
|
+
const tools_1 = require("./tools");
|
|
20
|
+
/**
|
|
21
|
+
* How many MINOR versions kubectl may differ from the API server and still be supported.
|
|
22
|
+
* Kubernetes publishes ±1; outside it, calls do not fail cleanly -- they fail on a field
|
|
23
|
+
* the other side does not know about, which reads as a bug in whatever was being deployed.
|
|
24
|
+
*/
|
|
25
|
+
exports.KUBECTL_SKEW = 1;
|
|
26
|
+
/**
|
|
27
|
+
* The API server's version, or null if it could not be read.
|
|
28
|
+
*
|
|
29
|
+
* Separate from the CLIENT version, and the distinction is the whole point of the check
|
|
30
|
+
* below. A static floor cannot express skew: the floor is `kubectl >= 1.21`, and
|
|
31
|
+
* Rocket.Chat's own Launchpad builds clusters at 1.33 -- so a kubectl that passes the floor
|
|
32
|
+
* by eleven minors is still outside the supported window, and passing a floor is exactly
|
|
33
|
+
* what it will report doing.
|
|
34
|
+
*/
|
|
35
|
+
async function serverVersion(context) {
|
|
36
|
+
const res = await exec_1.kube.run(['kubectl', '--context', context, 'version', '--output=json'], {
|
|
37
|
+
own: (0, names_1.isOurs)(context),
|
|
38
|
+
});
|
|
39
|
+
if (res.returncode !== 0)
|
|
40
|
+
return null;
|
|
41
|
+
let raw;
|
|
42
|
+
try {
|
|
43
|
+
const doc = JSON.parse(res.stdout || '{}');
|
|
44
|
+
raw = doc.serverVersion?.gitVersion ?? '';
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const parsed = (0, tools_1.parseVersion)(raw);
|
|
50
|
+
return parsed.length > 0 ? parsed : null;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* How far kubectl is from this cluster's API server, or null if unaskable.
|
|
54
|
+
*
|
|
55
|
+
* Returns the two versions and whether the gap is supported, rather than a verdict:
|
|
56
|
+
* `doctor` wants to say which two numbers it is talking about, and a check that reports
|
|
57
|
+
* "unsupported" without them sends somebody to look up both.
|
|
58
|
+
*/
|
|
59
|
+
async function skew(context, client) {
|
|
60
|
+
const server = await serverVersion(context);
|
|
61
|
+
if (server === null)
|
|
62
|
+
return null;
|
|
63
|
+
const clientVersion = client ?? (await (0, tools_1.tool)('kubectl')).version;
|
|
64
|
+
if (clientVersion.length < 2 || server.length < 2)
|
|
65
|
+
return null;
|
|
66
|
+
const gap = clientVersion[0] === server[0]
|
|
67
|
+
? Math.abs(clientVersion[1] - server[1])
|
|
68
|
+
: 99;
|
|
69
|
+
return { client: clientVersion, server, gap, ok: gap <= exports.KUBECTL_SKEW };
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Everything that needs the cluster, asked in parallel because each is a round trip.
|
|
73
|
+
*
|
|
74
|
+
* EIGHT INDEPENDENT READS, TOGETHER. The ordering rule this function is built on is about
|
|
75
|
+
* the PRECONDITION above it -- there is no point asking an API server for storage classes
|
|
76
|
+
* when kubectl is absent or the server is not answering -- and that gate stays exactly
|
|
77
|
+
* where it was. Everything below it needs only `out.context`.
|
|
78
|
+
*
|
|
79
|
+
* MEASURED against a live EKS cluster: `doctor` made 42 calls in 24.3 seconds, and about
|
|
80
|
+
* forty of them were kubectl or helm round trips at 1.2-2.2 s each.
|
|
81
|
+
*
|
|
82
|
+
* `unreadable` is appended in a FIXED order afterwards rather than as each answer lands, so
|
|
83
|
+
* the report does not vary with which call happened to return first.
|
|
84
|
+
*/
|
|
85
|
+
async function fillInClusterFacts(out) {
|
|
86
|
+
const [helm, sc, ic, ns, dist, nodes, metrics, lb] = await Promise.all([
|
|
87
|
+
// Asked HERE, beside kubectl's answer, so a disagreement is found before a create
|
|
88
|
+
// spends four minutes earning it.
|
|
89
|
+
(0, reachability_1.helmReachable)(out.context),
|
|
90
|
+
// EACH ANSWER READ, not assumed. `reachable()` probes /readyz, which a restricted
|
|
91
|
+
// credential can usually still get -- so passing it is not evidence that any of these
|
|
92
|
+
// reads will be permitted.
|
|
93
|
+
(0, capabilities_1.storageClasses)(out.context),
|
|
94
|
+
(0, capabilities_1.ingressClasses)(out.context),
|
|
95
|
+
(0, capabilities_1.workspaceNamespaces)(out.context),
|
|
96
|
+
(0, context_1.distribution)(out.context),
|
|
97
|
+
(0, capabilities_1.nodesSummary)(out.context),
|
|
98
|
+
(0, capabilities_1.metricsAvailable)(out.context),
|
|
99
|
+
(0, endpoints_1.loadbalancerAddress)(out.context),
|
|
100
|
+
]);
|
|
101
|
+
out.helmReachable = helm;
|
|
102
|
+
if (sc === null)
|
|
103
|
+
out.unreadable.push('storage');
|
|
104
|
+
else
|
|
105
|
+
[out.storageClasses, out.defaultStorageClass] = sc;
|
|
106
|
+
if (ic === null)
|
|
107
|
+
out.unreadable.push('ingress');
|
|
108
|
+
else
|
|
109
|
+
out.ingressClasses = ic;
|
|
110
|
+
if (ns === null)
|
|
111
|
+
out.unreadable.push('namespaces');
|
|
112
|
+
else
|
|
113
|
+
out.namespaces = ns;
|
|
114
|
+
out.distribution = dist;
|
|
115
|
+
if (nodes === null)
|
|
116
|
+
out.unreadable.push('nodes');
|
|
117
|
+
else
|
|
118
|
+
[out.nodeCount, out.architectures] = nodes;
|
|
119
|
+
out.metrics = metrics;
|
|
120
|
+
out.loadbalancer = lb;
|
|
121
|
+
}
|
|
122
|
+
/** Which context this run uses, and everything only the cluster can answer. */
|
|
123
|
+
async function settleContextAndAskTheCluster(context, out) {
|
|
124
|
+
// THE SAME FUNCTION `up` USES, and that is the whole point of the call. An earlier
|
|
125
|
+
// version resolved the context itself, which agreed with `planCluster` on every box that
|
|
126
|
+
// had only one of the two and disagreed on the box that had both: with `kind` installed
|
|
127
|
+
// but no cluster yet and k3s running, `doctor` reported "Using your cluster 'default'
|
|
128
|
+
// (k3s)" while `up` went and created a kind cluster. A preflight whose job is to predict
|
|
129
|
+
// a boot must not be a second opinion about it.
|
|
130
|
+
if (context !== '') {
|
|
131
|
+
out.context = context;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
let plan = null;
|
|
135
|
+
try {
|
|
136
|
+
plan = await (0, context_1.planCluster)();
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
if (!(error instanceof errors_1.PreflightError))
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
if (plan !== null) {
|
|
143
|
+
out.context = plan.context;
|
|
144
|
+
out.willCreate = plan.create;
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
// THE REASON WAS THROWN AWAY WITH THE EXCEPTION. `planCluster` raises both for "no
|
|
148
|
+
// kind and no kubeconfig" and for "kubectl is pointed at 'X', which is not
|
|
149
|
+
// answering", and dropping it left `context` empty -- so doctor fell through to "No
|
|
150
|
+
// Kubernetes cluster configured" for somebody whose cluster IS configured and whose
|
|
151
|
+
// credentials are what need fixing. It sent them to configure a second one.
|
|
152
|
+
out.context = await (0, context_1.activeContext)();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
out.provider = out.context === names_1.CONTEXT ? names_1.PROVIDER_KIND : names_1.PROVIDER_EXTERNAL;
|
|
156
|
+
if (out.context === '' || out.willCreate) {
|
|
157
|
+
// Nothing to probe: the cluster this create would use does not exist yet, and asking
|
|
158
|
+
// the OTHER cluster for its storage classes would describe a machine houston is not
|
|
159
|
+
// about to use.
|
|
160
|
+
return out;
|
|
161
|
+
}
|
|
162
|
+
out.clusterReachable = await (0, reachability_1.reachable)(out.context);
|
|
163
|
+
if (!out.clusterReachable)
|
|
164
|
+
return out;
|
|
165
|
+
await fillInClusterFacts(out);
|
|
166
|
+
return out;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Everything `doctor` needs, in one pass, changing nothing.
|
|
170
|
+
*
|
|
171
|
+
* kind is optional. Creating a cluster needs it; using one does not. So a missing `kind`
|
|
172
|
+
* narrows what houston can do -- it cannot make you a cluster -- without stopping it
|
|
173
|
+
* working in the cluster you already have.
|
|
174
|
+
*
|
|
175
|
+
* Which cluster gets probed, in order: the one asked for, else houston's own if it exists,
|
|
176
|
+
* else whatever `kubectl` is already pointed at.
|
|
177
|
+
*
|
|
178
|
+
* Ordered so each step's precondition is known. There is no point asking an API server for
|
|
179
|
+
* storage classes when `kubectl` is absent or the server is not answering, and a timeout
|
|
180
|
+
* there would be misreported as "no storage".
|
|
181
|
+
*/
|
|
182
|
+
async function preflight(context = '') {
|
|
183
|
+
// One tool at a time, in TOOLS order, as `{name: tools.tool(name) for name in TOOLS}`
|
|
184
|
+
// asks them. `Promise.all` ran the four version probes at once, so `helm version --short`
|
|
185
|
+
// could reach the log before `kubectl version --client`, in a different order from run to
|
|
186
|
+
// run.
|
|
187
|
+
const found = [];
|
|
188
|
+
for (const name of Object.keys((0, names_1.tools)()))
|
|
189
|
+
found.push([name, await (0, tools_1.tool)(name)]);
|
|
190
|
+
const out = (0, tools_1.preflight)({ tools: Object.fromEntries(found) });
|
|
191
|
+
if ((0, tools_1.canProvision)(out)) {
|
|
192
|
+
const [seen, probeFailed] = await (0, context_1.clusters)();
|
|
193
|
+
out.probeFailed = probeFailed;
|
|
194
|
+
if (probeFailed !== '')
|
|
195
|
+
return out;
|
|
196
|
+
out.clusterExists = seen.includes(names_1.CLUSTER_NAME);
|
|
197
|
+
out.otherClusters = seen.filter((entry) => entry !== names_1.CLUSTER_NAME);
|
|
198
|
+
}
|
|
199
|
+
if (out.tools.kubectl === undefined || out.tools.kubectl.path === '')
|
|
200
|
+
return out;
|
|
201
|
+
return await settleContextAndAskTheCluster(context, out);
|
|
202
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.REACH_DOWN = exports.REACH_NO_CONTEXT = exports.REACH_DENIED = exports.REACH_OK = void 0;
|
|
4
|
+
exports.reachOk = reachOk;
|
|
5
|
+
exports.reachDenied = reachDenied;
|
|
6
|
+
exports.reachWhy = reachWhy;
|
|
7
|
+
exports.reachAdvice = reachAdvice;
|
|
8
|
+
exports.reach = reach;
|
|
9
|
+
exports.reachable = reachable;
|
|
10
|
+
exports.helmReachable = helmReachable;
|
|
11
|
+
/**
|
|
12
|
+
* Can this cluster be reached, and if not, WHY.
|
|
13
|
+
*
|
|
14
|
+
* Tier k2, read-only. `Reach` classifies what came back into four states, and the distinction
|
|
15
|
+
* between them is the whole point: refused credentials mean the cluster is up and this is a
|
|
16
|
+
* permissions problem; no kubeconfig entry is not a statement about the cluster at all; and
|
|
17
|
+
* nothing answering is the only one that might mean it is gone.
|
|
18
|
+
*/
|
|
19
|
+
const exec_1 = require("./exec");
|
|
20
|
+
const names_1 = require("./names");
|
|
21
|
+
const tools_1 = require("./tools");
|
|
22
|
+
/**
|
|
23
|
+
* `reach()` answers. Four, because the probe can fail in four ways that need four
|
|
24
|
+
* different things done about them, and collapsing them to a bool sent people to check a
|
|
25
|
+
* healthy cluster three separate times in one day of live testing.
|
|
26
|
+
*/
|
|
27
|
+
exports.REACH_OK = 'ok';
|
|
28
|
+
exports.REACH_DENIED = 'denied';
|
|
29
|
+
exports.REACH_NO_CONTEXT = 'no-context';
|
|
30
|
+
exports.REACH_DOWN = 'down';
|
|
31
|
+
/**
|
|
32
|
+
* What the API server says when it is answering and refusing. EKS phrases it two ways
|
|
33
|
+
* depending on which client asks -- `kubectl get --raw` gets the first, the discovery
|
|
34
|
+
* client the second -- and both were observed on one cluster on the same afternoon, so
|
|
35
|
+
* matching only one of them is matching none of them half the time.
|
|
36
|
+
*/
|
|
37
|
+
const DENIED_MARKS = [
|
|
38
|
+
'unauthorized',
|
|
39
|
+
'must be logged in',
|
|
40
|
+
'asked for the client to provide credentials',
|
|
41
|
+
'forbidden',
|
|
42
|
+
'error from server (forbidden)',
|
|
43
|
+
];
|
|
44
|
+
/**
|
|
45
|
+
* What kubectl says when the kubeconfig has never heard of the context. NOT a statement
|
|
46
|
+
* about the cluster: this is the answer for a perfectly healthy cluster that nobody has
|
|
47
|
+
* run `aws eks update-kubeconfig` for on this box, and reading it as "the cluster is
|
|
48
|
+
* down" is how `cluster delete` came to report an ACTIVE cluster as not answering.
|
|
49
|
+
*
|
|
50
|
+
* TWO PHRASINGS, both observed on this box on the same day: `kubectl get --raw` answers
|
|
51
|
+
* `error: context "x" does not exist`, while the client-config path answers `Error in
|
|
52
|
+
* configuration: context was not found for specified context: x`.
|
|
53
|
+
*/
|
|
54
|
+
const NO_CONTEXT_PATTERNS = [
|
|
55
|
+
/context .*(?:does not exist|was not found)/u,
|
|
56
|
+
/no context exists with the name/u,
|
|
57
|
+
];
|
|
58
|
+
function reachOk(value) {
|
|
59
|
+
return value.status === exports.REACH_OK;
|
|
60
|
+
}
|
|
61
|
+
/** Answered, and said no. The cluster is up; the credential is the problem. */
|
|
62
|
+
function reachDenied(value) {
|
|
63
|
+
return value.status === exports.REACH_DENIED;
|
|
64
|
+
}
|
|
65
|
+
/** One sentence naming the actual cause, for a refusal message to carry. */
|
|
66
|
+
function reachWhy(value) {
|
|
67
|
+
if (value.status === exports.REACH_OK)
|
|
68
|
+
return '';
|
|
69
|
+
if (value.status === exports.REACH_DENIED) {
|
|
70
|
+
return ('it answered and refused these credentials, so the cluster is up and this is a ' +
|
|
71
|
+
'permissions problem');
|
|
72
|
+
}
|
|
73
|
+
if (value.status === exports.REACH_NO_CONTEXT) {
|
|
74
|
+
return ('this machine has no kubeconfig entry for it, which is not a statement about the ' + 'cluster');
|
|
75
|
+
}
|
|
76
|
+
return 'nothing answered: it may be stopped, deleted, or unreachable from here';
|
|
77
|
+
}
|
|
78
|
+
/** What to actually do about it. Empty when there is nothing to say. */
|
|
79
|
+
function reachAdvice(value, context = '') {
|
|
80
|
+
if (value.status === exports.REACH_DENIED) {
|
|
81
|
+
return (' An EKS cluster grants Kubernetes access separately from IAM: ask whoever ' +
|
|
82
|
+
'created it to run `aws eks create-access-entry`, or check `kubectl auth whoami`.');
|
|
83
|
+
}
|
|
84
|
+
if (value.status === exports.REACH_NO_CONTEXT) {
|
|
85
|
+
if (context.startsWith('arn:aws:eks:')) {
|
|
86
|
+
return (' For an EKS cluster, `aws eks update-kubeconfig --name <cluster> --region ' +
|
|
87
|
+
'<region>` writes it.');
|
|
88
|
+
}
|
|
89
|
+
return ' `kubectl config get-contexts` lists the ones this box knows.';
|
|
90
|
+
}
|
|
91
|
+
return '';
|
|
92
|
+
}
|
|
93
|
+
/** Probe the API server and classify what came back. Never raises. */
|
|
94
|
+
async function reach(context = names_1.CONTEXT, timeout = names_1.PROBE_TIMEOUT) {
|
|
95
|
+
const res = await exec_1.kube.run(['kubectl', '--context', context, 'get', '--raw', '/readyz'], {
|
|
96
|
+
own: (0, names_1.isOurs)(context),
|
|
97
|
+
timeout,
|
|
98
|
+
});
|
|
99
|
+
if (res.returncode === 0 && res.stdout.toLowerCase().includes('ok')) {
|
|
100
|
+
return { status: exports.REACH_OK, detail: '' };
|
|
101
|
+
}
|
|
102
|
+
// BOTH STREAMS. kubectl writes its configuration errors to stderr and some server
|
|
103
|
+
// errors to stdout, and which one carries the reason varies by subcommand -- so a
|
|
104
|
+
// classifier that reads one of them misfiles the other as REACH_DOWN, which is the
|
|
105
|
+
// exact conflation this type exists to end.
|
|
106
|
+
const said = `${res.stderr}\n${res.stdout}`.toLowerCase();
|
|
107
|
+
const lines = (res.stderr || res.stdout).trim().split('\n');
|
|
108
|
+
const first = lines.length > 0 ? lines[0].trim() : '';
|
|
109
|
+
for (const pattern of NO_CONTEXT_PATTERNS) {
|
|
110
|
+
if (pattern.test(said))
|
|
111
|
+
return { status: exports.REACH_NO_CONTEXT, detail: first };
|
|
112
|
+
}
|
|
113
|
+
for (const mark of DENIED_MARKS) {
|
|
114
|
+
if (said.includes(mark))
|
|
115
|
+
return { status: exports.REACH_DENIED, detail: first };
|
|
116
|
+
}
|
|
117
|
+
return { status: exports.REACH_DOWN, detail: first };
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Whether the API server answers. A cluster can exist and not respond -- a stopped
|
|
121
|
+
* Docker, a half-deleted cluster, a machine that just woke up.
|
|
122
|
+
*
|
|
123
|
+
* KEPT AS A BOOL on purpose. Most callers are resolution order, where the four-way
|
|
124
|
+
* answer would be noise and the only question is whether this candidate can be used.
|
|
125
|
+
* Callers that put the result in front of a person use `reach()` instead.
|
|
126
|
+
*/
|
|
127
|
+
async function reachable(context = names_1.CONTEXT, timeout = names_1.PROBE_TIMEOUT) {
|
|
128
|
+
return reachOk(await reach(context, timeout));
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Whether HELM can reach the cluster, and if not, what it said.
|
|
132
|
+
*
|
|
133
|
+
* Asked SEPARATELY from `reachable` because houston drives two clients and they do not
|
|
134
|
+
* share a code path: kubectl gets `--context` and, for an adopted cluster, whatever
|
|
135
|
+
* kubeconfig the user has; helm gets the same context through `helmEnv`. They can
|
|
136
|
+
* disagree, and when they do the create is already four minutes in.
|
|
137
|
+
*
|
|
138
|
+
* Measured on this box. `~/.kube/config` held the server CA and client certificate of a
|
|
139
|
+
* PREVIOUS k3s installation. kubectl was completely happy: `get ns`, `auth whoami` as
|
|
140
|
+
* system:admin, the whole MongoDB phase of a create. Helm refused every call with
|
|
141
|
+
* "kubernetes cluster unreachable: ... x509: certificate signed by unknown authority",
|
|
142
|
+
* so `up --runtime kubernetes` built a namespace, a StatefulSet, a PersistentVolume and
|
|
143
|
+
* an initiated replica set, then died at the chart and rolled all of it back. The error
|
|
144
|
+
* named neither the cause nor the cure, and `doctor` said the cluster was fine --
|
|
145
|
+
* because doctor only ever asked kubectl.
|
|
146
|
+
*
|
|
147
|
+
* Returns '' when helm is happy, else the line worth showing. `helm list` and not
|
|
148
|
+
* `version`: it needs a real authenticated round trip, which is the thing in doubt.
|
|
149
|
+
*/
|
|
150
|
+
async function helmReachable(context = names_1.CONTEXT, timeout = names_1.PROBE_TIMEOUT) {
|
|
151
|
+
if ((0, tools_1.which)('helm') === '')
|
|
152
|
+
return ''; // a missing helm is already its own check
|
|
153
|
+
// `helmEnv`, not `own`: helm's own state is always houston's while the kubeconfig
|
|
154
|
+
// belongs to whoever owns the cluster -- the distinction that module exists for, and
|
|
155
|
+
// the one this probe has to reproduce exactly or it would be testing a different
|
|
156
|
+
// client than the create uses.
|
|
157
|
+
const res = await exec_1.kube.run(['helm', 'list', '--kube-context', context, '-n', 'default', '--max', '1'], { env: (0, exec_1.helmEnv)(context), timeout });
|
|
158
|
+
if (res.returncode === 0)
|
|
159
|
+
return '';
|
|
160
|
+
const lines = (res.stderr || res.stdout).trim().split('\n');
|
|
161
|
+
const first = lines.length > 0 ? lines[0] : '';
|
|
162
|
+
return first !== '' ? first.slice(0, 300) : `helm exited ${String(res.returncode)}`;
|
|
163
|
+
}
|