typekro 0.35.0 → 0.36.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/.tsbuildinfo +1 -1
- package/dist/alchemy/kro-delete.d.ts +7 -0
- package/dist/alchemy/kro-delete.d.ts.map +1 -1
- package/dist/alchemy/kro-delete.js +28 -4
- package/dist/alchemy/kro-delete.js.map +1 -1
- package/dist/alchemy/resource-registration.d.ts +9 -2
- package/dist/alchemy/resource-registration.d.ts.map +1 -1
- package/dist/alchemy/resource-registration.js +117 -33
- package/dist/alchemy/resource-registration.js.map +1 -1
- package/dist/core/deployment/k8s-helpers.d.ts +77 -1
- package/dist/core/deployment/k8s-helpers.d.ts.map +1 -1
- package/dist/core/deployment/k8s-helpers.js +298 -17
- package/dist/core/deployment/k8s-helpers.js.map +1 -1
- package/dist/core/deployment/kro-artifact-binding-migration.d.ts +17 -6
- package/dist/core/deployment/kro-artifact-binding-migration.d.ts.map +1 -1
- package/dist/core/deployment/kro-artifact-binding-migration.js +16 -2
- package/dist/core/deployment/kro-artifact-binding-migration.js.map +1 -1
- package/dist/core/deployment/kro-namespace-teardown.d.ts +15 -1
- package/dist/core/deployment/kro-namespace-teardown.d.ts.map +1 -1
- package/dist/core/deployment/kro-namespace-teardown.js +34 -9
- package/dist/core/deployment/kro-namespace-teardown.js.map +1 -1
- package/dist/core/deployment/kro-readiness.d.ts +35 -0
- package/dist/core/deployment/kro-readiness.d.ts.map +1 -1
- package/dist/core/deployment/kro-readiness.js +201 -25
- package/dist/core/deployment/kro-readiness.js.map +1 -1
- package/dist/core/deployment/poll-timeout.d.ts +80 -2
- package/dist/core/deployment/poll-timeout.d.ts.map +1 -1
- package/dist/core/deployment/poll-timeout.js +164 -4
- package/dist/core/deployment/poll-timeout.js.map +1 -1
- package/dist/core/kubernetes/bun-http-library.d.ts +24 -0
- package/dist/core/kubernetes/bun-http-library.d.ts.map +1 -1
- package/dist/core/kubernetes/bun-http-library.js +146 -19
- package/dist/core/kubernetes/bun-http-library.js.map +1 -1
- package/dist/core/kubernetes/errors.d.ts +9 -0
- package/dist/core/kubernetes/errors.d.ts.map +1 -1
- package/dist/core/kubernetes/errors.js +7 -3
- package/dist/core/kubernetes/errors.js.map +1 -1
- package/dist/factories/clickhouse/compositions/clickhouse-cluster.d.ts +24 -2
- package/dist/factories/clickhouse/compositions/clickhouse-cluster.d.ts.map +1 -1
- package/dist/factories/clickhouse/compositions/clickhouse-cluster.js +24 -2
- package/dist/factories/clickhouse/compositions/clickhouse-cluster.js.map +1 -1
- package/dist/factories/clickhouse/resources/keeper.d.ts +61 -0
- package/dist/factories/clickhouse/resources/keeper.d.ts.map +1 -1
- package/dist/factories/clickhouse/resources/keeper.js +216 -2
- package/dist/factories/clickhouse/resources/keeper.js.map +1 -1
- package/dist/factories/clickhouse/resources/s3-backup.d.ts.map +1 -1
- package/dist/factories/clickhouse/resources/s3-backup.js +4 -3
- package/dist/factories/clickhouse/resources/s3-backup.js.map +1 -1
- package/dist/factories/clickhouse/types.d.ts +3 -2
- package/dist/factories/clickhouse/types.d.ts.map +1 -1
- package/dist/factories/clickhouse/types.js +28 -1
- package/dist/factories/clickhouse/types.js.map +1 -1
- package/dist/factories/clickhouse/utils/validation.d.ts +133 -10
- package/dist/factories/clickhouse/utils/validation.d.ts.map +1 -1
- package/dist/factories/clickhouse/utils/validation.js +165 -18
- package/dist/factories/clickhouse/utils/validation.js.map +1 -1
- package/dist/factories/clickstack/compositions/clickstack-bootstrap.d.ts +15 -1
- package/dist/factories/clickstack/compositions/clickstack-bootstrap.d.ts.map +1 -1
- package/dist/factories/clickstack/compositions/clickstack-bootstrap.js +15 -1
- package/dist/factories/clickstack/compositions/clickstack-bootstrap.js.map +1 -1
- package/dist/factories/rook/types.d.ts +16 -16
- package/package.json +1 -1
|
@@ -19,9 +19,26 @@
|
|
|
19
19
|
* exec-auth failure mode is to avoid per-request exec auth during polling (e.g. a pre-minted bearer token
|
|
20
20
|
* in the kubeconfig), so no credential subprocess is spawned in the first place.
|
|
21
21
|
*/
|
|
22
|
-
/**
|
|
23
|
-
|
|
22
|
+
/**
|
|
23
|
+
* A Kubernetes request that did not return within its budget — whichever layer noticed first.
|
|
24
|
+
*
|
|
25
|
+
* TWO layers can time the same request out, and callers must not have to care which won. The Bun
|
|
26
|
+
* HTTP library arms its socket timer synchronously while the request is being issued; a wrapper
|
|
27
|
+
* added by {@link withCallDeadline} arms its timer afterwards. With equal budgets the socket timer
|
|
28
|
+
* therefore fires FIRST, so a gate that recognised only the wrapper's error would treat a genuine
|
|
29
|
+
* timeout as an ordinary failure — and a gate that fails OPEN on ordinary failures would silently
|
|
30
|
+
* skip its assertion. Both layers raise this type; {@link isRequestTimeoutError} recognises it.
|
|
31
|
+
*/
|
|
32
|
+
export declare class RequestTimeoutError extends Error {
|
|
24
33
|
readonly timeoutMs: number;
|
|
34
|
+
/** Structural marker, so recognition survives duplicate module instances where `instanceof` does not. */
|
|
35
|
+
readonly isRequestTimeout: true;
|
|
36
|
+
constructor(message: string, timeoutMs: number);
|
|
37
|
+
}
|
|
38
|
+
/** True for a timeout raised by EITHER timing layer — the socket's or a {@link withCallDeadline} wrapper's. */
|
|
39
|
+
export declare function isRequestTimeoutError(error: unknown): error is RequestTimeoutError;
|
|
40
|
+
/** Thrown when a readiness-poll API call exceeds its per-call budget (distinguishable so callers can fail fast vs. retry). */
|
|
41
|
+
export declare class PollTimeoutError extends RequestTimeoutError {
|
|
25
42
|
constructor(label: string, timeoutMs: number);
|
|
26
43
|
}
|
|
27
44
|
/**
|
|
@@ -42,4 +59,65 @@ export declare function callWithTimeout<T>(op: () => Promise<T>, timeoutMs: numb
|
|
|
42
59
|
* {@link callWithTimeout}.
|
|
43
60
|
*/
|
|
44
61
|
export declare function perCallTimeout(remainingMs: number, capMs: number): number;
|
|
62
|
+
/**
|
|
63
|
+
* The per-verb request budget {@link withCallDeadline} applies. Reads are expected to be quick;
|
|
64
|
+
* creates and updates may sit behind admission webhooks; deletes may wait on finalizers — the same
|
|
65
|
+
* split the repo's HTTP defaults already make, so a caller's configured `httpTimeouts` is honored
|
|
66
|
+
* per verb instead of being flattened onto the read budget. `create` and `update` are kept APART
|
|
67
|
+
* because `HttpTimeoutConfig` exposes them separately: collapsing them into one write budget makes
|
|
68
|
+
* one of the two configured values unreachable.
|
|
69
|
+
*/
|
|
70
|
+
export interface CallDeadlineBudget {
|
|
71
|
+
/** GET / LIST and anything not classified as a create, an update or a delete. */
|
|
72
|
+
readonly read: number;
|
|
73
|
+
/** POST — `create*`. */
|
|
74
|
+
readonly create: number;
|
|
75
|
+
/** PUT / PATCH — `replace*`, `patch*`, server-side apply. */
|
|
76
|
+
readonly update: number;
|
|
77
|
+
/** DELETE. */
|
|
78
|
+
readonly delete: number;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Derive a per-verb budget from a caller's {@link HttpTimeoutConfig}-shaped options, each verb
|
|
82
|
+
* capped by `capMs` (normally the deployment timeout) so one request can never outlive the
|
|
83
|
+
* operation it belongs to. Non-positive / non-finite values fall back to the repo defaults —
|
|
84
|
+
* notably `timeout: 0`, which is NOT nullish and would otherwise collapse every budget to zero.
|
|
85
|
+
*/
|
|
86
|
+
export declare function callDeadlineBudget(timeouts: {
|
|
87
|
+
readonly default?: number | undefined;
|
|
88
|
+
readonly create?: number | undefined;
|
|
89
|
+
readonly update?: number | undefined;
|
|
90
|
+
readonly delete?: number | undefined;
|
|
91
|
+
} | undefined, capMs?: number): CallDeadlineBudget;
|
|
92
|
+
/**
|
|
93
|
+
* Classify a client method by name so it is bounded by its own verb's budget, matching the split the
|
|
94
|
+
* HTTP layer already makes by method (POST → create, PUT/PATCH → update, DELETE → delete). Anything
|
|
95
|
+
* else — `read`, `list`, `get*`, `listClusterCustomObject`, and any method a future client version
|
|
96
|
+
* adds — is treated as a READ, the shortest budget. Erring toward the short budget is deliberate: a
|
|
97
|
+
* misclassified call fails fast and visibly rather than hanging. A combined name (`createOrReplace`)
|
|
98
|
+
* resolves to `create`, the verb such a helper attempts first.
|
|
99
|
+
*/
|
|
100
|
+
export declare function callDeadlineVerb(method: string): keyof CallDeadlineBudget;
|
|
101
|
+
/**
|
|
102
|
+
* Wrap a Kubernetes API client so every request it issues is bounded by its verb's budget.
|
|
103
|
+
*
|
|
104
|
+
* Readiness polls already bound their own calls (see {@link callWithTimeout}); everything a handler
|
|
105
|
+
* does AROUND a deploy — drift checks, safety gates, CRD migrations, teardown — historically did
|
|
106
|
+
* not, so a single wedged request (a hung exec credential, a half-open socket, an API server that
|
|
107
|
+
* accepts the connection and never answers) hangs the whole reconcile with no log line and no
|
|
108
|
+
* error. Bounding at the client makes each of those calls reject with a {@link PollTimeoutError}
|
|
109
|
+
* naming the client and the method.
|
|
110
|
+
*
|
|
111
|
+
* EVERY function-valued property is wrapped, not an allow-list of known method names: a client
|
|
112
|
+
* method this module has never heard of must not silently escape the bound. A wrapped call whose
|
|
113
|
+
* return value is not thenable is handed back untouched, so synchronous helpers keep working.
|
|
114
|
+
*
|
|
115
|
+
* Same SCOPE / LIMITATION as {@link callWithTimeout}: this bounds the caller's `await`, it does not
|
|
116
|
+
* cancel the in-flight request or kill a wedged exec-auth subprocess.
|
|
117
|
+
*/
|
|
118
|
+
export declare function withCallDeadline<T extends object>(api: T, options: {
|
|
119
|
+
readonly budget: CallDeadlineBudget;
|
|
120
|
+
readonly label: string;
|
|
121
|
+
readonly abortSignal?: AbortSignal;
|
|
122
|
+
}): T;
|
|
45
123
|
//# sourceMappingURL=poll-timeout.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poll-timeout.d.ts","sourceRoot":"","sources":["../../../src/core/deployment/poll-timeout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;
|
|
1
|
+
{"version":3,"file":"poll-timeout.d.ts","sourceRoot":"","sources":["../../../src/core/deployment/poll-timeout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG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AE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC,GACD,SAAS,EACb,KAAK,CAAC,EAAE,MAAM,GACb,kBAAkB,CAYpB;AASD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,kBAAkB,CAKzE;AAsDD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAC/C,GAAG,EAAE,CAAC,EACN,OAAO,EAAE;IACP,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;CACpC,GACA,CAAC,CA0BH"}
|
|
@@ -19,15 +19,42 @@
|
|
|
19
19
|
* exec-auth failure mode is to avoid per-request exec auth during polling (e.g. a pre-minted bearer token
|
|
20
20
|
* in the kubeconfig), so no credential subprocess is spawned in the first place.
|
|
21
21
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
import { DEFAULT_HTTP_DELETE_TIMEOUT, DEFAULT_HTTP_READ_TIMEOUT, DEFAULT_HTTP_WRITE_TIMEOUT, } from '../config/defaults.js';
|
|
23
|
+
/**
|
|
24
|
+
* A Kubernetes request that did not return within its budget — whichever layer noticed first.
|
|
25
|
+
*
|
|
26
|
+
* TWO layers can time the same request out, and callers must not have to care which won. The Bun
|
|
27
|
+
* HTTP library arms its socket timer synchronously while the request is being issued; a wrapper
|
|
28
|
+
* added by {@link withCallDeadline} arms its timer afterwards. With equal budgets the socket timer
|
|
29
|
+
* therefore fires FIRST, so a gate that recognised only the wrapper's error would treat a genuine
|
|
30
|
+
* timeout as an ordinary failure — and a gate that fails OPEN on ordinary failures would silently
|
|
31
|
+
* skip its assertion. Both layers raise this type; {@link isRequestTimeoutError} recognises it.
|
|
32
|
+
*/
|
|
33
|
+
export class RequestTimeoutError extends Error {
|
|
24
34
|
timeoutMs;
|
|
35
|
+
/** Structural marker, so recognition survives duplicate module instances where `instanceof` does not. */
|
|
36
|
+
isRequestTimeout = true;
|
|
37
|
+
constructor(message, timeoutMs) {
|
|
38
|
+
super(message);
|
|
39
|
+
this.name = 'RequestTimeoutError';
|
|
40
|
+
this.timeoutMs = timeoutMs;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** True for a timeout raised by EITHER timing layer — the socket's or a {@link withCallDeadline} wrapper's. */
|
|
44
|
+
export function isRequestTimeoutError(error) {
|
|
45
|
+
if (error instanceof RequestTimeoutError)
|
|
46
|
+
return true;
|
|
47
|
+
return (typeof error === 'object' &&
|
|
48
|
+
error !== null &&
|
|
49
|
+
error.isRequestTimeout === true);
|
|
50
|
+
}
|
|
51
|
+
/** Thrown when a readiness-poll API call exceeds its per-call budget (distinguishable so callers can fail fast vs. retry). */
|
|
52
|
+
export class PollTimeoutError extends RequestTimeoutError {
|
|
25
53
|
constructor(label, timeoutMs) {
|
|
26
54
|
super(`${label} exceeded its ${timeoutMs}ms request timeout — the Kubernetes API call did not return. ` +
|
|
27
55
|
`The usual cause is a wedged or expired kubeconfig exec credential (e.g. an AWS SSO/EKS token ` +
|
|
28
|
-
`that expired mid-deploy). Re-run with fresh credentials
|
|
56
|
+
`that expired mid-deploy). Re-run with fresh credentials.`, timeoutMs);
|
|
29
57
|
this.name = 'PollTimeoutError';
|
|
30
|
-
this.timeoutMs = timeoutMs;
|
|
31
58
|
}
|
|
32
59
|
}
|
|
33
60
|
/**
|
|
@@ -75,4 +102,137 @@ export async function callWithTimeout(op, timeoutMs, label, abortSignal) {
|
|
|
75
102
|
export function perCallTimeout(remainingMs, capMs) {
|
|
76
103
|
return Math.min(capMs, remainingMs);
|
|
77
104
|
}
|
|
105
|
+
/** A positive, finite number, or `fallback`. Guards against `0`, `-1`, `NaN` and `Infinity`. */
|
|
106
|
+
function positiveOr(value, fallback) {
|
|
107
|
+
return typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : fallback;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Derive a per-verb budget from a caller's {@link HttpTimeoutConfig}-shaped options, each verb
|
|
111
|
+
* capped by `capMs` (normally the deployment timeout) so one request can never outlive the
|
|
112
|
+
* operation it belongs to. Non-positive / non-finite values fall back to the repo defaults —
|
|
113
|
+
* notably `timeout: 0`, which is NOT nullish and would otherwise collapse every budget to zero.
|
|
114
|
+
*/
|
|
115
|
+
export function callDeadlineBudget(timeouts, capMs) {
|
|
116
|
+
const cap = positiveOr(capMs, Number.POSITIVE_INFINITY);
|
|
117
|
+
// NO cross-fallback between `create` and `update`: they are separate knobs in `HttpTimeoutConfig`
|
|
118
|
+
// and each falls back only to the shared write default. Letting one stand in for the other means a
|
|
119
|
+
// caller who configured `{ create: 180_000, update: 30_000 }` silently gets 180s on every PATCH —
|
|
120
|
+
// exactly the conflation this budget exists to avoid.
|
|
121
|
+
return {
|
|
122
|
+
read: Math.min(positiveOr(timeouts?.default, DEFAULT_HTTP_READ_TIMEOUT), cap),
|
|
123
|
+
create: Math.min(positiveOr(timeouts?.create, DEFAULT_HTTP_WRITE_TIMEOUT), cap),
|
|
124
|
+
update: Math.min(positiveOr(timeouts?.update, DEFAULT_HTTP_WRITE_TIMEOUT), cap),
|
|
125
|
+
delete: Math.min(positiveOr(timeouts?.delete, DEFAULT_HTTP_DELETE_TIMEOUT), cap),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/** Method-name fragments that identify a create (POST). Matched case-insensitively. */
|
|
129
|
+
const CREATE_METHOD_PATTERN = /create|post/i;
|
|
130
|
+
/** Method-name fragments that identify an update (PUT / PATCH, including server-side apply). */
|
|
131
|
+
const UPDATE_METHOD_PATTERN = /replace|patch|update|put|apply/i;
|
|
132
|
+
/** Method-name fragments that identify a delete. Matched case-insensitively, checked FIRST. */
|
|
133
|
+
const DELETE_METHOD_PATTERN = /delete|remove/i;
|
|
134
|
+
/**
|
|
135
|
+
* Classify a client method by name so it is bounded by its own verb's budget, matching the split the
|
|
136
|
+
* HTTP layer already makes by method (POST → create, PUT/PATCH → update, DELETE → delete). Anything
|
|
137
|
+
* else — `read`, `list`, `get*`, `listClusterCustomObject`, and any method a future client version
|
|
138
|
+
* adds — is treated as a READ, the shortest budget. Erring toward the short budget is deliberate: a
|
|
139
|
+
* misclassified call fails fast and visibly rather than hanging. A combined name (`createOrReplace`)
|
|
140
|
+
* resolves to `create`, the verb such a helper attempts first.
|
|
141
|
+
*/
|
|
142
|
+
export function callDeadlineVerb(method) {
|
|
143
|
+
if (DELETE_METHOD_PATTERN.test(method))
|
|
144
|
+
return 'delete';
|
|
145
|
+
if (CREATE_METHOD_PATTERN.test(method))
|
|
146
|
+
return 'create';
|
|
147
|
+
if (UPDATE_METHOD_PATTERN.test(method))
|
|
148
|
+
return 'update';
|
|
149
|
+
return 'read';
|
|
150
|
+
}
|
|
151
|
+
function isThenable(value) {
|
|
152
|
+
return (typeof value === 'object' &&
|
|
153
|
+
value !== null &&
|
|
154
|
+
typeof value.then === 'function');
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Race an already-started operation against its budget and an abort signal. Unlike
|
|
158
|
+
* {@link callWithTimeout} a non-positive / non-finite budget is allowed: the abort race still
|
|
159
|
+
* applies, only the timer is skipped. Used by {@link withCallDeadline}, where dropping the abort
|
|
160
|
+
* plumbing because a budget was misconfigured would be its own silent hang.
|
|
161
|
+
*/
|
|
162
|
+
function raceDeadline(operation, budgetMs, label, abortSignal) {
|
|
163
|
+
const bounded = Number.isFinite(budgetMs) && budgetMs > 0;
|
|
164
|
+
if (!bounded && !abortSignal)
|
|
165
|
+
return operation;
|
|
166
|
+
let timer;
|
|
167
|
+
let detachAbort = () => undefined;
|
|
168
|
+
const races = [operation];
|
|
169
|
+
if (bounded) {
|
|
170
|
+
races.push(new Promise((_, reject) => {
|
|
171
|
+
timer = setTimeout(() => reject(new PollTimeoutError(label, budgetMs)), budgetMs);
|
|
172
|
+
}));
|
|
173
|
+
}
|
|
174
|
+
if (abortSignal) {
|
|
175
|
+
races.push(new Promise((_, reject) => {
|
|
176
|
+
if (abortSignal.aborted) {
|
|
177
|
+
reject(abortSignal.reason ?? new DOMException('The operation was aborted', 'AbortError'));
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const onAbort = () => reject(abortSignal.reason ?? new DOMException('The operation was aborted', 'AbortError'));
|
|
181
|
+
abortSignal.addEventListener('abort', onAbort, { once: true });
|
|
182
|
+
detachAbort = () => abortSignal.removeEventListener('abort', onAbort);
|
|
183
|
+
}));
|
|
184
|
+
}
|
|
185
|
+
return Promise.race(races).finally(() => {
|
|
186
|
+
if (timer)
|
|
187
|
+
clearTimeout(timer);
|
|
188
|
+
detachAbort();
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Wrap a Kubernetes API client so every request it issues is bounded by its verb's budget.
|
|
193
|
+
*
|
|
194
|
+
* Readiness polls already bound their own calls (see {@link callWithTimeout}); everything a handler
|
|
195
|
+
* does AROUND a deploy — drift checks, safety gates, CRD migrations, teardown — historically did
|
|
196
|
+
* not, so a single wedged request (a hung exec credential, a half-open socket, an API server that
|
|
197
|
+
* accepts the connection and never answers) hangs the whole reconcile with no log line and no
|
|
198
|
+
* error. Bounding at the client makes each of those calls reject with a {@link PollTimeoutError}
|
|
199
|
+
* naming the client and the method.
|
|
200
|
+
*
|
|
201
|
+
* EVERY function-valued property is wrapped, not an allow-list of known method names: a client
|
|
202
|
+
* method this module has never heard of must not silently escape the bound. A wrapped call whose
|
|
203
|
+
* return value is not thenable is handed back untouched, so synchronous helpers keep working.
|
|
204
|
+
*
|
|
205
|
+
* Same SCOPE / LIMITATION as {@link callWithTimeout}: this bounds the caller's `await`, it does not
|
|
206
|
+
* cancel the in-flight request or kill a wedged exec-auth subprocess.
|
|
207
|
+
*/
|
|
208
|
+
export function withCallDeadline(api, options) {
|
|
209
|
+
const { budget, label, abortSignal } = options;
|
|
210
|
+
const wrapped = new WeakMap();
|
|
211
|
+
return new Proxy(api, {
|
|
212
|
+
get(target, property) {
|
|
213
|
+
const value = Reflect.get(target, property);
|
|
214
|
+
if (typeof value !== 'function' || typeof property !== 'string')
|
|
215
|
+
return value;
|
|
216
|
+
const cached = wrapped.get(value);
|
|
217
|
+
if (cached)
|
|
218
|
+
return cached;
|
|
219
|
+
const method = value;
|
|
220
|
+
const budgetMs = budget[callDeadlineVerb(property)];
|
|
221
|
+
const bound = (...args) => {
|
|
222
|
+
// Check the signal BEFORE the call, not just inside `raceDeadline`. Racing an
|
|
223
|
+
// already-aborted signal still STARTS the request: the caller's promise rejects, but the
|
|
224
|
+
// write or delete has already left for the API server. In a replacement sequence
|
|
225
|
+
// (delete → wait for the 404 → create) an abort landing in that window would cancel the
|
|
226
|
+
// deployment and create the object anyway.
|
|
227
|
+
abortSignal?.throwIfAborted();
|
|
228
|
+
const result = method.apply(target, args);
|
|
229
|
+
if (!isThenable(result))
|
|
230
|
+
return result;
|
|
231
|
+
return raceDeadline(result, budgetMs, `${label} ${property}`, abortSignal);
|
|
232
|
+
};
|
|
233
|
+
wrapped.set(value, bound);
|
|
234
|
+
return bound;
|
|
235
|
+
},
|
|
236
|
+
});
|
|
237
|
+
}
|
|
78
238
|
//# sourceMappingURL=poll-timeout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poll-timeout.js","sourceRoot":"","sources":["../../../src/core/deployment/poll-timeout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,
|
|
1
|
+
{"version":3,"file":"poll-timeout.js","sourceRoot":"","sources":["../../../src/core/deployment/poll-timeout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;;;GASG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Y,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,IAAI,QAAQ,EAAE,EAAE,WAAW,CAAC,CAAC;YAC7E,CAAC,CAAC;YACF,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YAC1B,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import type { HttpLibrary, RequestContext, ResponseContext } from '@kubernetes/client-node/dist/gen/http/http.js';
|
|
15
15
|
import { type Observable } from '@kubernetes/client-node/dist/gen/rxjsStub.js';
|
|
16
|
+
import { RequestTimeoutError } from '../deployment/poll-timeout.js';
|
|
16
17
|
/**
|
|
17
18
|
* Configuration for HTTP request timeouts by operation type.
|
|
18
19
|
*
|
|
@@ -72,6 +73,29 @@ export interface AgentTlsOptions {
|
|
|
72
73
|
servername?: string;
|
|
73
74
|
ciphers?: string;
|
|
74
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* The transport dropped before the response was complete.
|
|
78
|
+
*
|
|
79
|
+
* WHY THIS TYPE EXISTS: a request whose socket dies mid-response must REJECT, and must reject as
|
|
80
|
+
* something callers already understand. It is modelled as a {@link RequestTimeoutError} because the
|
|
81
|
+
* caller's situation is identical to a timeout — the call did not return an answer — so gates that
|
|
82
|
+
* fail CLOSED on a wedged call (they must not read "no answer" as "nothing is there") keep working
|
|
83
|
+
* without knowing this class exists. `code` is `ECONNRESET` and the message contains
|
|
84
|
+
* `socket hang up`, the two shapes the transient/retryable classifiers already match on, so a
|
|
85
|
+
* retry loop treats it as the transient transport blip it usually is.
|
|
86
|
+
*
|
|
87
|
+
* NOTE ON `timeoutMs`: nothing here EXPIRED — the socket died with budget to spare, typically in
|
|
88
|
+
* milliseconds out of minutes. The inherited field therefore carries how long the request actually
|
|
89
|
+
* ran ({@link elapsedMs}), never the configured budget, so a log line or a retry heuristic reading
|
|
90
|
+
* it cannot conclude that the deadline was reached.
|
|
91
|
+
*/
|
|
92
|
+
export declare class PrematureCloseError extends RequestTimeoutError {
|
|
93
|
+
/** Node's system-error code for a peer-reset socket; transient-error classifiers match on it. */
|
|
94
|
+
readonly code: "ECONNRESET";
|
|
95
|
+
/** How long the request ran before the transport died. Same value as the inherited `timeoutMs`. */
|
|
96
|
+
readonly elapsedMs: number;
|
|
97
|
+
constructor(method: string, path: string, elapsedMs: number, phase: string, cause?: unknown);
|
|
98
|
+
}
|
|
75
99
|
/** Extract the TLS material KubeConfig placed on an https.Agent. */
|
|
76
100
|
export declare function extractAgentTlsOptions(agent: unknown): AgentTlsOptions;
|
|
77
101
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bun-http-library.d.ts","sourceRoot":"","sources":["../../../src/core/kubernetes/bun-http-library.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,eAAe,EAChB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,8CAA8C,CAAC;
|
|
1
|
+
{"version":3,"file":"bun-http-library.d.ts","sourceRoot":"","sources":["../../../src/core/kubernetes/bun-http-library.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,eAAe,EAChB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,8CAA8C,CAAC;AAOrF,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAGpE;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;IACH,MAAM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;IAyB5B,OAAO,CAAC,WAAW;CA2QpB;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,aAAa,CAAC,EAAE,iBAAiB,GAChC,WAAW,GAAG,SAAS,CAKzB;AAGD,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -15,7 +15,42 @@ import * as http from 'node:http';
|
|
|
15
15
|
import * as https from 'node:https';
|
|
16
16
|
import { from } from '@kubernetes/client-node/dist/gen/rxjsStub.js';
|
|
17
17
|
import { DEFAULT_HTTP_DELETE_TIMEOUT, DEFAULT_HTTP_READ_TIMEOUT, DEFAULT_HTTP_WATCH_TIMEOUT, DEFAULT_HTTP_WRITE_TIMEOUT, } from '../config/defaults.js';
|
|
18
|
+
import { RequestTimeoutError } from '../deployment/poll-timeout.js';
|
|
18
19
|
import { getComponentLogger } from '../logging/index.js';
|
|
20
|
+
/**
|
|
21
|
+
* The transport dropped before the response was complete.
|
|
22
|
+
*
|
|
23
|
+
* WHY THIS TYPE EXISTS: a request whose socket dies mid-response must REJECT, and must reject as
|
|
24
|
+
* something callers already understand. It is modelled as a {@link RequestTimeoutError} because the
|
|
25
|
+
* caller's situation is identical to a timeout — the call did not return an answer — so gates that
|
|
26
|
+
* fail CLOSED on a wedged call (they must not read "no answer" as "nothing is there") keep working
|
|
27
|
+
* without knowing this class exists. `code` is `ECONNRESET` and the message contains
|
|
28
|
+
* `socket hang up`, the two shapes the transient/retryable classifiers already match on, so a
|
|
29
|
+
* retry loop treats it as the transient transport blip it usually is.
|
|
30
|
+
*
|
|
31
|
+
* NOTE ON `timeoutMs`: nothing here EXPIRED — the socket died with budget to spare, typically in
|
|
32
|
+
* milliseconds out of minutes. The inherited field therefore carries how long the request actually
|
|
33
|
+
* ran ({@link elapsedMs}), never the configured budget, so a log line or a retry heuristic reading
|
|
34
|
+
* it cannot conclude that the deadline was reached.
|
|
35
|
+
*/
|
|
36
|
+
export class PrematureCloseError extends RequestTimeoutError {
|
|
37
|
+
/** Node's system-error code for a peer-reset socket; transient-error classifiers match on it. */
|
|
38
|
+
code = 'ECONNRESET';
|
|
39
|
+
/** How long the request ran before the transport died. Same value as the inherited `timeoutMs`. */
|
|
40
|
+
elapsedMs;
|
|
41
|
+
constructor(method, path, elapsedMs, phase, cause) {
|
|
42
|
+
super(`socket hang up: the connection closed before the response completed (${method} ${path}) — ${phase}.\n` +
|
|
43
|
+
`The connection lasted ${elapsedMs}ms; its budget had not expired.\n` +
|
|
44
|
+
(cause instanceof Error ? `Underlying transport error: ${cause.message}\n` : '') +
|
|
45
|
+
`\n` +
|
|
46
|
+
`The Kubernetes API server, or something between it and this client (load balancer, proxy, ` +
|
|
47
|
+
`NAT gateway), dropped the connection mid-flight. This is usually transient; retry.`, elapsedMs);
|
|
48
|
+
this.name = 'PrematureCloseError';
|
|
49
|
+
this.elapsedMs = elapsedMs;
|
|
50
|
+
if (cause !== undefined)
|
|
51
|
+
this.cause = cause;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
19
54
|
/** Extract the TLS material KubeConfig placed on an https.Agent. */
|
|
20
55
|
export function extractAgentTlsOptions(agent) {
|
|
21
56
|
return agent && typeof agent === 'object' && 'options' in agent
|
|
@@ -155,13 +190,45 @@ export class BunCompatibleHttpLibrary {
|
|
|
155
190
|
timeoutId = undefined;
|
|
156
191
|
}
|
|
157
192
|
};
|
|
193
|
+
// Detaching the abort listener, if one was attached. Assigned when the signal is wired up
|
|
194
|
+
// below; a no-op until then, so the latch can always call it.
|
|
195
|
+
let detachAbort = () => undefined;
|
|
196
|
+
// EVERY terminal path goes through here, and the FIRST one wins. Resolve/reject are latched so
|
|
197
|
+
// a socket teardown that emits several events in a row (`aborted`, then `error`, then `close`)
|
|
198
|
+
// cannot settle twice, and — the bug this guards — so no path can disarm the timer WITHOUT
|
|
199
|
+
// settling. Clearing the timer is the guard's job alone; nothing else touches it. Releasing the
|
|
200
|
+
// abort listener belongs here for the same reason: it is per-request state on a signal that
|
|
201
|
+
// usually OUTLIVES the request.
|
|
202
|
+
let settled = false;
|
|
203
|
+
const settle = (finish) => {
|
|
204
|
+
if (settled)
|
|
205
|
+
return;
|
|
206
|
+
settled = true;
|
|
207
|
+
clearRequestTimeout();
|
|
208
|
+
detachAbort();
|
|
209
|
+
finish();
|
|
210
|
+
};
|
|
211
|
+
// Bun's `node:http` emits the REQUEST's 'close' as soon as the response headers arrive, long
|
|
212
|
+
// before the body is done (Node emits it after the exchange ends). So 'close' on the request
|
|
213
|
+
// only means "the exchange ended" while no response has begun; once one has, the response's own
|
|
214
|
+
// terminal events are what tell us whether it completed.
|
|
215
|
+
let responseStarted = false;
|
|
216
|
+
// The elapsed time, not the budget: a premature close happens with budget to spare, and the
|
|
217
|
+
// error must not read as "the deadline was reached". See {@link PrematureCloseError}.
|
|
218
|
+
const issuedAt = Date.now();
|
|
219
|
+
const failPrematureClose = (phase, cause) => settle(() => reject(new PrematureCloseError(method, url.pathname, Date.now() - issuedAt, phase, cause)));
|
|
158
220
|
const req = httpModule.request(options, (res) => {
|
|
221
|
+
responseStarted = true;
|
|
159
222
|
const chunks = [];
|
|
160
223
|
res.on('data', (chunk) => {
|
|
161
224
|
chunks.push(chunk);
|
|
162
225
|
});
|
|
226
|
+
// The socket died with the body half-delivered. Unhandled, these leave the promise pending
|
|
227
|
+
// FOREVER: 'end' never fires, and the request's 'error' does not fire either.
|
|
228
|
+
res.on('aborted', () => failPrematureClose('the response body was truncated'));
|
|
229
|
+
res.on('error', (err) => failPrematureClose('the response stream failed', err));
|
|
230
|
+
res.on('close', () => failPrematureClose('the response stream closed before it ended'));
|
|
163
231
|
res.on('end', () => {
|
|
164
|
-
clearRequestTimeout();
|
|
165
232
|
const buffer = Buffer.concat(chunks);
|
|
166
233
|
const responseHeaders = {};
|
|
167
234
|
// Convert headers to simple object
|
|
@@ -196,12 +263,11 @@ export class BunCompatibleHttpLibrary {
|
|
|
196
263
|
}
|
|
197
264
|
},
|
|
198
265
|
};
|
|
199
|
-
resolve(response);
|
|
266
|
+
settle(() => resolve(response));
|
|
200
267
|
});
|
|
201
268
|
});
|
|
202
269
|
req.on('error', (err) => {
|
|
203
|
-
|
|
204
|
-
reject(err);
|
|
270
|
+
settle(() => reject(err));
|
|
205
271
|
});
|
|
206
272
|
req.on('socket', (socket) => {
|
|
207
273
|
// Prevent idle client sockets from keeping short-lived CLI processes alive.
|
|
@@ -215,8 +281,11 @@ export class BunCompatibleHttpLibrary {
|
|
|
215
281
|
// Watch operations are handled by the API server via timeoutSeconds parameter
|
|
216
282
|
if (shouldSetTimeout) {
|
|
217
283
|
timeoutId = setTimeout(() => {
|
|
218
|
-
|
|
219
|
-
|
|
284
|
+
// A TYPED timeout (not a bare Error): this timer is armed synchronously as the request is
|
|
285
|
+
// issued, so with equal budgets it fires BEFORE any deadline wrapper around the call and
|
|
286
|
+
// is the error a caller actually sees. A gate that fails open on ordinary failures must be
|
|
287
|
+
// able to tell this apart from "the object does not exist". See `isRequestTimeoutError`.
|
|
288
|
+
const timeoutError = new RequestTimeoutError(`HTTP request timeout: ${method} ${url.pathname} timed out after ${timeoutMs}ms\n` +
|
|
220
289
|
`URL: ${url.toString()}\n` +
|
|
221
290
|
`\n` +
|
|
222
291
|
`💡 Possible causes:\n` +
|
|
@@ -229,29 +298,87 @@ export class BunCompatibleHttpLibrary {
|
|
|
229
298
|
` • Verify Kubernetes API server is running: kubectl cluster-info\n` +
|
|
230
299
|
` • Check webhook status: kubectl get validatingwebhookconfigurations\n` +
|
|
231
300
|
` • Increase timeout via httpTimeouts option if needed\n` +
|
|
232
|
-
` • For watch operations: timeouts are disabled (API server controls via timeoutSeconds)
|
|
233
|
-
|
|
301
|
+
` • For watch operations: timeouts are disabled (API server controls via timeoutSeconds)`, timeoutMs);
|
|
302
|
+
// Settle BEFORE tearing the socket down: `req.destroy()` emits 'error'/'close', and the
|
|
303
|
+
// caller must see the timeout — not the ECONNRESET our own abort produced. The latch makes
|
|
304
|
+
// that teardown a no-op.
|
|
305
|
+
settle(() => reject(timeoutError));
|
|
306
|
+
req.destroy();
|
|
234
307
|
}, timeoutMs);
|
|
308
|
+
// Belt and braces for the pre-connect phase. The wall-clock timer above is armed
|
|
309
|
+
// synchronously, so it already covers a DNS or TCP/TLS connect that never completes — but it
|
|
310
|
+
// can only bound the caller's `await`; it cannot guarantee the runtime actually releases a
|
|
311
|
+
// socket still stuck in connect. `setTimeout` on the request tears that socket down from the
|
|
312
|
+
// inside. It is an IDLE timer, so on a live connection it can never fire before the wall
|
|
313
|
+
// clock, which means it never shortens a legitimately slow request.
|
|
314
|
+
req.setTimeout(timeoutMs, () => {
|
|
315
|
+
req.destroy();
|
|
316
|
+
});
|
|
235
317
|
}
|
|
236
318
|
// Handle abort signal (if available - added in newer versions).
|
|
237
|
-
//
|
|
238
|
-
//
|
|
319
|
+
//
|
|
320
|
+
// `{ once: true }` alone is NOT enough to bound the listener's lifetime: it removes the
|
|
321
|
+
// listener when the event FIRES, and the overwhelmingly common case is that it never fires
|
|
322
|
+
// because the request succeeded. A caller's signal typically spans a whole converge — hundreds
|
|
323
|
+
// of requests — so every completed request left its closure (and the `req` it captures)
|
|
324
|
+
// attached, growing the signal's listener list for the life of the operation. Detaching is
|
|
325
|
+
// therefore done by the latch, which every terminal path goes through, with `{ once: true }`
|
|
326
|
+
// kept as belt and braces for the firing case.
|
|
239
327
|
const getSignal = Reflect.get(request, 'getSignal');
|
|
240
328
|
const signal = getSignal?.();
|
|
241
329
|
if (signal) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
req.destroy(
|
|
245
|
-
}
|
|
330
|
+
const onAbort = () => {
|
|
331
|
+
settle(() => reject(signal.reason ?? new Error('Request aborted')));
|
|
332
|
+
req.destroy();
|
|
333
|
+
};
|
|
334
|
+
// An ALREADY-aborted signal never fires 'abort' again, so a listener alone silently misses
|
|
335
|
+
// it and the request goes out anyway — the exact opposite of what the caller asked for.
|
|
336
|
+
// A signal is routinely already aborted by the time a request is issued: a converge-wide
|
|
337
|
+
// signal trips while an earlier call is in flight, and the next call in the queue is built
|
|
338
|
+
// against it. Reject up front and tear the half-built request down BEFORE `req.end()` puts
|
|
339
|
+
// any bytes on the wire.
|
|
340
|
+
if (signal.aborted) {
|
|
341
|
+
settle(() => reject(signal.reason ?? new DOMException('The operation was aborted', 'AbortError')));
|
|
342
|
+
req.destroy();
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
346
|
+
detachAbort = () => signal.removeEventListener('abort', onAbort);
|
|
347
|
+
}
|
|
246
348
|
}
|
|
349
|
+
// The request ended without the promise having settled. On Bun this fires as soon as the
|
|
350
|
+
// response headers land, so it is only terminal while NO response has started; after that the
|
|
351
|
+
// response's own 'aborted'/'error'/'close' are the terminal events. Either way the timer stays
|
|
352
|
+
// armed until something settles — clearing it here WITHOUT settling was the hang.
|
|
247
353
|
req.on('close', () => {
|
|
248
|
-
|
|
354
|
+
if (responseStarted)
|
|
355
|
+
return;
|
|
356
|
+
failPrematureClose('the socket closed before any response was received');
|
|
249
357
|
});
|
|
250
|
-
// Send body if present
|
|
251
|
-
|
|
252
|
-
|
|
358
|
+
// Send body if present.
|
|
359
|
+
//
|
|
360
|
+
// These can throw SYNCHRONOUSLY — `write` rejects a body that is not a string or Buffer with
|
|
361
|
+
// ERR_INVALID_ARG_TYPE, for instance. A throw here escapes the Promise executor, which rejects
|
|
362
|
+
// the promise for us but does NOT run the latch, so the timer would stay armed and hold a
|
|
363
|
+
// short-lived CLI process open for its whole budget after the call had already failed. Route
|
|
364
|
+
// it through the latch instead, and tear the half-issued request down.
|
|
365
|
+
//
|
|
366
|
+
// A signal that was ALREADY aborted has settled the promise and destroyed the request above;
|
|
367
|
+
// there is nothing left to send, and writing to a destroyed request would only raise a
|
|
368
|
+
// spurious ERR_STREAM_DESTROYED. Returning here is also what keeps the promise's contract
|
|
369
|
+
// honest: the server never sees a request the caller had already cancelled.
|
|
370
|
+
if (settled)
|
|
371
|
+
return;
|
|
372
|
+
try {
|
|
373
|
+
if (body) {
|
|
374
|
+
req.write(body);
|
|
375
|
+
}
|
|
376
|
+
req.end();
|
|
377
|
+
}
|
|
378
|
+
catch (err) {
|
|
379
|
+
settle(() => reject(err));
|
|
380
|
+
req.destroy();
|
|
253
381
|
}
|
|
254
|
-
req.end();
|
|
255
382
|
});
|
|
256
383
|
}
|
|
257
384
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bun-http-library.js","sourceRoot":"","sources":["../../../src/core/kubernetes/bun-http-library.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AAMpC,OAAO,EAAE,IAAI,EAAmB,MAAM,8CAA8C,CAAC;AACrF,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAmEzD,oEAAoE;AACpE,MAAM,UAAU,sBAAsB,CAAC,KAAc;IACnD,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,SAAS,IAAI,KAAK;QAC7D,CAAC,CAAE,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAqB;QACpD,CAAC,CAAC,EAAE,CAAC;AACT,CAAC;AAED;;;GAGG;AACH,MAAM,gBAAgB,GAAgC;IACpD,OAAO,EAAE,yBAAyB;IAClC,KAAK,EAAE,0BAA0B,EAAE,qEAAqE;IACxG,MAAM,EAAE,0BAA0B,EAAE,6CAA6C;IACjF,MAAM,EAAE,0BAA0B,EAAE,6CAA6C;IACjF,MAAM,EAAE,2BAA2B,EAAE,8CAA8C;CACpF,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,OAAO,GAAG,KAAK,WAAW,CAAC;AACpC,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B,CAAC;gBACD,GAAG,CAAC,GAAG,EAAE,CAAC;YACZ,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC1B,GAAG,CAAC,OAAO,EAAE,CAAC;YAChB,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,wBAAwB,CACtC,aAAiC;IAEjC,IAAI,YAAY,EAAE,EAAE,CAAC;QACnB,OAAO,IAAI,wBAAwB,CAAC,aAAa,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -95,6 +95,15 @@ export declare function isNotFoundError(error: unknown): boolean;
|
|
|
95
95
|
* ```
|
|
96
96
|
*/
|
|
97
97
|
export declare function isConflictError(error: unknown): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* HTTP status codes that are typically retryable.
|
|
100
|
+
* These indicate temporary issues that may resolve on retry.
|
|
101
|
+
*
|
|
102
|
+
* @internal Exported so the read-error classifier in `../deployment/k8s-helpers.ts` can answer
|
|
103
|
+
* "is this status transient?" from this one list rather than keeping a second copy that could
|
|
104
|
+
* drift from it.
|
|
105
|
+
*/
|
|
106
|
+
export declare const RETRYABLE_STATUS_CODES: ReadonlySet<number>;
|
|
98
107
|
/**
|
|
99
108
|
* Check if an error is retryable.
|
|
100
109
|
*
|