@xrystal/core 3.55.65 → 3.55.66
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/README.md
CHANGED
|
@@ -263,7 +263,7 @@ bun run dev
|
|
|
263
263
|
|
|
264
264
|
**TR:** `x/environments/*` yalnızca lokal dev + Telepresence. Image'a gömme. Cluster'da Secret inject; runtime dosya okumaz.
|
|
265
265
|
|
|
266
|
-
**Infra preflight:** Before Kafka/Redis/Mongo connect,
|
|
266
|
+
**Infra preflight:** Before Kafka/Redis/Mongo connect, TCP checks from tmp.yml + env. **Default fail-fast** in cluster and plain local dev. **Telepresence intercept** (pod env on laptop, no service-account token): lenient by default + 2s probe — override with `STRICT_INFRA_PREFLIGHT=1`.
|
|
267
267
|
|
|
268
268
|
**Docker / Compose:** Image `CMD ["bun", "xry", "start"]` (dev: `xry dev`). Runtime skips `x/environments` when `/.dockerenv` or k8s is detected (optional override: `XRY_RUNTIME=container|docker|k8s`). Compose: `env_file:` on `x/docker/docker-compose*.yml` — not `COPY` env into the image.
|
|
269
269
|
| `xry test` | Run `x/tests` | `x/tests` çalıştır |
|
package/package.json
CHANGED
|
@@ -19,6 +19,8 @@ type PreflightRow = {
|
|
|
19
19
|
result: 'OK' | 'UNREACHABLE' | 'CONFIG' | 'INVALID';
|
|
20
20
|
detail?: string;
|
|
21
21
|
};
|
|
22
|
+
/** True only inside a real pod (not Telepresence env dump on the laptop). */
|
|
23
|
+
export declare function isInKubernetesPod(): boolean;
|
|
22
24
|
export type PreflightReportMeta = {
|
|
23
25
|
atUtc: string;
|
|
24
26
|
runtime: string;
|
|
@@ -43,7 +45,7 @@ export declare class InfraPreflightFailed extends Error {
|
|
|
43
45
|
/** Strict fail: one report on stderr, then InfraPreflightFailed (no duplicate stack). */
|
|
44
46
|
export declare function abortInfraPreflight(report: string): never;
|
|
45
47
|
export declare function resolveProbeTimeoutMs(): number;
|
|
46
|
-
/** Default: fail-fast
|
|
48
|
+
/** Default: fail-fast in cluster and plain local dev; lenient for Telepresence intercept env on laptop. */
|
|
47
49
|
export declare function isStrictInfraPreflight(): boolean;
|
|
48
50
|
/** Default: same fast TCP probe everywhere (local, Docker, Kubernetes). Opt out: INFRA_PREFLIGHT_TCP=0. */
|
|
49
51
|
export declare function shouldTcpProbeInfraPreflight(): boolean;
|
|
@@ -8,7 +8,22 @@ import { isInfraLoaderEnabled, resolveLoaderBootPlan, } from '../../../utils/hel
|
|
|
8
8
|
import { resolveTmpRuntimeConfigs } from '../../../utils/helpers/tmp/tmp-schema.js';
|
|
9
9
|
import { getTmpSnapshot } from '../../../utils/helpers/tmp/tmp-loader.js';
|
|
10
10
|
const DEFAULT_PROBE_TIMEOUT_MS = 500;
|
|
11
|
+
const TELEPRESENCE_LOCAL_PROBE_TIMEOUT_MS = 2000;
|
|
11
12
|
const RULE = '─'.repeat(72);
|
|
13
|
+
/** True only inside a real pod (not Telepresence env dump on the laptop). */
|
|
14
|
+
export function isInKubernetesPod() {
|
|
15
|
+
if (!(process.env.KUBERNETES_SERVICE_HOST ?? '').trim())
|
|
16
|
+
return false;
|
|
17
|
+
try {
|
|
18
|
+
return fs.existsSync('/var/run/secrets/kubernetes.io/serviceaccount/token');
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function isTelepresenceLocalEnv() {
|
|
25
|
+
return Boolean((process.env.KUBERNETES_SERVICE_HOST ?? '').trim()) && !isInKubernetesPod();
|
|
26
|
+
}
|
|
12
27
|
function resolveInstalledCoreVersion() {
|
|
13
28
|
try {
|
|
14
29
|
const pkgPath = require.resolve('@xrystal/core/package.json');
|
|
@@ -20,12 +35,18 @@ function resolveInstalledCoreVersion() {
|
|
|
20
35
|
}
|
|
21
36
|
}
|
|
22
37
|
function resolveRuntimeLabel() {
|
|
23
|
-
if (
|
|
38
|
+
if (isInKubernetesPod()) {
|
|
24
39
|
return {
|
|
25
40
|
label: 'kubernetes',
|
|
26
41
|
detect: 'KUBERNETES_SERVICE_HOST (kubelet-injected)',
|
|
27
42
|
};
|
|
28
43
|
}
|
|
44
|
+
if (isTelepresenceLocalEnv()) {
|
|
45
|
+
return {
|
|
46
|
+
label: 'local-telepresence',
|
|
47
|
+
detect: 'KUBERNETES_SERVICE_HOST from intercept env-file (not in pod)',
|
|
48
|
+
};
|
|
49
|
+
}
|
|
29
50
|
try {
|
|
30
51
|
if (fs.existsSync('/.dockerenv')) {
|
|
31
52
|
return { label: 'docker', detect: '/.dockerenv' };
|
|
@@ -68,20 +89,27 @@ export function abortInfraPreflight(report) {
|
|
|
68
89
|
}
|
|
69
90
|
export function resolveProbeTimeoutMs() {
|
|
70
91
|
const raw = (process.env.INFRA_PREFLIGHT_TIMEOUT_MS ?? '').trim();
|
|
71
|
-
if (!raw)
|
|
92
|
+
if (!raw) {
|
|
93
|
+
if (isTelepresenceLocalEnv())
|
|
94
|
+
return TELEPRESENCE_LOCAL_PROBE_TIMEOUT_MS;
|
|
72
95
|
return DEFAULT_PROBE_TIMEOUT_MS;
|
|
96
|
+
}
|
|
73
97
|
const n = Number.parseInt(raw, 10);
|
|
74
98
|
if (!Number.isFinite(n) || n < 100)
|
|
75
99
|
return DEFAULT_PROBE_TIMEOUT_MS;
|
|
76
100
|
return Math.min(n, 5000);
|
|
77
101
|
}
|
|
78
|
-
/** Default: fail-fast
|
|
102
|
+
/** Default: fail-fast in cluster and plain local dev; lenient for Telepresence intercept env on laptop. */
|
|
79
103
|
export function isStrictInfraPreflight() {
|
|
80
104
|
const raw = (process.env.STRICT_INFRA_PREFLIGHT ?? '').trim().toLowerCase();
|
|
81
|
-
if (
|
|
105
|
+
if (raw === '1' || raw === 'true' || raw === 'yes' || raw === 'on')
|
|
82
106
|
return true;
|
|
83
107
|
if (raw === '0' || raw === 'false' || raw === 'no' || raw === 'off')
|
|
84
108
|
return false;
|
|
109
|
+
if (isInKubernetesPod())
|
|
110
|
+
return true;
|
|
111
|
+
if (isTelepresenceLocalEnv())
|
|
112
|
+
return false;
|
|
85
113
|
return true;
|
|
86
114
|
}
|
|
87
115
|
/** Default: same fast TCP probe everywhere (local, Docker, Kubernetes). Opt out: INFRA_PREFLIGHT_TCP=0. */
|
|
@@ -92,7 +120,10 @@ export function shouldTcpProbeInfraPreflight() {
|
|
|
92
120
|
return true;
|
|
93
121
|
}
|
|
94
122
|
function runtimeContextHint() {
|
|
95
|
-
if (
|
|
123
|
+
if (isTelepresenceLocalEnv()) {
|
|
124
|
+
return 'Telepresence local: env from pod; TCP from laptop (Tailscale/VPN). Lenient preflight default — set STRICT_INFRA_PREFLIGHT=1 to fail-fast.';
|
|
125
|
+
}
|
|
126
|
+
if (isInKubernetesPod()) {
|
|
96
127
|
if (!shouldTcpProbeInfraPreflight()) {
|
|
97
128
|
return 'Kubernetes: TCP preflight disabled (INFRA_PREFLIGHT_TCP=0). Config-only check.';
|
|
98
129
|
}
|