@mark1russell7/kind 0.11.0 → 0.11.2

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.
@@ -121,6 +121,7 @@ type Stack = "service" | "grpc";
121
121
  * - `rst` and `blackhole` are the rules of the injector of the harness in the namespace of Redis. In
122
122
  * T15 they are in the namespace of each replica. A black hole of T15 can stop the calls of the
123
123
  * clients before the fault (`quiet`). It can also set `tcp_retries2` of each client pod (`retries`).
124
+ * A black hole with `partition` is in the namespace of the target replica only, with the client pods as peers.
124
125
  * - `peer-gone-without-close` drops the segments of Redis, and then Redis goes away.
125
126
  * - `app-stall` blocks the event loop of one replica.
126
127
  * - `rollout` is a rolling update while Redis is down.
@@ -182,6 +183,13 @@ interface Trigger<A = Quantity> {
182
183
  * last use is at the fault. The heal opens a new channel again.
183
184
  */
184
185
  readonly close?: boolean | undefined;
186
+ /**
187
+ * This flag puts a black hole between the clients and the target replica (T07 `blackhole` of S2).
188
+ * The rules go in the namespace of the target only, with each client pod as a peer. The kubelet
189
+ * still reaches the replica from its node, thus its readiness and its endpoint stay. The prepare
190
+ * gives each client new connections first, as `cannot-serve` does.
191
+ */
192
+ readonly partition?: boolean | undefined;
185
193
  }
186
194
  /** A kubelet probe is the period, the failure threshold and the timeout of one probe of the pod. */
187
195
  interface KubeletProbe {
@@ -231,16 +239,26 @@ interface Declaration {
231
239
  readonly threshold: Quantity;
232
240
  } | null;
233
241
  /**
234
- * This flag is the lame-duck state of the HTTP edge. With true or no value, the edge sends
235
- * `Connection: close` while the service is not ready, thus each caller opens a new connection.
236
- * With false, the edge keeps each connection open, thus a caller learns only from the endpoints.
242
+ * This flag is the lame-duck state of the HTTP edge. With true or no value, the edge closes each
243
+ * connection in band while the service is not ready, thus each caller opens a new connection. On
244
+ * HTTP/1.1 the signal is `Connection: close`, and on HTTP/2 it is GOAWAY. With false, the edge keeps
245
+ * each connection open, thus a caller learns only from the endpoints.
237
246
  */
238
247
  readonly lameDuck?: boolean | undefined;
248
+ /**
249
+ * This text is the protocol of the HTTP edge and of its clients. `h2c` is HTTP/2 without TLS: the
250
+ * app listens with `node:http2`, and each client sends its requests as streams on its sessions.
251
+ * With `http/1.1` or no value, the edge is `node:http`.
252
+ */
253
+ readonly protocol?: EdgeProtocol | undefined;
239
254
  }
255
+ /** An edge protocol is the protocol of the HTTP edge of the service: HTTP/1.1, or HTTP/2 without TLS (`h2c`). */
256
+ type EdgeProtocol = "http/1.1" | "h2c";
240
257
  /**
241
258
  * A workload is the clients: one pod on each node, each with requests to the ClusterIP. The HTTP client
242
- * opens a new connection for each request, or it keeps `connections` open. The gRPC client sends each
243
- * call on its one channel.
259
+ * opens a new connection for each request, or it keeps `connections` open. On HTTP/2 (`protocol` of
260
+ * the declaration), each connection is a session, and each request is a stream on it. The gRPC client
261
+ * sends each call on its one channel.
244
262
  */
245
263
  interface Workload {
246
264
  /** This time is the interval between two requests of one client. The clients do not wait for an answer. */
@@ -252,7 +270,8 @@ interface Workload {
252
270
  readonly timeout: Quantity;
253
271
  /**
254
272
  * This count is the keep-alive connections of each HTTP client. Each request goes on the next
255
- * connection in turn. With no value, the client opens a new connection for each request.
273
+ * connection in turn. With no value, the client opens a new connection for each request. A client
274
+ * of HTTP/2 keeps this count of sessions, and it needs the count.
256
275
  */
257
276
  readonly connections?: number | undefined;
258
277
  }
@@ -1030,5 +1049,5 @@ declare const quantileOf: (sorted: readonly number[], p: number) => number;
1030
1049
  */
1031
1050
  declare const medianInterval: (sorted: readonly number[]) => [number, number];
1032
1051
  //#endregion
1033
- export { updatesOf as $, Declaration as $t, TriggerV1 as A, scenario as An, rulesOf as At, RunCheck as B, ztunnelPodsOf as Bt, KindCellResult as C, NodeImage as Cn, outcomesOf as Ct, PredictionV1 as D, kindConfig as Dn, requestsOf as Dt, LoadSample as E, goDuration as En, recordsOf as Et, KIND_NOISE as F, slicesOf as Ft, judgeKind as G, PORT as Gt, checkRun as H, CLIENT as Ht, KindDecision as I, socketsOf as It, propagationOf as J, bandOf as Jt, observationAfter as K, REDIS as Kt, KindVerdict as L, stoppingOf as Lt, upgrade as M, signalsOf as Mt, upgradeCell as N, sliceDropOf as Nt, RunCheckV1 as O, kubeProxyPatch as On, restartOf as Ot, Deleted as P, sliceEmptyOf as Pt, unitOf as Q, Band as Qt, LAST_SLACK as R, transitionOf as Rt, KindCellRecordV1 as S, NODE_IMAGES as Sn, kernelCounts as St, KindVerdictV1 as T, cidrRange as Tn, podsOf as Tt, deletionsOf as U, HEALTH_PORT as Ut, RunFacts as V, ztunnelReplaced as Vt, factsOf as W, LOG_LABEL as Wt, referenceOf as X, secondsOf as Xt, propagationSource as Y, seconds as Yt, reusesReset as Z, showBand as Zt, ClusterManifest as _, Workload as _n, dropOf as _t, STAGES as a, MeshMode as an, RecordLine as at, FORMAT_V1 as b, KindScenario as bn, intakeOf as bt, readRecord as c, RedisDeclaration as cn, SliceLine as ct, calibrationOf as d, ResetReuse as dn, TunnelLine as dt, KindCell as en, Endpoint as et, cellsTable as f, Stack as fn, ZtunnelPodLine as ft, BandV1 as g, WindowPrediction as gn, deletionOf as gt, timeSpread as h, TriggerKind as hn, byNode as ht, quantileOf as i, MeshFlavor as in, PropagationSource as it, judge as j, scenarioProblems as jn, signalOf as jt, RunFactsV1 as k, nodeNames as kn, restartsAt as kt, Judged as l, Reference as ln, SocketLine as lt, predictionText as m, Trigger as mn, byClients as mt, medianInterval as n, KubeletProbe as nn, Line as nt, kindCellRecordSchema as o, PodSettings as on, Request as ot, medianText as p, Template as pn, backendsAt as pt, observationEnd as q, SERVER as qt, middle as r, Mesh as rn, PodLine as rt, kindCellRecordV1Schema as s, Prediction as sn, RulesLine as st, RELATIVE as t, KindRun as tn, HBONE_PORT as tt, TimeSpread as u, Replica as un, TCP_STATE as ut, EnvironmentManifest as v, KUBE_PROXY_MODES as vn, emptyOf as vt, KindCellV1 as w, cidrOverlap as wn, podsAt as wt, KindCellRecord as x, KubeProxyMode as xn, isTunnelState as xt, FORMAT as y, KindConfig as yn, failuresOf as yt, Propagated as z, tunnelsOf as zt };
1034
- //# sourceMappingURL=judge-4bzoeGIb.d.ts.map
1052
+ export { updatesOf as $, Declaration as $t, TriggerV1 as A, nodeNames as An, rulesOf as At, RunCheck as B, ztunnelPodsOf as Bt, KindCellResult as C, NODE_IMAGES as Cn, outcomesOf as Ct, PredictionV1 as D, goDuration as Dn, requestsOf as Dt, LoadSample as E, cidrRange as En, recordsOf as Et, KIND_NOISE as F, slicesOf as Ft, judgeKind as G, PORT as Gt, checkRun as H, CLIENT as Ht, KindDecision as I, socketsOf as It, propagationOf as J, bandOf as Jt, observationAfter as K, REDIS as Kt, KindVerdict as L, stoppingOf as Lt, upgrade as M, scenarioProblems as Mn, signalsOf as Mt, upgradeCell as N, sliceDropOf as Nt, RunCheckV1 as O, kindConfig as On, restartOf as Ot, Deleted as P, sliceEmptyOf as Pt, unitOf as Q, Band as Qt, LAST_SLACK as R, transitionOf as Rt, KindCellRecordV1 as S, KubeProxyMode as Sn, kernelCounts as St, KindVerdictV1 as T, cidrOverlap as Tn, podsOf as Tt, deletionsOf as U, HEALTH_PORT as Ut, RunFacts as V, ztunnelReplaced as Vt, factsOf as W, LOG_LABEL as Wt, referenceOf as X, secondsOf as Xt, propagationSource as Y, seconds as Yt, reusesReset as Z, showBand as Zt, ClusterManifest as _, WindowPrediction as _n, dropOf as _t, STAGES as a, MeshFlavor as an, RecordLine as at, FORMAT_V1 as b, KindConfig as bn, intakeOf as bt, readRecord as c, Prediction as cn, SliceLine as ct, calibrationOf as d, Replica as dn, TunnelLine as dt, EdgeProtocol as en, Endpoint as et, cellsTable as f, ResetReuse as fn, ZtunnelPodLine as ft, BandV1 as g, TriggerKind as gn, deletionOf as gt, timeSpread as h, Trigger as hn, byNode as ht, quantileOf as i, Mesh as in, PropagationSource as it, judge as j, scenario as jn, signalOf as jt, RunFactsV1 as k, kubeProxyPatch as kn, restartsAt as kt, Judged as l, RedisDeclaration as ln, SocketLine as lt, predictionText as m, Template as mn, byClients as mt, medianInterval as n, KindRun as nn, Line as nt, kindCellRecordSchema as o, MeshMode as on, Request as ot, medianText as p, Stack as pn, backendsAt as pt, observationEnd as q, SERVER as qt, middle as r, KubeletProbe as rn, PodLine as rt, kindCellRecordV1Schema as s, PodSettings as sn, RulesLine as st, RELATIVE as t, KindCell as tn, HBONE_PORT as tt, TimeSpread as u, Reference as un, TCP_STATE as ut, EnvironmentManifest as v, Workload as vn, emptyOf as vt, KindCellV1 as w, NodeImage as wn, podsAt as wt, KindCellRecord as x, KindScenario as xn, isTunnelState as xt, FORMAT as y, KUBE_PROXY_MODES as yn, failuresOf as yt, Propagated as z, tunnelsOf as zt };
1053
+ //# sourceMappingURL=judge-DrMgsOZ0.d.ts.map
package/build/judge.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as updatesOf, $t as Declaration, A as TriggerV1, At as rulesOf, B as RunCheck, Bt as ztunnelPodsOf, C as KindCellResult, Ct as outcomesOf, D as PredictionV1, Dt as requestsOf, E as LoadSample, Et as recordsOf, F as KIND_NOISE, Ft as slicesOf, G as judgeKind, Gt as PORT, H as checkRun, Ht as CLIENT, I as KindDecision, It as socketsOf, J as propagationOf, Jt as bandOf, K as observationAfter, Kt as REDIS, L as KindVerdict, Lt as stoppingOf, M as upgrade, Mt as signalsOf, N as upgradeCell, Nt as sliceDropOf, O as RunCheckV1, Ot as restartOf, P as Deleted, Pt as sliceEmptyOf, Q as unitOf, Qt as Band, R as LAST_SLACK, Rt as transitionOf, S as KindCellRecordV1, St as kernelCounts, T as KindVerdictV1, Tt as podsOf, U as deletionsOf, Ut as HEALTH_PORT, V as RunFacts, Vt as ztunnelReplaced, W as factsOf, Wt as LOG_LABEL, X as referenceOf, Xt as secondsOf, Y as propagationSource, Yt as seconds, Z as reusesReset, Zt as showBand, _ as ClusterManifest, _n as Workload, _t as dropOf, a as STAGES, an as MeshMode, at as RecordLine, b as FORMAT_V1, bt as intakeOf, c as readRecord, cn as RedisDeclaration, ct as SliceLine, d as calibrationOf, dn as ResetReuse, dt as TunnelLine, en as KindCell, et as Endpoint, f as cellsTable, fn as Stack, ft as ZtunnelPodLine, g as BandV1, gn as WindowPrediction, gt as deletionOf, h as timeSpread, hn as TriggerKind, ht as byNode, i as quantileOf, in as MeshFlavor, it as PropagationSource, j as judge, jt as signalOf, k as RunFactsV1, kt as restartsAt, l as Judged, ln as Reference, lt as SocketLine, m as predictionText, mn as Trigger, mt as byClients, n as medianInterval, nn as KubeletProbe, nt as Line, o as kindCellRecordSchema, on as PodSettings, ot as Request, p as medianText, pn as Template, pt as backendsAt, q as observationEnd, qt as SERVER, r as middle, rn as Mesh, rt as PodLine, s as kindCellRecordV1Schema, sn as Prediction, st as RulesLine, t as RELATIVE, tn as KindRun, tt as HBONE_PORT, u as TimeSpread, un as Replica, ut as TCP_STATE, v as EnvironmentManifest, vt as emptyOf, w as KindCellV1, wt as podsAt, x as KindCellRecord, xn as KubeProxyMode, xt as isTunnelState, y as FORMAT, yt as failuresOf, z as Propagated, zt as tunnelsOf } from "./judge-4bzoeGIb.js";
2
- export { type Band, type BandV1, CLIENT, type ClusterManifest, type Declaration, type Deleted, Endpoint, type EnvironmentManifest, FORMAT, FORMAT_V1, HBONE_PORT, HEALTH_PORT, type Judged, KIND_NOISE, type KindCell, type KindCellRecord, type KindCellRecordV1, type KindCellResult, type KindCellV1, type KindDecision, type KindRun, type KindVerdict, type KindVerdictV1, type KubeProxyMode, type KubeletProbe, LAST_SLACK, LOG_LABEL, Line, type LoadSample, type Mesh, type MeshFlavor, type MeshMode, PORT, PodLine, type PodSettings, type Prediction, type PredictionV1, type Propagated, PropagationSource, REDIS, RELATIVE, RecordLine, type RedisDeclaration, type Reference, type Replica, Request, type ResetReuse, RulesLine, type RunCheck, type RunCheckV1, type RunFacts, type RunFactsV1, SERVER, STAGES, SliceLine, SocketLine, type Stack, TCP_STATE, type Template, type TimeSpread, type Trigger, type TriggerKind, type TriggerV1, TunnelLine, type WindowPrediction, type Workload, ZtunnelPodLine, backendsAt, bandOf, byClients, byNode, calibrationOf, cellsTable, checkRun, deletionOf, deletionsOf, dropOf, emptyOf, factsOf, failuresOf, intakeOf, isTunnelState, judge, judgeKind, kernelCounts, kindCellRecordSchema, kindCellRecordV1Schema, medianInterval, medianText, middle, observationAfter, observationEnd, outcomesOf, podsAt, podsOf, predictionText, propagationOf, propagationSource, quantileOf, readRecord, recordsOf, referenceOf, requestsOf, restartOf, restartsAt, reusesReset, rulesOf, seconds, secondsOf, showBand, signalOf, signalsOf, sliceDropOf, sliceEmptyOf, slicesOf, socketsOf, stoppingOf, timeSpread, transitionOf, tunnelsOf, unitOf, updatesOf, upgrade, upgradeCell, ztunnelPodsOf, ztunnelReplaced };
1
+ import { $ as updatesOf, $t as Declaration, A as TriggerV1, At as rulesOf, B as RunCheck, Bt as ztunnelPodsOf, C as KindCellResult, Ct as outcomesOf, D as PredictionV1, Dt as requestsOf, E as LoadSample, Et as recordsOf, F as KIND_NOISE, Ft as slicesOf, G as judgeKind, Gt as PORT, H as checkRun, Ht as CLIENT, I as KindDecision, It as socketsOf, J as propagationOf, Jt as bandOf, K as observationAfter, Kt as REDIS, L as KindVerdict, Lt as stoppingOf, M as upgrade, Mt as signalsOf, N as upgradeCell, Nt as sliceDropOf, O as RunCheckV1, Ot as restartOf, P as Deleted, Pt as sliceEmptyOf, Q as unitOf, Qt as Band, R as LAST_SLACK, Rt as transitionOf, S as KindCellRecordV1, Sn as KubeProxyMode, St as kernelCounts, T as KindVerdictV1, Tt as podsOf, U as deletionsOf, Ut as HEALTH_PORT, V as RunFacts, Vt as ztunnelReplaced, W as factsOf, Wt as LOG_LABEL, X as referenceOf, Xt as secondsOf, Y as propagationSource, Yt as seconds, Z as reusesReset, Zt as showBand, _ as ClusterManifest, _n as WindowPrediction, _t as dropOf, a as STAGES, an as MeshFlavor, at as RecordLine, b as FORMAT_V1, bt as intakeOf, c as readRecord, cn as Prediction, ct as SliceLine, d as calibrationOf, dn as Replica, dt as TunnelLine, en as EdgeProtocol, et as Endpoint, f as cellsTable, fn as ResetReuse, ft as ZtunnelPodLine, g as BandV1, gn as TriggerKind, gt as deletionOf, h as timeSpread, hn as Trigger, ht as byNode, i as quantileOf, in as Mesh, it as PropagationSource, j as judge, jt as signalOf, k as RunFactsV1, kt as restartsAt, l as Judged, ln as RedisDeclaration, lt as SocketLine, m as predictionText, mn as Template, mt as byClients, n as medianInterval, nn as KindRun, nt as Line, o as kindCellRecordSchema, on as MeshMode, ot as Request, p as medianText, pn as Stack, pt as backendsAt, q as observationEnd, qt as SERVER, r as middle, rn as KubeletProbe, rt as PodLine, s as kindCellRecordV1Schema, sn as PodSettings, st as RulesLine, t as RELATIVE, tn as KindCell, tt as HBONE_PORT, u as TimeSpread, un as Reference, ut as TCP_STATE, v as EnvironmentManifest, vn as Workload, vt as emptyOf, w as KindCellV1, wt as podsAt, x as KindCellRecord, xt as isTunnelState, y as FORMAT, yt as failuresOf, z as Propagated, zt as tunnelsOf } from "./judge-DrMgsOZ0.js";
2
+ export { type Band, type BandV1, CLIENT, type ClusterManifest, type Declaration, type Deleted, type EdgeProtocol, Endpoint, type EnvironmentManifest, FORMAT, FORMAT_V1, HBONE_PORT, HEALTH_PORT, type Judged, KIND_NOISE, type KindCell, type KindCellRecord, type KindCellRecordV1, type KindCellResult, type KindCellV1, type KindDecision, type KindRun, type KindVerdict, type KindVerdictV1, type KubeProxyMode, type KubeletProbe, LAST_SLACK, LOG_LABEL, Line, type LoadSample, type Mesh, type MeshFlavor, type MeshMode, PORT, PodLine, type PodSettings, type Prediction, type PredictionV1, type Propagated, PropagationSource, REDIS, RELATIVE, RecordLine, type RedisDeclaration, type Reference, type Replica, Request, type ResetReuse, RulesLine, type RunCheck, type RunCheckV1, type RunFacts, type RunFactsV1, SERVER, STAGES, SliceLine, SocketLine, type Stack, TCP_STATE, type Template, type TimeSpread, type Trigger, type TriggerKind, type TriggerV1, TunnelLine, type WindowPrediction, type Workload, ZtunnelPodLine, backendsAt, bandOf, byClients, byNode, calibrationOf, cellsTable, checkRun, deletionOf, deletionsOf, dropOf, emptyOf, factsOf, failuresOf, intakeOf, isTunnelState, judge, judgeKind, kernelCounts, kindCellRecordSchema, kindCellRecordV1Schema, medianInterval, medianText, middle, observationAfter, observationEnd, outcomesOf, podsAt, podsOf, predictionText, propagationOf, propagationSource, quantileOf, readRecord, recordsOf, referenceOf, requestsOf, restartOf, restartsAt, reusesReset, rulesOf, seconds, secondsOf, showBand, signalOf, signalsOf, sliceDropOf, sliceEmptyOf, slicesOf, socketsOf, stoppingOf, timeSpread, transitionOf, tunnelsOf, unitOf, updatesOf, upgrade, upgradeCell, ztunnelPodsOf, ztunnelReplaced };
package/build/judge.js CHANGED
@@ -1 +1 @@
1
- export { ut as CLIENT, u as FORMAT, d as FORMAT_V1, N as HBONE_PORT, dt as HEALTH_PORT, h as KIND_NOISE, g as LAST_SLACK, ft as LOG_LABEL, pt as PORT, mt as REDIS, k as RELATIVE, ht as SERVER, t as STAGES, P as TCP_STATE, F as backendsAt, gt as bandOf, I as byClients, L as byNode, a as calibrationOf, o as cellsTable, _ as checkRun, R as deletionOf, v as deletionsOf, z as dropOf, B as emptyOf, y as factsOf, V as failuresOf, H as intakeOf, U as isTunnelState, f as judge, b as judgeKind, W as kernelCounts, n as kindCellRecordSchema, r as kindCellRecordV1Schema, A as medianInterval, s as medianText, j as middle, x as observationAfter, S as observationEnd, G as outcomesOf, K as podsAt, q as podsOf, c as predictionText, C as propagationOf, w as propagationSource, M as quantileOf, i as readRecord, J as recordsOf, T as referenceOf, Y as requestsOf, X as restartOf, Z as restartsAt, E as reusesReset, Q as rulesOf, _t as seconds, vt as secondsOf, yt as showBand, $ as signalOf, et as signalsOf, tt as sliceDropOf, nt as sliceEmptyOf, rt as slicesOf, it as socketsOf, at as stoppingOf, l as timeSpread, ot as transitionOf, st as tunnelsOf, D as unitOf, O as updatesOf, p as upgrade, m as upgradeCell, ct as ztunnelPodsOf, lt as ztunnelReplaced } from "./judge-DdeJ1qVd.js";
1
+ export { ut as CLIENT, u as FORMAT, d as FORMAT_V1, N as HBONE_PORT, dt as HEALTH_PORT, h as KIND_NOISE, g as LAST_SLACK, ft as LOG_LABEL, pt as PORT, mt as REDIS, k as RELATIVE, ht as SERVER, t as STAGES, P as TCP_STATE, F as backendsAt, gt as bandOf, I as byClients, L as byNode, a as calibrationOf, o as cellsTable, _ as checkRun, R as deletionOf, v as deletionsOf, z as dropOf, B as emptyOf, y as factsOf, V as failuresOf, H as intakeOf, U as isTunnelState, f as judge, b as judgeKind, W as kernelCounts, n as kindCellRecordSchema, r as kindCellRecordV1Schema, A as medianInterval, s as medianText, j as middle, x as observationAfter, S as observationEnd, G as outcomesOf, K as podsAt, q as podsOf, c as predictionText, C as propagationOf, w as propagationSource, M as quantileOf, i as readRecord, J as recordsOf, T as referenceOf, Y as requestsOf, X as restartOf, Z as restartsAt, E as reusesReset, Q as rulesOf, _t as seconds, vt as secondsOf, yt as showBand, $ as signalOf, et as signalsOf, tt as sliceDropOf, nt as sliceEmptyOf, rt as slicesOf, it as socketsOf, at as stoppingOf, l as timeSpread, ot as transitionOf, st as tunnelsOf, D as unitOf, O as updatesOf, p as upgrade, m as upgradeCell, ct as ztunnelPodsOf, lt as ztunnelReplaced } from "./judge-C09uZiha.js";
package/image/app.mjs CHANGED
@@ -6,6 +6,7 @@
6
6
  // service: the lab has no transport of its own.
7
7
  import { existsSync, readFileSync } from "node:fs";
8
8
  import http from "node:http";
9
+ import http2 from "node:http2";
9
10
  import { handle, httpTransport, pathOf, probeServer } from "@mark1russell7/service/http";
10
11
  import { redisClient } from "@mark1russell7/service/redis";
11
12
  import { CONTROLLER, ROUTE, compose } from "./compose.ts";
@@ -66,8 +67,9 @@ const KNOBS = { server_idle_close: s(6), server_idle_sweep_interval: s(1), serve
66
67
 
67
68
  // the server transport: the transport gets the lifecycle at its start, thus a request before the end
68
69
  // of the startup gets the refusal of the service (503, retryable), and Connection: close while the
69
- // service is not ready
70
- const server = http.createServer();
70
+ // service is not ready. With the protocol h2c of the declaration, the edge is a server of HTTP/2
71
+ // without TLS, and the close of a connection is a GOAWAY on its session (the candidate C of S2)
72
+ const server = declaration.protocol === "h2c" ? http2.createServer() : http.createServer();
71
73
  server.on("listening", () => say({ ev: "app", what: "listening", port: config.port }));
72
74
  // lameDuck false of the declaration keeps each connection open while the service is not ready: then a
73
75
  // caller learns only from the endpoints (the candidate A of S2). The default is the lame duck
package/image/client.mjs CHANGED
@@ -3,8 +3,11 @@
3
3
  // count of keep-alive connections, and each request goes on the next one in turn. kube-proxy picks a
4
4
  // backend only for a new connection. SIGHUP opens new connections. Each request is one JSON line with
5
5
  // its start on CLOCK_MONOTONIC, its duration, its outcome (ok, 503, refused, reset, timeout,
6
- // unreachable, or another error) and its local port (`lp`).
6
+ // unreachable, or another error) and its local port (`lp`). With PROTOCOL h2c, each connection is a
7
+ // session of HTTP/2, and each request is a stream on the next session in turn.
7
8
  import http from "node:http";
9
+ import http2 from "node:http2";
10
+ import net from "node:net";
8
11
 
9
12
  const [host, port] = (process.env.TARGET ?? "").split(":");
10
13
  const every = Number(process.env.EVERY_MS ?? 20);
@@ -12,21 +15,48 @@ const timeout = Number(process.env.TIMEOUT_MS ?? 1000);
12
15
  const pod = process.env.POD_NAME ?? "client";
13
16
  const node = process.env.NODE_NAME ?? "";
14
17
  const now = () => Number(process.hrtime.bigint()) / 1e6;
15
- const connections = process.env.CONNECTIONS === undefined ? 0 : Number(process.env.CONNECTIONS);
18
+ const h2 = process.env.PROTOCOL === "h2c";
19
+ // a client of HTTP/2 needs at least one session
20
+ const connections = process.env.CONNECTIONS === undefined ? (h2 ? 1 : 0) : Number(process.env.CONNECTIONS);
16
21
 
17
22
  // each agent holds one keep-alive connection. A `Connection: close` of the server ends it after its
18
23
  // answer, and the next request on the agent opens a new connection
19
24
  const agentsOf = () => Array.from({ length: connections }, () => new http.Agent({ keepAlive: true, maxSockets: 1 }));
20
- let agents = agentsOf();
25
+ let agents = h2 ? [] : agentsOf();
21
26
  let turn = 0;
22
- // SIGHUP: new agents for the next requests. The old agents go after the timeout, thus each request
23
- // on them ends first
27
+
28
+ // each slot of HTTP/2 holds one session on its own socket, thus the client knows its local port. A
29
+ // GOAWAY, a close or an error of the session makes the slot open a new session at its next stream.
30
+ // kube-proxy picks a backend for that new connection. The old session ends the streams that it has
31
+ const sessionOf = () => {
32
+ const socket = net.connect({ host, port: Number(port) });
33
+ const session = http2.connect(`http://${host}:${port}`, { createConnection: () => socket });
34
+ const held = { session, socket, usable: true };
35
+ const drop = () => {
36
+ held.usable = false;
37
+ };
38
+ session.on("goaway", drop);
39
+ session.on("close", drop);
40
+ session.on("error", drop);
41
+ return held;
42
+ };
43
+ let slots = h2 ? Array.from({ length: connections }, sessionOf) : [];
44
+ const slotAt = (at) => {
45
+ if (!slots[at].usable) slots[at] = sessionOf();
46
+ return slots[at];
47
+ };
48
+
49
+ // SIGHUP: new agents or sessions for the next requests. The old ones go after the timeout, thus each
50
+ // request on them ends first
24
51
  process.on("SIGHUP", () => {
25
52
  const old = agents;
26
- agents = agentsOf();
53
+ const oldSlots = slots;
54
+ if (h2) slots = Array.from({ length: connections }, sessionOf);
55
+ else agents = agentsOf();
27
56
  say({ ev: "client", what: "reconnect", t: now() });
28
57
  setTimeout(() => {
29
58
  for (const agent of old) agent.destroy();
59
+ for (const held of oldSlots) held.session.destroy();
30
60
  }, timeout + 100);
31
61
  });
32
62
 
@@ -56,6 +86,8 @@ const portOf = (socket) => {
56
86
  return typeof out.port === "number" ? out.port : null;
57
87
  };
58
88
 
89
+ const outcomeOfStatus = (status) => (status === 200 ? "ok" : status === 503 ? "503" : `status-${status}`);
90
+
59
91
  const fire = () => {
60
92
  const t = now();
61
93
  let done = false;
@@ -80,7 +112,7 @@ const fire = () => {
80
112
  res.on("data", (chunk) => {
81
113
  body += chunk;
82
114
  });
83
- res.on("end", () => finish(res.statusCode === 200 ? "ok" : res.statusCode === 503 ? "503" : `status-${res.statusCode}`, { b: body.slice(0, 64) }));
115
+ res.on("end", () => finish(outcomeOfStatus(res.statusCode), { b: body.slice(0, 64) }));
84
116
  res.on("error", (error) => finish(outcomeOf(error), { e: error.code ?? String(error) }));
85
117
  });
86
118
  const timer = setTimeout(() => {
@@ -105,5 +137,86 @@ const fire = () => {
105
137
  req.end();
106
138
  };
107
139
 
108
- say({ ev: "client", what: "start", t: now(), target: `${host}:${port}`, every, timeout, connections });
109
- setInterval(fire, every);
140
+ // a stream that the server did not take: REFUSED_STREAM, a stream above the last one of a GOAWAY, or
141
+ // a stream on a session that closed before it went. RFC 9113 (section 8.7) lets the client send it
142
+ // again, and the client does that once, on a new session
143
+ const REFUSED = http2.constants.NGHTTP2_REFUSED_STREAM;
144
+ const untaken = (error, stream) =>
145
+ stream?.rstCode === REFUSED ||
146
+ /REFUSED_STREAM/.test(String(error?.message ?? "")) ||
147
+ error?.code === "ERR_HTTP2_GOAWAY_SESSION" ||
148
+ error?.code === "ERR_HTTP2_INVALID_SESSION";
149
+
150
+ // one request of HTTP/2: a stream on the next session in turn. Each stream writes the same line as a
151
+ // request of HTTP/1.1, and `r` tells that the client sent it again
152
+ const fireH2 = () => {
153
+ const t = now();
154
+ const at = turn++ % connections;
155
+ let done = false;
156
+ let lp = null;
157
+ let held = null;
158
+ let stream = null;
159
+ let again = false;
160
+ const finish = (o, extra = {}) => {
161
+ if (done) return;
162
+ done = true;
163
+ clearTimeout(timer);
164
+ lp ??= portOf(held?.socket);
165
+ say({ ev: "req", t, d: Math.round((now() - t) * 1000) / 1000, o, ...extra, lp, ...(again ? { r: 1 } : {}) });
166
+ };
167
+ const failed = (error) => {
168
+ if (done) return;
169
+ if (!again && untaken(error, stream)) {
170
+ again = true;
171
+ held.usable = false;
172
+ send();
173
+ return;
174
+ }
175
+ finish(outcomeOf(error), { e: error?.code ?? String(error) });
176
+ };
177
+ const send = () => {
178
+ held = slotAt(at);
179
+ lp = portOf(held.socket);
180
+ if (held.socket.connecting)
181
+ held.socket.once("connect", () => {
182
+ lp ??= portOf(held.socket);
183
+ });
184
+ try {
185
+ stream = held.session.request({ ":path": "/work" });
186
+ } catch (error) {
187
+ failed(error);
188
+ return;
189
+ }
190
+ const mine = stream;
191
+ let status = 0;
192
+ let body = "";
193
+ mine.setEncoding("utf8");
194
+ mine.on("response", (headers) => {
195
+ status = Number(headers[":status"]);
196
+ });
197
+ mine.on("data", (chunk) => {
198
+ body += chunk;
199
+ });
200
+ mine.on("end", () => {
201
+ if (mine === stream && status !== 0) finish(outcomeOfStatus(status), { b: body.slice(0, 64) });
202
+ });
203
+ mine.on("error", (error) => {
204
+ if (mine === stream) failed(error);
205
+ });
206
+ mine.on("close", () => {
207
+ if (mine !== stream || done) return;
208
+ if (status !== 0) finish(outcomeOfStatus(status), { b: body.slice(0, 64) });
209
+ else failed(Object.assign(new Error(`the stream closed with code ${mine.rstCode}`), { code: mine.rstCode === REFUSED ? "REFUSED_STREAM" : "ECONNRESET" }));
210
+ });
211
+ mine.end();
212
+ };
213
+ const timer = setTimeout(() => {
214
+ lp ??= portOf(held?.socket);
215
+ stream?.close(http2.constants.NGHTTP2_CANCEL);
216
+ finish("timeout", { e: "LAB_TIMEOUT" });
217
+ }, timeout);
218
+ send();
219
+ };
220
+
221
+ say({ ev: "client", what: "start", t: now(), target: `${host}:${port}`, every, timeout, connections, protocol: h2 ? "h2c" : "http/1.1" });
222
+ setInterval(h2 ? fireH2 : fire, every);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@mark1russell7/kind",
4
- "version": "0.11.0",
4
+ "version": "0.11.2",
5
5
  "description": "Kubernetes in Docker as a lab for connection timers: a kind cluster from a scenario, faults in the namespaces of its pods, observations on the one monotonic clock of the VM, and predictions from the ordering law. Its judge entry reads and judges a raw record without Docker.",
6
6
  "keywords": [
7
7
  "kubernetes",
@@ -67,7 +67,7 @@
67
67
  "dependencies": {
68
68
  "@mark1russell7/harness": "^0.12.4",
69
69
  "@mark1russell7/quantity": "^0.2.0",
70
- "@mark1russell7/service": "^0.5.18",
70
+ "@mark1russell7/service": "^0.5.19",
71
71
  "testcontainers": "12.2.0"
72
72
  },
73
73
  "peerDependencies": {