@calltelemetry/fmix 2.7.16 → 2.7.17
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/bin/fmix +117 -1
- package/package.json +3 -3
package/bin/fmix
CHANGED
|
@@ -25,7 +25,7 @@ set -uo pipefail
|
|
|
25
25
|
# ---------------------------------------------------------------------------
|
|
26
26
|
# Constants & config
|
|
27
27
|
# ---------------------------------------------------------------------------
|
|
28
|
-
FMIX_VERSION="2.7.
|
|
28
|
+
FMIX_VERSION="2.7.17"
|
|
29
29
|
FMIX_HOME="${FMIX_HOME:-${HOME}/.ct-fmix}"
|
|
30
30
|
FMIX_OS="$(uname -s)"
|
|
31
31
|
FMIX_ARCH="$(uname -m)"
|
|
@@ -14822,6 +14822,102 @@ fmix_wait_infra() {
|
|
|
14822
14822
|
return 1
|
|
14823
14823
|
}
|
|
14824
14824
|
|
|
14825
|
+
fmix_infra_capacity_bytes() {
|
|
14826
|
+
local py_bin
|
|
14827
|
+
py_bin="$(fmix_python_bin)" || return 1
|
|
14828
|
+
"$py_bin" - <<'PY'
|
|
14829
|
+
import json
|
|
14830
|
+
import os
|
|
14831
|
+
import platform
|
|
14832
|
+
import subprocess
|
|
14833
|
+
import sys
|
|
14834
|
+
|
|
14835
|
+
def probe(*args):
|
|
14836
|
+
result = subprocess.run(args, capture_output=True, text=True, timeout=5)
|
|
14837
|
+
if result.returncode or len(result.stdout) > 1024 * 1024:
|
|
14838
|
+
raise ValueError("incomplete native observation")
|
|
14839
|
+
return result.stdout.strip()
|
|
14840
|
+
|
|
14841
|
+
try:
|
|
14842
|
+
# DOCKER_CONTEXT takes precedence over DOCKER_HOST. Never use a local
|
|
14843
|
+
# capacity reading to admit allocation on an unobserved remote daemon.
|
|
14844
|
+
context = os.environ.get("DOCKER_CONTEXT", "")
|
|
14845
|
+
host = os.environ.get("DOCKER_HOST", "")
|
|
14846
|
+
if context:
|
|
14847
|
+
if context.startswith("-"):
|
|
14848
|
+
raise ValueError("invalid context")
|
|
14849
|
+
host = json.loads(probe("docker", "context", "inspect", "--format",
|
|
14850
|
+
"{{json .Endpoints.docker.Host}}", context))
|
|
14851
|
+
elif not host:
|
|
14852
|
+
host = json.loads(probe("docker", "context", "inspect", "--format",
|
|
14853
|
+
"{{json .Endpoints.docker.Host}}"))
|
|
14854
|
+
if not isinstance(host, str) or not host.startswith("unix:///"):
|
|
14855
|
+
raise ValueError("unobserved remote storage")
|
|
14856
|
+
|
|
14857
|
+
if platform.system() == "Darwin":
|
|
14858
|
+
if not host.endswith("/.orbstack/run/docker.sock"):
|
|
14859
|
+
raise ValueError("unobserved macOS Docker storage")
|
|
14860
|
+
# Discover the *open* backing image rather than assuming its default
|
|
14861
|
+
# path: OrbStack can place data on a different filesystem. Only read
|
|
14862
|
+
# native descriptor metadata; do not traverse protected app storage.
|
|
14863
|
+
raw = probe("lsof", "-nP", "-a", "-u", str(os.getuid()),
|
|
14864
|
+
"-c", "OrbStack", "-Fn")
|
|
14865
|
+
paths = {line[1:] for line in raw.splitlines()
|
|
14866
|
+
if line.startswith("n/") and line.endswith("/data.img.raw")}
|
|
14867
|
+
if len(paths) != 1:
|
|
14868
|
+
raise ValueError("ambiguous or unavailable Docker backing storage")
|
|
14869
|
+
anchor = paths.pop()
|
|
14870
|
+
elif platform.system() == "Linux":
|
|
14871
|
+
anchor = json.loads(probe("docker", "info", "--format", "{{json .DockerRootDir}}"))
|
|
14872
|
+
if not isinstance(anchor, str) or not os.path.isabs(anchor):
|
|
14873
|
+
raise ValueError("unavailable Docker storage root")
|
|
14874
|
+
else:
|
|
14875
|
+
raise ValueError("unsupported native storage observation")
|
|
14876
|
+
before = os.stat(anchor)
|
|
14877
|
+
capacity = os.statvfs(anchor)
|
|
14878
|
+
after = os.stat(anchor)
|
|
14879
|
+
if (before.st_dev, before.st_ino) != (after.st_dev, after.st_ino):
|
|
14880
|
+
raise ValueError("storage identity changed")
|
|
14881
|
+
free = capacity.f_bavail * capacity.f_frsize
|
|
14882
|
+
total = capacity.f_blocks * capacity.f_frsize
|
|
14883
|
+
if not 0 <= free <= total < 10**18 or total == 0:
|
|
14884
|
+
raise ValueError("invalid native capacity")
|
|
14885
|
+
print(f"{free} {total}")
|
|
14886
|
+
except Exception:
|
|
14887
|
+
print("[fmix] Docker storage capacity unavailable; refusing cold infrastructure allocation.",
|
|
14888
|
+
file=sys.stderr)
|
|
14889
|
+
sys.exit(1)
|
|
14890
|
+
PY
|
|
14891
|
+
}
|
|
14892
|
+
|
|
14893
|
+
fmix_infra_has_headroom() {
|
|
14894
|
+
# An 8 decimal GB cold-start allowance covers the observed post-reset
|
|
14895
|
+
# image/cache refill. This is admission, not an OS quota or a reservation
|
|
14896
|
+
# against nonparticipating Docker clients. No public bypass/override.
|
|
14897
|
+
local capacity free total floor reserve=8000000000
|
|
14898
|
+
capacity="$(fmix_infra_capacity_bytes)" || {
|
|
14899
|
+
fmix_error "Docker disk capacity is unknown; holding infrastructure startup."
|
|
14900
|
+
return 75
|
|
14901
|
+
}
|
|
14902
|
+
if [[ ! "$capacity" =~ ^[0-9]{1,18}[[:blank:]][0-9]{1,18}$ ]]; then
|
|
14903
|
+
fmix_error "Invalid Docker disk capacity; holding infrastructure startup."
|
|
14904
|
+
return 75
|
|
14905
|
+
fi
|
|
14906
|
+
read -r free total <<<"$capacity"
|
|
14907
|
+
free=$((10#$free))
|
|
14908
|
+
total=$((10#$total))
|
|
14909
|
+
if (( total <= 0 || free > total )); then
|
|
14910
|
+
fmix_error "Invalid Docker disk capacity; holding infrastructure startup."
|
|
14911
|
+
return 75
|
|
14912
|
+
fi
|
|
14913
|
+
floor=$(( total / 20 ))
|
|
14914
|
+
(( floor <= 100000000000 )) || floor=100000000000
|
|
14915
|
+
if (( free < reserve || free - reserve < floor )); then
|
|
14916
|
+
fmix_error "Docker disk pressure: free=${free}B, startup allowance=${reserve}B, retained floor=${floor}B. Holding startup; reuse ready infrastructure or reclaim through its owner."
|
|
14917
|
+
return 75
|
|
14918
|
+
fi
|
|
14919
|
+
}
|
|
14920
|
+
|
|
14825
14921
|
fmix_ensure_infra() {
|
|
14826
14922
|
if fmix_infra_ready; then
|
|
14827
14923
|
echo " [OK] infra ready postgres $DB_HOST:$DB_PORT nats $NATS_HOST:$NATS_PORT"
|
|
@@ -14848,12 +14944,32 @@ fmix_ensure_infra() {
|
|
|
14848
14944
|
return 1
|
|
14849
14945
|
fi
|
|
14850
14946
|
|
|
14947
|
+
# Coalesce concurrent callers after an engine reset. The native lease is
|
|
14948
|
+
# held through readiness and admission; never force another owner's lock.
|
|
14949
|
+
local lock_name="infra-ensure" startup_rc=0
|
|
14950
|
+
fmix_lock_acquire "$lock_name" "$FMIX_ENSURE_TIMEOUT" "shared infrastructure startup" || return 1
|
|
14951
|
+
fmix_ensure_infra_locked || startup_rc=$?
|
|
14952
|
+
if ! fmix_lock_release "$lock_name"; then
|
|
14953
|
+
fmix_error "Infrastructure startup lease release failed."
|
|
14954
|
+
return 1
|
|
14955
|
+
fi
|
|
14956
|
+
return "$startup_rc"
|
|
14957
|
+
}
|
|
14958
|
+
|
|
14959
|
+
fmix_ensure_infra_locked() {
|
|
14960
|
+
if fmix_infra_ready; then
|
|
14961
|
+
echo " [OK] infra ready postgres $DB_HOST:$DB_PORT nats $NATS_HOST:$NATS_PORT"
|
|
14962
|
+
return 0
|
|
14963
|
+
fi
|
|
14964
|
+
fmix_infra_has_headroom || return 75
|
|
14851
14965
|
echo " starting shared $FMIX_INFRA_PROJECT (postgres + nats)..."
|
|
14852
14966
|
fmix_start_existing_ct_infra || true
|
|
14853
14967
|
if fmix_wait_infra; then
|
|
14854
14968
|
echo " [OK] infra ready postgres $DB_HOST:$DB_PORT nats $NATS_HOST:$NATS_PORT"
|
|
14855
14969
|
return 0
|
|
14856
14970
|
fi
|
|
14971
|
+
# Another producer may allocate while existing services are warming.
|
|
14972
|
+
fmix_infra_has_headroom || return 75
|
|
14857
14973
|
if ! fmix_compose_up_ensure; then
|
|
14858
14974
|
fmix_error "docker compose could not start $FMIX_INFRA_PROJECT postgres/nats"
|
|
14859
14975
|
return 1
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@calltelemetry/fmix",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.17",
|
|
4
4
|
"description": "Verified native FMix runner for CallTelemetry workspaces",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"directory": "packages/npm"
|
|
27
27
|
},
|
|
28
28
|
"fmix": {
|
|
29
|
-
"runnerSha256": "
|
|
30
|
-
"sourceTag": "fmix-v2.7.
|
|
29
|
+
"runnerSha256": "66448f9a223caab18e7273ebdfb8544d055a1ff772096860be46d73bc4af5ee6",
|
|
30
|
+
"sourceTag": "fmix-v2.7.17"
|
|
31
31
|
}
|
|
32
32
|
}
|