alasio 8.0.0 → 10.0.0
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/dist/cli/src/api-server.js +18 -0
- package/dist/cli/src/api-server.js.map +1 -0
- package/dist/cli/src/bound-harnesses.js +98 -0
- package/dist/cli/src/bound-harnesses.js.map +1 -0
- package/dist/cli/src/branches.js +79 -22
- package/dist/cli/src/branches.js.map +1 -1
- package/dist/cli/src/cluster/docker.js +40 -15
- package/dist/cli/src/cluster/docker.js.map +1 -1
- package/dist/cli/src/cluster/host.js +38 -8
- package/dist/cli/src/cluster/host.js.map +1 -1
- package/dist/cli/src/cluster/k3s.js +105 -14
- package/dist/cli/src/cluster/k3s.js.map +1 -1
- package/dist/cli/src/cluster/node.js +142 -33
- package/dist/cli/src/cluster/node.js.map +1 -1
- package/dist/cli/src/cluster/stargz.js +92 -0
- package/dist/cli/src/cluster/stargz.js.map +1 -0
- package/dist/cli/src/commands/branch.js +5 -4
- package/dist/cli/src/commands/branch.js.map +1 -1
- package/dist/cli/src/commands/common.js +11 -5
- package/dist/cli/src/commands/common.js.map +1 -1
- package/dist/cli/src/commands/folder.js +14 -0
- package/dist/cli/src/commands/folder.js.map +1 -0
- package/dist/cli/src/commands/lake.js +1 -1
- package/dist/cli/src/commands/lake.js.map +1 -1
- package/dist/cli/src/commands/login-relay.js +91 -0
- package/dist/cli/src/commands/login-relay.js.map +1 -0
- package/dist/cli/src/commands/login.js +11 -10
- package/dist/cli/src/commands/login.js.map +1 -1
- package/dist/cli/src/commands/logs.js +89 -6
- package/dist/cli/src/commands/logs.js.map +1 -1
- package/dist/cli/src/commands/restart.js +10 -4
- package/dist/cli/src/commands/restart.js.map +1 -1
- package/dist/cli/src/commands/restore-filer-store.js +27 -10
- package/dist/cli/src/commands/restore-filer-store.js.map +1 -1
- package/dist/cli/src/commands/status.js +119 -20
- package/dist/cli/src/commands/status.js.map +1 -1
- package/dist/cli/src/commands/uninstall.js +8 -9
- package/dist/cli/src/commands/uninstall.js.map +1 -1
- package/dist/cli/src/commands/up.js +20 -9
- package/dist/cli/src/commands/up.js.map +1 -1
- package/dist/cli/src/commands/upgrade.js +22 -6
- package/dist/cli/src/commands/upgrade.js.map +1 -1
- package/dist/cli/src/commands.js +2 -1
- package/dist/cli/src/commands.js.map +1 -1
- package/dist/cli/src/config.js +4 -1
- package/dist/cli/src/config.js.map +1 -1
- package/dist/cli/src/cpu-baseline.js +8 -4
- package/dist/cli/src/cpu-baseline.js.map +1 -1
- package/dist/cli/src/folders.js +63 -0
- package/dist/cli/src/folders.js.map +1 -0
- package/dist/cli/src/gateway-calls.js +64 -0
- package/dist/cli/src/gateway-calls.js.map +1 -0
- package/dist/cli/src/install.js +45 -31
- package/dist/cli/src/install.js.map +1 -1
- package/dist/cli/src/kept-releases.js +27 -20
- package/dist/cli/src/kept-releases.js.map +1 -1
- package/dist/cli/src/kube/api.js +61 -15
- package/dist/cli/src/kube/api.js.map +1 -1
- package/dist/cli/src/kube/apply.js +122 -81
- package/dist/cli/src/kube/apply.js.map +1 -1
- package/dist/cli/src/kube/rollout.js +43 -21
- package/dist/cli/src/kube/rollout.js.map +1 -1
- package/dist/cli/src/main.js +2 -1
- package/dist/cli/src/main.js.map +1 -1
- package/dist/cli/src/manifests/admission.js +558 -222
- package/dist/cli/src/manifests/admission.js.map +1 -1
- package/dist/cli/src/manifests/alasio.js +180 -428
- package/dist/cli/src/manifests/alasio.js.map +1 -1
- package/dist/cli/src/manifests/branch.js +16 -27
- package/dist/cli/src/manifests/branch.js.map +1 -1
- package/dist/cli/src/manifests/codex-login.js +101 -0
- package/dist/cli/src/manifests/codex-login.js.map +1 -0
- package/dist/cli/src/manifests/collector.js +83 -62
- package/dist/cli/src/manifests/collector.js.map +1 -1
- package/dist/cli/src/manifests/common.js +82 -25
- package/dist/cli/src/manifests/common.js.map +1 -1
- package/dist/cli/src/manifests/config.js +137 -105
- package/dist/cli/src/manifests/config.js.map +1 -1
- package/dist/cli/src/manifests/disruption.js +18 -3
- package/dist/cli/src/manifests/disruption.js.map +1 -1
- package/dist/cli/src/manifests/folders.js +131 -0
- package/dist/cli/src/manifests/folders.js.map +1 -0
- package/dist/cli/src/manifests/grafana.js +4 -2
- package/dist/cli/src/manifests/grafana.js.map +1 -1
- package/dist/cli/src/manifests/harness-pools.js +236 -0
- package/dist/cli/src/manifests/harness-pools.js.map +1 -0
- package/dist/cli/src/manifests/image-holder.js +61 -0
- package/dist/cli/src/manifests/image-holder.js.map +1 -0
- package/dist/cli/src/manifests/index.js +14 -7
- package/dist/cli/src/manifests/index.js.map +1 -1
- package/dist/cli/src/manifests/keda.js +4 -2
- package/dist/cli/src/manifests/keda.js.map +1 -1
- package/dist/cli/src/manifests/lake.js +18 -20
- package/dist/cli/src/manifests/lake.js.map +1 -1
- package/dist/cli/src/manifests/log.js +84 -19
- package/dist/cli/src/manifests/log.js.map +1 -1
- package/dist/cli/src/manifests/neon.js +60 -80
- package/dist/cli/src/manifests/neon.js.map +1 -1
- package/dist/cli/src/manifests/network-policies.js +232 -94
- package/dist/cli/src/manifests/network-policies.js.map +1 -1
- package/dist/cli/src/manifests/node-agent.js +42 -15
- package/dist/cli/src/manifests/node-agent.js.map +1 -1
- package/dist/cli/src/manifests/object-store.js +99 -25
- package/dist/cli/src/manifests/object-store.js.map +1 -1
- package/dist/cli/src/manifests/sandbox-gateway.js +761 -0
- package/dist/cli/src/manifests/sandbox-gateway.js.map +1 -0
- package/dist/cli/src/manifests/scalers.js +17 -5
- package/dist/cli/src/manifests/scalers.js.map +1 -1
- package/dist/cli/src/manifests/sizing.js +17 -9
- package/dist/cli/src/manifests/sizing.js.map +1 -1
- package/dist/cli/src/manifests/valkey.js +30 -10
- package/dist/cli/src/manifests/valkey.js.map +1 -1
- package/dist/cli/src/manifests/volume-lock.js +43 -0
- package/dist/cli/src/manifests/volume-lock.js.map +1 -0
- package/dist/cli/src/manifests/vpa.js +15 -2
- package/dist/cli/src/manifests/vpa.js.map +1 -1
- package/dist/cli/src/manifests/workspace-storage.js +182 -94
- package/dist/cli/src/manifests/workspace-storage.js.map +1 -1
- package/dist/cli/src/neon-storage.js +54 -16
- package/dist/cli/src/neon-storage.js.map +1 -1
- package/dist/cli/src/release.js +9 -9
- package/dist/cli/src/release.js.map +1 -1
- package/dist/cli/src/setup-pod.js +44 -0
- package/dist/cli/src/setup-pod.js.map +1 -0
- package/dist/cli/src/target.js +2 -2
- package/dist/cli/src/target.js.map +1 -1
- package/dist/cli/src/telegram.js +13 -4
- package/dist/cli/src/telegram.js.map +1 -1
- package/dist/cli/src/wakes.js +68 -0
- package/dist/cli/src/wakes.js.map +1 -0
- package/dist/cli/src/webhook.js +5 -2
- package/dist/cli/src/webhook.js.map +1 -1
- package/dist/cluster/node/pins.json +11 -5
- package/dist/neon/control/branches.js +13 -6
- package/dist/neon/control/branches.js.map +1 -1
- package/dist/neon/control/endpoints.js +81 -10
- package/dist/neon/control/endpoints.js.map +1 -1
- package/dist/neon/control/secrets.js +24 -8
- package/dist/neon/control/secrets.js.map +1 -1
- package/dist/src/binder/bindings.js +195 -0
- package/dist/src/binder/bindings.js.map +1 -0
- package/dist/src/binder/names.js +63 -0
- package/dist/src/binder/names.js.map +1 -0
- package/dist/src/binder/tokens.js +71 -0
- package/dist/src/binder/tokens.js.map +1 -0
- package/dist/src/branch/names.js +20 -6
- package/dist/src/branch/names.js.map +1 -1
- package/dist/src/events/names.js +28 -0
- package/dist/src/events/names.js.map +1 -0
- package/dist/src/gateway/names.js +240 -0
- package/dist/src/gateway/names.js.map +1 -0
- package/dist/src/harness/names.js +67 -0
- package/dist/src/harness/names.js.map +1 -0
- package/dist/src/kube/client.js +212 -0
- package/dist/src/kube/client.js.map +1 -0
- package/dist/src/kube/sandbox-shape.js +14 -68
- package/dist/src/kube/sandbox-shape.js.map +1 -1
- package/dist/src/kube/started-map.js +12 -0
- package/dist/src/kube/started-map.js.map +1 -0
- package/dist/src/node-agent/names.js +62 -5
- package/dist/src/node-agent/names.js.map +1 -1
- package/dist/src/sandbox/names.js +12 -20
- package/dist/src/sandbox/names.js.map +1 -1
- package/dist/src/sandbox/otlp-resource.js +173 -0
- package/dist/src/sandbox/otlp-resource.js.map +1 -0
- package/dist/src/sandbox/telemetry.js +43 -0
- package/dist/src/sandbox/telemetry.js.map +1 -0
- package/dist/src/telegram/bot-commands.js +17 -0
- package/dist/src/telegram/bot-commands.js.map +1 -0
- package/dist/src/telegram/stop.js +12 -0
- package/dist/src/telegram/stop.js.map +1 -0
- package/dist/src/telemetry/config.js +131 -0
- package/dist/src/telemetry/config.js.map +1 -0
- package/dist/src/telemetry/forward.js +154 -0
- package/dist/src/telemetry/forward.js.map +1 -0
- package/package.json +1 -1
- package/dist/cli/src/manifests/agent-sandbox.js +0 -92
- package/dist/cli/src/manifests/agent-sandbox.js.map +0 -1
- package/dist/cli/src/manifests/juicefs-csi.js +0 -320
- package/dist/cli/src/manifests/juicefs-csi.js.map +0 -1
- package/dist/cli/src/manifests/sandboxes.agents.x-k8s.io.json +0 -6295
- package/dist/src/kube/config.js +0 -145
- package/dist/src/kube/config.js.map +0 -1
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* alasio's one door to the Kubernetes API (decision 001 of the Kubernetes design): a
|
|
3
|
+
* narrow client over @kubernetes/client-node, so the modules that drive workloads take
|
|
4
|
+
* this small service and their tests a fake of it.
|
|
5
|
+
*
|
|
6
|
+
* In a pod it authenticates as the pod's ServiceAccount; elsewhere (tests, a developer's
|
|
7
|
+
* machine) as the current context of `KUBECONFIG` or ~/.kube/config.
|
|
8
|
+
*/
|
|
9
|
+
import { request } from "node:http";
|
|
10
|
+
import { createInterface } from "node:readline";
|
|
11
|
+
import { PassThrough } from "node:stream";
|
|
12
|
+
import { finished } from "node:stream/promises";
|
|
13
|
+
import { isDeepStrictEqual } from "node:util";
|
|
14
|
+
import { CoreV1Api, Exec, KubeConfig, KubernetesObjectApi, PatchStrategy, setHeaderOptions } from "@kubernetes/client-node";
|
|
15
|
+
import { Cause, Context, Effect, Layer, Predicate, Queue, Result, Schema, Stream } from "effect";
|
|
16
|
+
/** The annotation of the bookmark that ends a watch's initial events. */
|
|
17
|
+
export const INITIAL_EVENTS_END = "k8s.io/initial-events-end";
|
|
18
|
+
/** The API refused a call, or could not be reached: the status it answered with, when it answered. */
|
|
19
|
+
export class KubeApiError extends Schema.TaggedError()("KubeApiError", {
|
|
20
|
+
/** The API's HTTP status (404 for absent, 409 for a conflict), when it answered. */
|
|
21
|
+
status: Schema.optional(Schema.Number),
|
|
22
|
+
cause: Schema.Defect(),
|
|
23
|
+
}) {
|
|
24
|
+
/** What a call failed with, read for the status the API answered with (the client's ApiException carries it as `code`). */
|
|
25
|
+
static of(cause) {
|
|
26
|
+
return new KubeApiError({ status: Predicate.hasProperty(cause, "code") && Predicate.isNumber(cause.code) ? cause.code : undefined, cause });
|
|
27
|
+
}
|
|
28
|
+
get message() {
|
|
29
|
+
return this.cause instanceof Error ? this.cause.message : String(this.cause);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** A command `exec` ran in a container came to no exit code: its output overflowed, or the exec itself failed. */
|
|
33
|
+
export class KubeExecError extends Schema.TaggedError()("KubeExecError", {
|
|
34
|
+
message: Schema.String,
|
|
35
|
+
}) {
|
|
36
|
+
}
|
|
37
|
+
/** Whether `error` is the API's answer `status`. */
|
|
38
|
+
export const hasStatus = (status) => (error) => error.status === status;
|
|
39
|
+
/** Whether `value` is a JSON object, which a merge patch merges key by key. */
|
|
40
|
+
const isJsonObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
41
|
+
/**
|
|
42
|
+
* The JSON merge patch (RFC 7386) that makes `from` into `to`: objects patched key by key,
|
|
43
|
+
* with null for each key `to` has no value for, and anything else, arrays included,
|
|
44
|
+
* given whole. A merge patch cannot set a null, so a null in `to` is a key it lacks.
|
|
45
|
+
*/
|
|
46
|
+
export function mergePatch(from, to) {
|
|
47
|
+
if (!isJsonObject(from) || !isJsonObject(to))
|
|
48
|
+
return to;
|
|
49
|
+
const patch = {};
|
|
50
|
+
for (const [key, value] of Object.entries(from)) {
|
|
51
|
+
if (value !== undefined && to[key] === undefined)
|
|
52
|
+
patch[key] = null;
|
|
53
|
+
}
|
|
54
|
+
for (const [key, value] of Object.entries(to)) {
|
|
55
|
+
if (value === undefined || isDeepStrictEqual(from[key], value))
|
|
56
|
+
continue;
|
|
57
|
+
patch[key] = mergePatch(from[key], value);
|
|
58
|
+
}
|
|
59
|
+
return patch;
|
|
60
|
+
}
|
|
61
|
+
const DEFAULT_EXEC_MAX_BYTES = 16 * 1024 * 1024;
|
|
62
|
+
/**
|
|
63
|
+
* How long a watch hears nothing before its connection is taken for lost and the watch
|
|
64
|
+
* fails: one and a half times the minute between the bookmarks the API server sends a watch
|
|
65
|
+
* that asks for them, however quiet what it watches.
|
|
66
|
+
*/
|
|
67
|
+
export const WATCH_SILENCE_MS = 90_000;
|
|
68
|
+
/** The kubeconfig alasio runs with: its ServiceAccount in a pod, the default elsewhere. */
|
|
69
|
+
function loadKubeConfig() {
|
|
70
|
+
const kubeConfig = new KubeConfig();
|
|
71
|
+
kubeConfig.loadFromDefault();
|
|
72
|
+
return kubeConfig;
|
|
73
|
+
}
|
|
74
|
+
const ref = (apiVersion, kind, namespace, name) => ({ apiVersion, kind, metadata: { namespace, name } });
|
|
75
|
+
/**
|
|
76
|
+
* What a merge patch of the object sends: `patch`, addressed to the object, whose name
|
|
77
|
+
* and namespace sit in its metadata beside what `patch` changes there.
|
|
78
|
+
*/
|
|
79
|
+
export function patchBody(apiVersion, kind, namespace, name, patch) {
|
|
80
|
+
const target = ref(apiVersion, kind, namespace, name);
|
|
81
|
+
const metadata = Predicate.hasProperty(patch, "metadata") && isJsonObject(patch.metadata) ? patch.metadata : {};
|
|
82
|
+
return { ...patch, ...target, metadata: { ...metadata, ...target.metadata } };
|
|
83
|
+
}
|
|
84
|
+
/** A call to the API, its rejection a KubeApiError. */
|
|
85
|
+
const call = (request) => Effect.tryPromise({ try: request, catch: KubeApiError.of });
|
|
86
|
+
/**
|
|
87
|
+
* The Kubernetes API, as alasio calls it. Objects are addressed by `apiVersion`, `kind`,
|
|
88
|
+
* namespace and name, so one set of calls serves every kind alike.
|
|
89
|
+
*/
|
|
90
|
+
export class KubeClient extends Context.Service()("alasio/kube/KubeClient") {
|
|
91
|
+
/** The API alasio's kubeconfig (loadKubeConfig) reaches. */
|
|
92
|
+
static layer = Layer.sync(KubeClient, () => makeKubeClient(loadKubeConfig()));
|
|
93
|
+
}
|
|
94
|
+
/** The client over `kubeConfig`, its watches failing after `watchSilenceMs` of silence. */
|
|
95
|
+
export function makeKubeClient(kubeConfig, { watchSilenceMs = WATCH_SILENCE_MS } = {}) {
|
|
96
|
+
const objects = KubernetesObjectApi.makeApiClient(kubeConfig);
|
|
97
|
+
const core = kubeConfig.makeApiClient(CoreV1Api);
|
|
98
|
+
const executor = new Exec(kubeConfig);
|
|
99
|
+
const exec = Effect.fnUntraced(function* (namespace, pod, container, command, { maxBytes = DEFAULT_EXEC_MAX_BYTES } = {}) {
|
|
100
|
+
const stdout = new PassThrough();
|
|
101
|
+
const stderr = new PassThrough();
|
|
102
|
+
const out = [];
|
|
103
|
+
const err = [];
|
|
104
|
+
let size = 0;
|
|
105
|
+
let socket = null;
|
|
106
|
+
let overflowed = false;
|
|
107
|
+
stdout.on("data", (chunk) => {
|
|
108
|
+
size += chunk.length;
|
|
109
|
+
if (size > maxBytes) {
|
|
110
|
+
overflowed = true;
|
|
111
|
+
socket?.close();
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
out.push(chunk);
|
|
115
|
+
});
|
|
116
|
+
stderr.on("data", (chunk) => err.push(chunk));
|
|
117
|
+
// Held in an object: the status callback sets it where control flow cannot see.
|
|
118
|
+
const reported = { status: null };
|
|
119
|
+
// The status arrives on its own channel before the socket closes; the output is
|
|
120
|
+
// whole once the socket has closed and both streams have drained.
|
|
121
|
+
yield* Effect.callback((resume) => {
|
|
122
|
+
executor
|
|
123
|
+
.exec(namespace, pod, container, [...command], stdout, stderr, null, false, (status) => { reported.status = status; })
|
|
124
|
+
.then((opened) => {
|
|
125
|
+
socket = opened;
|
|
126
|
+
opened.on("close", () => resume(Effect.void));
|
|
127
|
+
opened.on("error", (error) => resume(Effect.fail(KubeApiError.of(error))));
|
|
128
|
+
}, (error) => resume(Effect.fail(KubeApiError.of(error))));
|
|
129
|
+
return Effect.sync(() => socket?.close());
|
|
130
|
+
});
|
|
131
|
+
for (const stream of [stdout, stderr]) {
|
|
132
|
+
if (!stream.writableEnded)
|
|
133
|
+
stream.end();
|
|
134
|
+
}
|
|
135
|
+
// Both were ended just above, so both finish.
|
|
136
|
+
yield* Effect.promise(() => Promise.all([finished(stdout), finished(stderr)]));
|
|
137
|
+
if (overflowed) {
|
|
138
|
+
return yield* new KubeExecError({ message: `the output of ${JSON.stringify(command[0])} in ${namespace}/${pod} is over ${maxBytes} bytes` });
|
|
139
|
+
}
|
|
140
|
+
if (!reported.status)
|
|
141
|
+
return yield* new KubeExecError({ message: `exec in ${namespace}/${pod} ended without a status` });
|
|
142
|
+
return {
|
|
143
|
+
exitCode: yield* Effect.fromResult(exitCodeOf(reported.status)),
|
|
144
|
+
stdout: Buffer.concat(out),
|
|
145
|
+
stderr: Buffer.concat(err).toString("utf8"),
|
|
146
|
+
};
|
|
147
|
+
});
|
|
148
|
+
// Asked over node:http, as client-node's ProtoClient asks, not through its Watch: its request timeout, 30 s and not to be
|
|
149
|
+
// set, ends every watch of something quiet between two of the API server's bookmarks, so each would be listed anew twice a minute.
|
|
150
|
+
const watch = (apiVersion, plural, namespace, labelSelector, from) => Stream.callback((queue) => Effect.acquireRelease(Effect.tryPromise({
|
|
151
|
+
try: async () => {
|
|
152
|
+
const url = new URL(`${kubeConfig.getCurrentCluster()?.server ?? ""}/${apiVersion.includes("/") ? "apis" : "api"}/${apiVersion}/namespaces/${namespace}/${plural}`);
|
|
153
|
+
const since = from === undefined ? { sendInitialEvents: "true", resourceVersionMatch: "NotOlderThan" } : { resourceVersion: from };
|
|
154
|
+
for (const [name, value] of Object.entries({ watch: "true", labelSelector, allowWatchBookmarks: "true", ...since })) {
|
|
155
|
+
url.searchParams.set(name, value);
|
|
156
|
+
}
|
|
157
|
+
const options = {};
|
|
158
|
+
await kubeConfig.applyToHTTPSOptions(options);
|
|
159
|
+
const fail = (error) => void Queue.failCauseUnsafe(queue, Cause.fail(KubeApiError.of(error)));
|
|
160
|
+
const asked = request(url, options, (response) => {
|
|
161
|
+
response.on("error", fail);
|
|
162
|
+
if (response.statusCode !== 200) {
|
|
163
|
+
response.resume();
|
|
164
|
+
return fail(Object.assign(new Error(`watching ${url.pathname} was answered ${response.statusCode} ${response.statusMessage}`), { code: response.statusCode }));
|
|
165
|
+
}
|
|
166
|
+
const lines = createInterface({ input: response, crlfDelay: Infinity });
|
|
167
|
+
// What ends the response, the watch ended or its connection lost, ends the lines, which say so as their own error.
|
|
168
|
+
lines.on("error", fail);
|
|
169
|
+
lines.on("line", (line) => {
|
|
170
|
+
try {
|
|
171
|
+
const { type, object } = JSON.parse(line);
|
|
172
|
+
// The API server's own end of a watch it cannot go on with, as a Status: 410 where what it watched from is too old.
|
|
173
|
+
if (type === "ERROR")
|
|
174
|
+
fail(Object.assign(new Error(object.message ?? `watching ${url.pathname} failed`), { code: object.code }));
|
|
175
|
+
else
|
|
176
|
+
Queue.offerUnsafe(queue, { type, object });
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
fail(error);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
response.on("end", () => void Queue.endUnsafe(queue));
|
|
183
|
+
});
|
|
184
|
+
asked.setTimeout(watchSilenceMs, () => asked.destroy(new Error(`the watch of ${url.pathname} heard nothing for ${watchSilenceMs} ms`)));
|
|
185
|
+
asked.on("error", fail);
|
|
186
|
+
asked.end();
|
|
187
|
+
return asked;
|
|
188
|
+
},
|
|
189
|
+
catch: KubeApiError.of,
|
|
190
|
+
}), (asked) => Effect.sync(() => asked.destroy())));
|
|
191
|
+
return KubeClient.of({
|
|
192
|
+
read: (apiVersion, kind, namespace, name) => call(() => objects.read(ref(apiVersion, kind, namespace, name))).pipe(Effect.catchIf(hasStatus(404), () => Effect.succeed(null))),
|
|
193
|
+
list: (apiVersion, kind, namespace, labelSelector) => call(() => objects.list(apiVersion, kind, namespace, undefined, undefined, undefined, undefined, labelSelector)).pipe(Effect.map(({ items }) => items)),
|
|
194
|
+
create: (object) => call(() => objects.create(object)),
|
|
195
|
+
replace: (object) => call(() => objects.replace(object)),
|
|
196
|
+
patch: (apiVersion, kind, namespace, name, patch) => call(() => objects.patch(patchBody(apiVersion, kind, namespace, name, patch), undefined, undefined, "alasio", undefined, PatchStrategy.MergePatch)),
|
|
197
|
+
watch,
|
|
198
|
+
patchPodStatus: (namespace, name, patch) => call(() => core.patchNamespacedPodStatus({ namespace, name, body: patch, fieldManager: "alasio" }, setHeaderOptions("Content-Type", PatchStrategy.StrategicMergePatch))).pipe(Effect.asVoid),
|
|
199
|
+
remove: (apiVersion, kind, namespace, name, resourceVersion) => call(() => objects.delete(ref(apiVersion, kind, namespace, name), undefined, undefined, undefined, undefined, "Background", resourceVersion === undefined ? undefined : { preconditions: { resourceVersion } })).pipe(Effect.asVoid, Effect.catchIf(hasStatus(404), () => Effect.void)),
|
|
200
|
+
exec,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
/** The exit code a `pods/exec` status reports: 0 on success, the process's own otherwise. */
|
|
204
|
+
export function exitCodeOf(status) {
|
|
205
|
+
if (status.status === "Success")
|
|
206
|
+
return Result.succeed(0);
|
|
207
|
+
const cause = status.details?.causes?.find((entry) => entry.reason === "ExitCode");
|
|
208
|
+
if (cause)
|
|
209
|
+
return Result.succeed(Number(cause.message));
|
|
210
|
+
return Result.fail(new KubeExecError({ message: `exec failed: ${status.message ?? status.reason ?? "unknown error"}` }));
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=client.js.map
|
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AAS,EAAE,YAAY,EAAE,eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,EAAE,eAAe,EAAE,EAAE,CAAC,CACrM,CAAC,IAAI,CACJ,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAClD;QACH,IAAI;KACL,CAAC,CAAC;AACL,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,UAAU,CAAC,MAAgB;IACzC,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1D,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC;IACnF,IAAI,KAAK;QAAE,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IACxD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,aAAa,CAAC,EAAE,OAAO,EAAE,gBAAgB,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,MAAM,IAAI,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3H,CAAC"}
|
|
@@ -1,42 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* What alasio
|
|
3
|
-
* (../
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* that holds alasio to its templates (cli/src/manifests/admission.ts) knows it as they do.
|
|
2
|
+
* What alasio's pods of bayma carry, beyond their templates, that more than one of its
|
|
3
|
+
* parts knows: the gateway that binds them (../gateway/), the node agents that snapshot and
|
|
4
|
+
* restore them (../node-agent/), and the admission policies that hold them to what alasio
|
|
5
|
+
* up renders (cli/src/manifests/admission.ts). In one place, with no dependency, so the
|
|
6
|
+
* command line takes it as it is.
|
|
8
7
|
*/
|
|
9
|
-
/** The container
|
|
8
|
+
/** The container of a session's or a folder instance's pod that runs bayma. */
|
|
10
9
|
export const BAYMA_CONTAINER = "bayma";
|
|
11
|
-
/** Where a Sandbox's token Secret is mounted in its bayma container, its key, and its volume. */
|
|
12
|
-
export const TOKEN_DIR = "/run/alasio/bayma";
|
|
13
|
-
export const TOKEN_KEY = "token";
|
|
14
|
-
export const TOKEN_VOLUME = "alasio-bayma-token";
|
|
15
|
-
/** The token volume's files' mode: readable by the pod's group, which is how a non-root bayma reads it. */
|
|
16
|
-
export const TOKEN_MODE = 0o440;
|
|
17
|
-
/** The file bayma reads its token from, which a restored Sandbox's new token replaces. */
|
|
18
|
-
export const TOKEN_FILE = `${TOKEN_DIR}/${TOKEN_KEY}`;
|
|
19
|
-
/** The arguments bayma is given after its template's: where its token is. */
|
|
20
|
-
export const TOKEN_FILE_ARGS = ["--token-file", TOKEN_FILE];
|
|
21
|
-
/** The arguments a session's bayma is given after those when it exports telemetry: the token it exports with, read from the same file for each export. */
|
|
22
|
-
export const TELEMETRY_TOKEN_FILE_ARGS = ["--telemetry-token-file", TOKEN_FILE];
|
|
23
|
-
/** The name of a Sandbox's token Secret. */
|
|
24
|
-
export function tokenSecretName(name) {
|
|
25
|
-
return `${name}-bayma-token`;
|
|
26
|
-
}
|
|
27
|
-
/** The label every object alasio makes carries, and the one that names its Sandbox. */
|
|
28
|
-
export const MANAGED_BY = { "app.kubernetes.io/managed-by": "alasio" };
|
|
29
|
-
export const SANDBOX_LABEL = "alasio.dev/sandbox";
|
|
30
|
-
/** What a Sandbox's pod is to alasio: a session's, or a folder's bayma's. */
|
|
31
|
-
export const WORKLOAD_LABEL = "alasio.dev/workload";
|
|
32
10
|
/** A session's internet, `none` or `full`, which its NetworkPolicies follow. */
|
|
33
11
|
export const NET_MODE_LABEL = "alasio.dev/net-mode";
|
|
34
|
-
/** The harness a folder's bayma serves, as a path segment. */
|
|
35
|
-
export const HARNESS_LABEL = "alasio.dev/harness";
|
|
36
|
-
/** The resolvers a session with internet uses unless its template names others. */
|
|
37
|
-
export const DEFAULT_FULL_MODE_NAMESERVERS = ["1.1.1.1", "8.8.8.8"];
|
|
38
|
-
/** The argument a folder's bayma is given its state directory by, under its template's state root. */
|
|
39
|
-
export const STATE_DIR_ARG = "--state-dir";
|
|
40
12
|
/**
|
|
41
13
|
* The argument a session's bayma is given how long it holds a stop by, for alasio to
|
|
42
14
|
* snapshot it first (bayma's mcp-http help): a bayma run without it holds none.
|
|
@@ -44,13 +16,19 @@ export const STATE_DIR_ARG = "--state-dir";
|
|
|
44
16
|
export const STOP_WAIT_ARG = "--stop-wait-ms";
|
|
45
17
|
/** How long a session's bayma takes to stop once it holds its stop no more: it persists its sessions. */
|
|
46
18
|
export const BAYMA_STOP_SECONDS = 30;
|
|
19
|
+
/**
|
|
20
|
+
* The variable bayma's hook, run as its sandbox is restored, takes why its host stopped the
|
|
21
|
+
* sandbox from, as the end of a sentence, to tell each live session's next exec (bayma's
|
|
22
|
+
* sandbox-hook help).
|
|
23
|
+
*/
|
|
24
|
+
export const SANDBOX_STOP_REASON_VARIABLE = "BAYMA_SANDBOX_STOP_REASON";
|
|
47
25
|
/** A path segment from `value`: never empty, nor starting with a dot. */
|
|
48
26
|
export function sanitizePathToken(value) {
|
|
49
27
|
return String(value).replace(/[^A-Za-z0-9_.-]+/g, "-").replace(/^[-.]+|-+$/g, "") || "default";
|
|
50
28
|
}
|
|
51
29
|
/**
|
|
52
30
|
* What a session's pod template carries of its whole-sandbox snapshots
|
|
53
|
-
* (../
|
|
31
|
+
* (../gateway/snapshots.ts): the hash of the template it was made from, which its
|
|
54
32
|
* snapshots record; the CPU features its sandbox is held to; and, of a pod restored from
|
|
55
33
|
* a snapshot, the image it is restored from, on its node under the snapshot cache, left
|
|
56
34
|
* paused until its node's agent resumes it, which its readiness gate waits for.
|
|
@@ -64,18 +42,6 @@ export const RESTORE_ANNOTATION = "dev.gvisor.internal.restore.host-image-path";
|
|
|
64
42
|
export const RESTORE_PAUSED_ANNOTATION = "dev.gvisor.internal.restore.paused";
|
|
65
43
|
/** The condition of a restored pod's readiness gate, which alasio sets once its sandbox is resumed. */
|
|
66
44
|
export const RESUMED_CONDITION = "alasio.dev/resumed";
|
|
67
|
-
/**
|
|
68
|
-
* The annotation of a suspended Sandbox naming the snapshot its pod was saved into, which
|
|
69
|
-
* alone it may be restored from: set as it is suspended, removed as it is next resumed,
|
|
70
|
-
* from that snapshot or not, so a snapshot outlives no resume of its Sandbox's.
|
|
71
|
-
*/
|
|
72
|
-
export const SNAPSHOT_ANNOTATION = "alasio.dev/snapshot";
|
|
73
|
-
/**
|
|
74
|
-
* The annotation naming the gVisor release that took the snapshot SNAPSHOT_ANNOTATION
|
|
75
|
-
* names, beside it, the only one that restores it: `alasio up` keeps every release one
|
|
76
|
-
* names (cli/src/kept-releases.ts).
|
|
77
|
-
*/
|
|
78
|
-
export const SNAPSHOT_RELEASE_ANNOTATION = "alasio.dev/snapshot-release";
|
|
79
45
|
/** Where a node agent keeps the snapshots it prepares, as `<environment>/<workspace>/<snapshot>` (../node-agent/cache.ts). */
|
|
80
46
|
export const SNAPSHOT_CACHE_DIR = "/var/lib/alasio/snapshots";
|
|
81
47
|
/**
|
|
@@ -83,26 +49,6 @@ export const SNAPSHOT_CACHE_DIR = "/var/lib/alasio/snapshots";
|
|
|
83
49
|
* workspace's ids sort as its snapshots were taken, then 32 random bits.
|
|
84
50
|
*/
|
|
85
51
|
export const SNAPSHOT_ID = "[0-9]{8}T[0-9]{9}Z-[0-9a-f]{8}";
|
|
86
|
-
/** A DNS label: an environment's name (its sessions' namespace) and a workspace's
|
|
52
|
+
/** A DNS label: an environment's name (its sessions' namespace) and a workspace's, as the snapshot cache's directories are named. */
|
|
87
53
|
export const NAME = /^[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])?$/u;
|
|
88
|
-
/** The init container that holds a session's pod until its egress is confined: its name, and its resources. */
|
|
89
|
-
export const EGRESS_GATE = { name: "egress-gate", resources: { requests: { cpu: "10m", memory: "32Mi" }, limits: { memory: "64Mi" } } };
|
|
90
|
-
/**
|
|
91
|
-
* The egress gate's program: exits once three connections in a row to the API server
|
|
92
|
-
* fail, and fails the pod if they still succeed after two minutes. Runs on the agent
|
|
93
|
-
* image's Node.
|
|
94
|
-
*/
|
|
95
|
-
export const EGRESS_GATE_SCRIPT = [
|
|
96
|
-
"const net = require('node:net');",
|
|
97
|
-
"const host = process.env.KUBERNETES_SERVICE_HOST, port = Number(process.env.KUBERNETES_SERVICE_PORT);",
|
|
98
|
-
"const deadline = Date.now() + 120000; let refused = 0;",
|
|
99
|
-
"(function probe() {",
|
|
100
|
-
" const socket = net.connect({ host, port, timeout: 1000 });",
|
|
101
|
-
" const next = (blocked) => { socket.destroy(); refused = blocked ? refused + 1 : 0;",
|
|
102
|
-
" if (refused >= 3) process.exit(0);",
|
|
103
|
-
" if (Date.now() > deadline) { console.error('egress is not confined: is NetworkPolicy enforced in this cluster?'); process.exit(1); }",
|
|
104
|
-
" setTimeout(probe, 250); };",
|
|
105
|
-
" socket.once('connect', () => next(false)); socket.once('timeout', () => next(true)); socket.once('error', () => next(true));",
|
|
106
|
-
"})();",
|
|
107
|
-
].join("\n");
|
|
108
54
|
//# sourceMappingURL=sandbox-shape.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-shape.js","sourceRoot":"","sources":["../../../../src/kube/sandbox-shape.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"sandbox-shape.js","sourceRoot":"","sources":["../../../../src/kube/sandbox-shape.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,+EAA+E;AAC/E,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC;AAEvC,gFAAgF;AAChF,MAAM,CAAC,MAAM,cAAc,GAAG,qBAAqB,CAAC;AAEpD;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,gBAAgB,CAAC;AAE9C,yGAAyG;AACzG,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAErC;;;;GAIG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,2BAA2B,CAAC;AAExE,yEAAyE;AACzE,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC;AACjG,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,6BAA6B,CAAC;AACzE,oGAAoG;AACpG,MAAM,CAAC,MAAM,uBAAuB,GAAG,iCAAiC,CAAC;AACzE,0GAA0G;AAC1G,MAAM,CAAC,MAAM,kBAAkB,GAAG,6CAA6C,CAAC;AAChF,yGAAyG;AACzG,MAAM,CAAC,MAAM,yBAAyB,GAAG,oCAAoC,CAAC;AAC9E,uGAAuG;AACvG,MAAM,CAAC,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;AACtD,8HAA8H;AAC9H,MAAM,CAAC,MAAM,kBAAkB,GAAG,2BAA2B,CAAC;AAC9D;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,gCAAgC,CAAC;AAC5D,qIAAqI;AACrI,MAAM,CAAC,MAAM,IAAI,GAAG,uCAAuC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where alasio keeps the time of its last start (./started.ts), which `alasio status` reads
|
|
3
|
+
* while alasio runs no replica (cli/src/commands/status.ts), and whose ConfigMap alasio's
|
|
4
|
+
* manifests make, empty, alasio's Role letting it read and patch that one alone
|
|
5
|
+
* (cli/src/manifests/alasio.ts). In a module of its own, with no dependency, so the command
|
|
6
|
+
* line takes it as it is.
|
|
7
|
+
*/
|
|
8
|
+
/** The ConfigMap alasio keeps the time of its last start in, of its namespace. */
|
|
9
|
+
export const STARTED_CONFIG_MAP = "alasio-started";
|
|
10
|
+
/** Its key holding the time, as an ISO 8601 timestamp. */
|
|
11
|
+
export const STARTED_KEY = "startedAt";
|
|
12
|
+
//# sourceMappingURL=started-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"started-map.js","sourceRoot":"","sources":["../../../../src/kube/started-map.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,kFAAkF;AAClF,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AAEnD,0DAA0D;AAC1D,MAAM,CAAC,MAAM,WAAW,GAAG,WAAW,CAAC"}
|
|
@@ -14,6 +14,27 @@ export const NODE_AGENT_PORT = 8484;
|
|
|
14
14
|
* alone reaches it, as a node reaches the pods it runs.
|
|
15
15
|
*/
|
|
16
16
|
export const STORE_PROXY_PORT = 8485;
|
|
17
|
+
/**
|
|
18
|
+
* Where a node agent keeps, on its node's /run, a tmpfs, what outlives it until the node
|
|
19
|
+
* restarts: the Unix domain socket it serves the snapshots bucket on to its node's restores
|
|
20
|
+
* too, which a restore's checkpoint gofer dials by its path, whatever pod the agent runs in
|
|
21
|
+
* (STORE_SOCKET), and those restores' tokens, read back as it starts again
|
|
22
|
+
* (STORE_TOKENS_FILE), each only root's. Of the pods alasio makes, the agent alone mounts the
|
|
23
|
+
* node's /run (cli/src/manifests/node-agent.ts), and the sessions' pods are held to their
|
|
24
|
+
* templates, which mount none of it (cli/src/manifests/admission.ts sandboxPodPolicy). The
|
|
25
|
+
* host profile's mounts, which the operator gives alasio and the folder's bayma, could reach
|
|
26
|
+
* it, but both run as the operator's user (1000 unless the profile says), whom the socket's
|
|
27
|
+
* and the file's mode, 0600 and root's, keep out.
|
|
28
|
+
*/
|
|
29
|
+
export const NODE_AGENT_RUN_DIR = "/run/alasio/node-agent";
|
|
30
|
+
/** The variable that moves NODE_AGENT_RUN_DIR, as a test of the agent's own process does. */
|
|
31
|
+
export const NODE_AGENT_RUN_DIR_VARIABLE = "ALASIO_NODE_AGENT_RUN_DIR";
|
|
32
|
+
/** The socket a node agent serves the snapshots bucket on, on its node, in `runDir` (NODE_AGENT_RUN_DIR). */
|
|
33
|
+
export const storeSocket = (runDir) => `${runDir}/store.sock`;
|
|
34
|
+
/** The file a node agent keeps its restores' tokens in, on its node, in `runDir` (NODE_AGENT_RUN_DIR). */
|
|
35
|
+
export const storeTokensFile = (runDir) => `${runDir}/tokens.json`;
|
|
36
|
+
/** The URL a restore's gofer names the store by through STORE_SOCKET, which it signs: no host's, as the socket alone is dialled. */
|
|
37
|
+
export const STORE_SOCKET_ENDPOINT = "http://alasio-node-agent";
|
|
17
38
|
/** The variable that gives a node agent its pod's address, which it serves the bucket to its node on. */
|
|
18
39
|
export const POD_IP_VARIABLE = "POD_IP";
|
|
19
40
|
/**
|
|
@@ -36,6 +57,13 @@ export const gvisorDirectory = (release) => `${GVISOR_RELEASES}/${release}`;
|
|
|
36
57
|
* where `since` names none.
|
|
37
58
|
*/
|
|
38
59
|
export function restoresFromBucket(release, since) {
|
|
60
|
+
return releaseAtOrPast(release, since);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Whether gVisor's `release` is the fork's `since` or one past it, by its base's date and
|
|
64
|
+
* patch, then its own number; never where either names no release of the fork's.
|
|
65
|
+
*/
|
|
66
|
+
function releaseAtOrPast(release, since) {
|
|
39
67
|
const parts = (named) => {
|
|
40
68
|
const matched = /^(\d{8})\.(\d+)-eaucoin\.(\d+)$/u.exec(named);
|
|
41
69
|
return matched ? matched.slice(1).map(Number) : null;
|
|
@@ -46,6 +74,19 @@ export function restoresFromBucket(release, since) {
|
|
|
46
74
|
const differs = of.findIndex((part, index) => part !== first[index]);
|
|
47
75
|
return differs === -1 || (of[differs] ?? 0) > (first[differs] ?? 0);
|
|
48
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* The gofer a restore of a snapshot taken under gVisor's `release` asks for: through a socket,
|
|
79
|
+
* reading again pages a read of failed, of one at or past `since`, the first release that
|
|
80
|
+
* restores so, as cluster/node/pins.json says it (gvisor.restoresThroughSocketSince); none,
|
|
81
|
+
* the agent's own way, over TCP, of one before it, and of every release where `since` names none.
|
|
82
|
+
*/
|
|
83
|
+
export const goferOf = (release, since) => (releaseAtOrPast(release, since) ? { transport: "socket", pagesRetry: true } : null);
|
|
84
|
+
/**
|
|
85
|
+
* The name of a restore's pod, as the gateway makes it (../gateway/names.ts restorePodName): its
|
|
86
|
+
* pool's, `-restore-`, then seven of base 36's digits; the one name whose directory the node
|
|
87
|
+
* agent makes for it, before the pod is made.
|
|
88
|
+
*/
|
|
89
|
+
export const RESTORE_POD = /^[a-z0-9]([-a-z0-9]*[a-z0-9])?-restore-[0-9a-z]{7}$/u;
|
|
49
90
|
/** The variable that gives the node agent the first gVisor release that restores straight from the bucket (restoresFromBucket). */
|
|
50
91
|
export const RESTORES_FROM_BUCKET_SINCE_VARIABLE = "ALASIO_GVISOR_RESTORES_FROM_BUCKET_SINCE";
|
|
51
92
|
/** Where k3s's containerd reads its template, and runsc its options. */
|
|
@@ -61,6 +102,21 @@ export const gvisorHandler = (release) => `runsc-${gvisorLabel(release)}`;
|
|
|
61
102
|
export const gvisorRuntimeClass = (release) => `gvisor-${gvisorLabel(release)}`;
|
|
62
103
|
/** The version runsc of gVisor's `release` reports, and saves its images with: its release's tag. */
|
|
63
104
|
export const runscVersion = (release) => `release-${release}`;
|
|
105
|
+
/**
|
|
106
|
+
* The directory alasio's pods keep on a node, which nothing of k3s's removes: the workspaces'
|
|
107
|
+
* JuiceFS mount and its state and cache, its juicefs, and the pool pods' directories, which
|
|
108
|
+
* workspaces are attached into, mounts all (cli/src/manifests/sandbox-gateway.ts).
|
|
109
|
+
*/
|
|
110
|
+
export const NODE_DIRECTORY = "/var/lib/alasio";
|
|
111
|
+
/**
|
|
112
|
+
* Where a node has workspace storage mounted, held by a pod of its own, each workspace's
|
|
113
|
+
* files at `<environment>/<workspace>/files`.
|
|
114
|
+
*/
|
|
115
|
+
export const WORKSPACES_ROOT = `${NODE_DIRECTORY}/workspaces`;
|
|
116
|
+
/** Where a node keeps the directory of each pod of a sandbox pool, or of a harness pool, `<namespace>/<pod>`, which the pod mounts by `subPathExpr` of its namespace and its name. */
|
|
117
|
+
export const ATTACH_ROOT = `${NODE_DIRECTORY}/attach`;
|
|
118
|
+
/** The file of a harness pool's pod's binding in its directory, which its node's agent writes as the gateway binds it, and the pod serves once it is there (src/harness/program.ts). */
|
|
119
|
+
export const BINDING_FILE = "binding.json";
|
|
64
120
|
/** The root the gVisor shims run runsc with for Kubernetes' containers, under the node's /run. */
|
|
65
121
|
export const RUNSC_ROOT = "/run/containerd/runsc/k8s.io";
|
|
66
122
|
/** The node's snapshot cache, where its sandboxes are restored from, as the admission policy holds a restore to. */
|
|
@@ -93,8 +149,10 @@ export const UNSYNCED_DOWNLOAD_BYTES = SNAPSHOT_PARTS_AT_ONCE * SNAPSHOT_SYNC_BY
|
|
|
93
149
|
export const NODE_AGENT_OWN_BYTES = 160 * 1024 ** 2;
|
|
94
150
|
/** The least memory limit a node agent runs under: its own, and a download's budget beside it. */
|
|
95
151
|
export const NODE_AGENT_MEMORY_FLOOR = NODE_AGENT_OWN_BYTES + UNSYNCED_DOWNLOAD_BYTES;
|
|
96
|
-
/** The variable holding the token
|
|
152
|
+
/** The variable holding the token the sandbox gateway presents to a node agent. */
|
|
97
153
|
export const NODE_AGENT_TOKEN_VARIABLE = "ALASIO_NODE_AGENT_TOKEN";
|
|
154
|
+
/** The variable holding workspace storage's metadata engine's address, its password in it, which the agent sets workspaces' quotas on alone. */
|
|
155
|
+
export const META_URL_VARIABLE = "META_URL";
|
|
98
156
|
/** The variable holding the most bytes the node's snapshot cache keeps. */
|
|
99
157
|
export const SNAPSHOT_CACHE_BYTES_VARIABLE = "ALASIO_SNAPSHOT_CACHE_BYTES";
|
|
100
158
|
/**
|
|
@@ -106,7 +164,7 @@ export const OPERATION_LIMIT_SECONDS = 15 * 60;
|
|
|
106
164
|
/**
|
|
107
165
|
* How long a restore from the bucket may take from its prepare to its resume, which its token
|
|
108
166
|
* lasts unless resumed before (./store-proxy.ts): the longest it takes, alasio waiting 3
|
|
109
|
-
* minutes for its pod to run (
|
|
167
|
+
* minutes for its pod to run (POD_RUNNING_TIMEOUT_MS in src/gateway/snapshots.ts), then for the
|
|
110
168
|
* agent's resume, and a margin.
|
|
111
169
|
*/
|
|
112
170
|
export const RESTORE_PREPARED_FOR_SECONDS = 5 * 60;
|
|
@@ -114,9 +172,8 @@ export const RESTORE_PREPARED_FOR_SECONDS = 5 * 60;
|
|
|
114
172
|
export const BACKGROUND_READ_SECONDS_VARIABLE = "ALASIO_BACKGROUND_READ_SECONDS";
|
|
115
173
|
/**
|
|
116
174
|
* The slowest a resumed restore is taken to read the rest of its sandbox through the node
|
|
117
|
-
* agent, in the background: half of what
|
|
118
|
-
* 8.7 MB/s through the agent's proxy from the restore's start to its last read
|
|
119
|
-
* (program/progress/live-lazy.md).
|
|
175
|
+
* agent, in the background: half of what was measured on a runner's bundled SeaweedFS,
|
|
176
|
+
* 8.7 MB/s through the agent's proxy from the restore's start to its last read.
|
|
120
177
|
*/
|
|
121
178
|
export const BACKGROUND_READ_BYTES_PER_SECOND = 4 * 1024 ** 2;
|
|
122
179
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"names.js","sourceRoot":"","sources":["../../../../src/node-agent/names.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,qEAAqE;AACrE,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC;AAEpC;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAErC,yGAAyG;AACzG,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAC;AAExC;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,8BAA8B,CAAC;AAE9D,qDAAqD;AACr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B,CAAC;AAE3E;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,GAAG,EAAE,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,GAAG,EAAE,CAAC;AAEnD,+IAA+I;AAC/I,MAAM,CAAC,MAAM,gCAAgC,GAAG,gCAAgC,CAAC;AAEjF;;;;GAIG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;AAE9D;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,WAAmB;IACvD,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,gCAAgC,CAAC,CAAC,CAAC;AACjF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,WAAmB;IACtD,OAAO,4BAA4B,GAAG,qBAAqB,CAAC,WAAW,CAAC,GAAG,uBAAuB,CAAC;AACrG,CAAC"}
|
|
@@ -1,33 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Naming for session filesystems. A workspace is one of two kinds (see
|
|
3
3
|
* ../workspace/kind.ts): a folder, or a session filesystem identified by a volume id.
|
|
4
|
-
* A volume id is what alasio generates and stores, and its session's
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
import { Schema } from "effect";
|
|
8
|
-
/**
|
|
9
|
-
* The longest a volume id is: a DNS label's 63 characters, less a claim template's name
|
|
10
|
-
* of up to CLAIM_TEMPLATE_MAX and the hyphen after it, so its volume claims' names,
|
|
11
|
-
* `<template>-<id>` (../kube/sandboxes.ts claimName), are DNS labels too, as alasio's
|
|
12
|
-
* admission policy of its clones holds them to (cli/src/manifests/admission.ts).
|
|
4
|
+
* A volume id is what alasio generates and stores, and its session's workspace, which the
|
|
5
|
+
* sandbox gateway holds, is named for it (sessionKey).
|
|
13
6
|
*/
|
|
7
|
+
/** The longest a volume id is: a DNS label's 63 characters, with room to spare, as the ids alasio has stored are. */
|
|
14
8
|
export const VOLUME_ID_MAX = 58;
|
|
15
|
-
/** The longest a claim template's name is, of which a volume id's claims are named. */
|
|
16
|
-
export const CLAIM_TEMPLATE_MAX = 63 - 1 - VOLUME_ID_MAX;
|
|
17
9
|
/**
|
|
18
10
|
* A volume id is a DNS label of 3–58 characters from `[a-z0-9-]` that starts and ends
|
|
19
|
-
* with a letter or digit, as the names of
|
|
20
|
-
*
|
|
11
|
+
* with a letter or digit, as the names of what is made of it must be, a workspace's
|
|
12
|
+
* directory among them, of VOLUME_ID_MAX at most. alasio generates ids that already
|
|
21
13
|
* satisfy this, and this guards against any that would not.
|
|
22
14
|
*/
|
|
23
15
|
const VOLUME_ID_PATTERN = new RegExp(`^[a-z0-9][a-z0-9-]{1,${VOLUME_ID_MAX - 2}}[a-z0-9]$`, "u");
|
|
24
|
-
/** A volume id, as what comes from outside alasio is decoded. */
|
|
25
|
-
const VolumeId = Schema.String.check(Schema.isPattern(VOLUME_ID_PATTERN));
|
|
26
|
-
/**
|
|
27
|
-
* A session's token, `<volumeId>.<random>` (../kube/sandboxes.ts newToken), decoded into
|
|
28
|
-
* the session it names and the rest.
|
|
29
|
-
*/
|
|
30
|
-
export const SessionToken = Schema.TemplateLiteralParser([VolumeId, ".", Schema.NonEmptyString]);
|
|
31
16
|
export function isValidVolumeId(volumeId) {
|
|
32
17
|
return typeof volumeId === "string" && VOLUME_ID_PATTERN.test(volumeId);
|
|
33
18
|
}
|
|
@@ -41,4 +26,11 @@ export function assertValidVolumeId(volumeId) {
|
|
|
41
26
|
export function newVolumeId(random = () => crypto.randomUUID()) {
|
|
42
27
|
return `fs-${random().replace(/-/g, "").slice(0, 12)}`;
|
|
43
28
|
}
|
|
29
|
+
/** The key a session filesystem's workspace is bound by in the sandbox service: `sessionfs:<volumeId>`. */
|
|
30
|
+
export const sessionKey = (volumeId) => `sessionfs:${volumeId}`;
|
|
31
|
+
/** The volume id of the session filesystem `key` binds, where it binds one; else null. */
|
|
32
|
+
export function volumeIdOfKey(key) {
|
|
33
|
+
const volumeId = key.startsWith("sessionfs:") ? key.slice("sessionfs:".length) : "";
|
|
34
|
+
return isValidVolumeId(volumeId) ? volumeId : null;
|
|
35
|
+
}
|
|
44
36
|
//# sourceMappingURL=names.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"names.js","sourceRoot":"","sources":["../../../../src/sandbox/names.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"names.js","sourceRoot":"","sources":["../../../../src/sandbox/names.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,qHAAqH;AACrH,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,iBAAiB,GAAG,IAAI,MAAM,CAAC,wBAAwB,aAAa,GAAG,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;AAEjG,MAAM,UAAU,eAAe,CAAC,QAAiB;IAC/C,OAAO,OAAO,QAAQ,KAAK,QAAQ,IAAI,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC1E,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,QAAiB;IACnD,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,8BAA8B,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,YAAY,aAAa,kEAAkE,CAAC,CAAC;IACrK,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,WAAW,CAAC,MAAM,GAAiB,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE;IAC1E,OAAO,MAAM,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;AACzD,CAAC;AAED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