Author SHA1 Message Date
Pavlo Ratushnyi bbc8018e8b Bound runtime image probe waits and cleanup
Linux / keyless-cuda-gate (pull_request) Skipped
Desktop foundation / core (ubuntu-latest) (pull_request) Successful in 2m50s
Linux / verify (pull_request) Successful in 6m33s
Linux / keyless-cuda (pull_request) Skipped
Linux / static-cuda-package (pull_request) Skipped
Linux / hosted-cuda-package (pull_request) Skipped
Linux / linux-cli-container (pull_request) Successful in 1m34s
Linux / linux-static-cli (pull_request) Successful in 6m26s
Linux / release-cli (pull_request) Skipped
2026-10-08 00:53:28 +02:00
Pavlo Ratushnyi d7d24c7401 test: preserve container smoke failures on cleanup 2026-10-08 00:34:59 +02:00
Pavlo Ratushnyi fb3ce6e8c5 STRA-13: isolate CLI container gate image ownership
Build the CLI container gate with a run and attempt tag plus a nonce owner label, capture and validate its immutable image ID, and pass that ID to the smoke check. Limit cleanup to the validated owned image and temporary receipt without parent pruning, preserving all other workflow gates.
2026-10-08 00:33:41 +02:00
Pavlo Ratushnyi 63a56772da test: bound CLI container startup wait 2026-10-08 00:30:54 +02:00
Pavlo Ratushnyi b848e433a3 STRA-13: align desktop CI Rust helper target
Linux / keyless-cuda-gate (pull_request) Skipped
Desktop foundation / core (ubuntu-latest) (pull_request) Successful in 2m54s
Linux / keyless-cuda (pull_request) Skipped
Linux / static-cuda-package (pull_request) Skipped
Linux / verify (pull_request) Successful in 7m2s
Linux / hosted-cuda-package (pull_request) Skipped
Linux / linux-cli-container (pull_request) Successful in 29s
Linux / linux-static-cli (pull_request) Successful in 5m16s
Linux / release-cli (pull_request) Skipped
Set the desktop job target directory to desktop-core/target so workspace Rust builds produce the helper at the existing .NET and Python consumer paths. Preserve all workflow checks and event routing.
2026-10-08 00:25:07 +02:00
Pavlo Ratushnyi 3aea854d41 fix(ci): route desktop gates to Linux with pinned Rust bootstrap
Linux / keyless-cuda-gate (pull_request) Skipped
Desktop foundation / core (ubuntu-latest) (pull_request) Failing after 2m57s
Linux / verify (pull_request) Successful in 7m4s
Linux / keyless-cuda (pull_request) Skipped
Linux / static-cuda-package (pull_request) Skipped
Linux / hosted-cuda-package (pull_request) Skipped
Linux / linux-cli-container (pull_request) Successful in 4m6s
Linux / linux-static-cli (pull_request) Successful in 8m27s
Linux / release-cli (pull_request) Skipped
2026-10-08 00:00:59 +02:00
5 changed files with 338 additions and 12 deletions
+12 -3
View File
@@ -1,20 +1,29 @@
name: Desktop foundation
on:
push:
paths: ['desktop-core/**', 'desktop/**', '.github/workflows/desktop.yml', 'rust-toolchain.toml']
# Main pushes exclude CLI release tags; feature branches use pull requests.
branches: [main]
paths: ['desktop-core/**', 'desktop/**', '.github/workflows/desktop.yml', 'rust-toolchain.toml', 'scripts/install-pinned-rustup.sh', 'Cargo.toml', 'Cargo.lock']
pull_request:
paths: ['desktop-core/**', 'desktop/**', '.github/workflows/desktop.yml', 'rust-toolchain.toml']
paths: ['desktop-core/**', 'desktop/**', '.github/workflows/desktop.yml', 'rust-toolchain.toml', 'scripts/install-pinned-rustup.sh', 'Cargo.toml', 'Cargo.lock']
permissions:
contents: read
jobs:
core:
env:
CARGO_TARGET_DIR: ${{ github.workspace }}/desktop-core/target
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
# Windows/macOS validation is deferred and unqualified.
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Linux build tools
run: apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates build-essential python3 python-is-python3
- name: Install pinned Rust
run: scripts/install-pinned-rustup.sh rustup toolchain install 1.99.0 --profile minimal --component rustfmt --component clippy
- name: Format
run: cargo fmt --manifest-path desktop-core/Cargo.toml --check
- name: Tests
+32 -3
View File
@@ -481,12 +481,41 @@ jobs:
command -v docker >/dev/null 2>&1 || { apt-get update -qq; DEBIAN_FRONTEND=noninteractive apt-get install -y -qq docker.io; }
docker version
- name: Build actual CLI-only scratch image
run: docker build --file deploy/Dockerfile.static-cli --tag strata-cli-check .
run: |
set -euo pipefail
owned_dir="$(mktemp -d "$RUNNER_TEMP/leleka-cli-check-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}-XXXXXX")"
image_tag="leleka-cli-check:${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}-${owned_dir##*-}"
printf '%s\n' "CLI_CHECK_DIR=$owned_dir" "CLI_CHECK_TAG=$image_tag" >> "$GITHUB_ENV"
# The nonce label makes identical builds distinct image configs on the shared daemon.
docker build --file deploy/Dockerfile.static-cli --tag "$image_tag" \
--label "io.leleka.ci.cli-check-owner=$image_tag" --iidfile "$owned_dir/image.iid" .
image="$(cat "$owned_dir/image.iid")"
[[ "$image" =~ ^sha256:[0-9a-f]{64}$ ]]
test "$(docker image inspect --format '{{ index .Config.Labels "io.leleka.ci.cli-check-owner" }}' "$image")" = "$image_tag"
- name: Check isolated CLI container startup and shutdown
run: python3 scripts/smoke-cli-container.py strata-cli-check
run: |
set -euo pipefail
image="$(cat "$CLI_CHECK_DIR/image.iid")"
[[ "$image" =~ ^sha256:[0-9a-f]{64}$ ]]
test "$(docker image inspect --format '{{ index .Config.Labels "io.leleka.ci.cli-check-owner" }}' "$image")" = "$CLI_CHECK_TAG"
python3 scripts/smoke-cli-container.py "$image"
- name: Remove test image
if: always()
run: docker image rm strata-cli-check || true
run: |
set -euo pipefail
test -n "${CLI_CHECK_DIR:-}" || exit 0
trap 'rm -f -- "$CLI_CHECK_DIR/image.iid"; rmdir -- "$CLI_CHECK_DIR"' EXIT
if test -s "$CLI_CHECK_DIR/image.iid"; then
image="$(cat "$CLI_CHECK_DIR/image.iid")"
else
# A failed build may leave the owned tag without writing an IID receipt.
image="$(docker image inspect --format '{{.Id}}' "$CLI_CHECK_TAG" 2>/dev/null || true)"
fi
test -n "$image" || exit 0
[[ "$image" =~ ^sha256:[0-9a-f]{64}$ ]]
test "$(docker image inspect --format '{{ index .Config.Labels "io.leleka.ci.cli-check-owner" }}' "$image")" = "$CLI_CHECK_TAG"
# No force or parent pruning: cleanup cannot remove other jobs' references or cache.
docker image rm --no-prune "$image"
release-cli:
permissions:
+96 -3
View File
@@ -9,6 +9,7 @@ import re
import shutil
import stat
import subprocess
import sys
import tempfile
import uuid
@@ -17,6 +18,9 @@ NAME = 'strata-next-linux-x86_64-musl'
FILES = {NAME, 'PROVENANCE.json', 'SHA256SUMS'}
# Official Ubuntu 26.04 linux/amd64 manifest, observed 2026-10-04; glibc is probed.
BASE = 'ubuntu@sha256:88a381d5b5eeb2b35d3ad70925a362c37ce569daf43ede89ff818ec20e4d3794'
PROBE_INFRA_TIMEOUT = 120
PROBE_APP_TIMEOUT = 30
PROBE_OUTPUT_LIMIT = 64 * 1024
def digest(path):
@@ -124,18 +128,107 @@ def docker(*args, timeout=30, check=True):
check=check, timeout=timeout)
def _bounded_output(value, stream):
if not isinstance(value, str) or len(value.encode('utf-8')) > PROBE_OUTPUT_LIMIT:
raise ValueError(f'isolated CLI {stream} exceeds {PROBE_OUTPUT_LIMIT}-byte limit')
return value
def _report_best_effort(message):
try:
print(message, file=sys.stderr, flush=True)
except BaseException:
pass
def _safe_report(message):
try:
_report_best_effort(message)
except BaseException:
pass
def _diagnose_owned_container(name):
for label, args in (
('inspect', ('inspect', '--format', '{{json .State}}', name)),
('logs', ('logs', '--tail', '40', name)),
):
try:
result = docker(*args, timeout=8, check=False)
output = (result.stdout or '') + (result.stderr or '')
if len(output.encode('utf-8')) > PROBE_OUTPUT_LIMIT:
output = '[earlier output truncated]\n' + output[-PROBE_OUTPUT_LIMIT:]
_safe_report(
f'Owned runtime-image probe {label} (exit {result.returncode}):\n{output}')
except BaseException as error:
_safe_report(
f'Owned runtime-image probe {label} unavailable: {type(error).__name__}')
def isolated_run(image, arguments, *, entrypoint=None):
name = 'strata-image-probe-' + uuid.uuid4().hex
args = ['run', '--name', name, '--rm', '--platform', 'linux/amd64', '--network', 'none',
args = ['create', '--name', name, '--platform', 'linux/amd64', '--network', 'none',
'--read-only', '--user', '65532:65532', '--cap-drop', 'ALL',
'--security-opt', 'no-new-privileges', '-e', 'CUDA_VISIBLE_DEVICES=',
'-e', 'NVIDIA_VISIBLE_DEVICES=void']
if entrypoint:
args += ['--entrypoint', entrypoint]
primary_error = None
try:
return docker(*args, image, *arguments).stdout
created = docker(*args, image, *arguments, timeout=PROBE_INFRA_TIMEOUT)
_bounded_output(created.stdout, 'create output')
docker('start', name, timeout=PROBE_INFRA_TIMEOUT)
waited = docker('wait', name, timeout=PROBE_APP_TIMEOUT, check=False)
_bounded_output(waited.stdout, 'wait status')
_bounded_output(waited.stderr, 'wait stderr')
if waited.returncode:
raise subprocess.CalledProcessError(
waited.returncode, ['docker', 'wait', name],
output=waited.stdout, stderr=waited.stderr)
if not re.fullmatch(r'(?:0|[1-9][0-9]{0,2})\n?', waited.stdout):
raise ValueError('docker wait returned a malformed CLI exit status')
exit_status = int(waited.stdout.rstrip('\n'))
if exit_status > 255:
raise ValueError('docker wait returned a CLI exit status outside 0..255')
logs = docker('logs', name, timeout=30, check=False)
stdout = _bounded_output(logs.stdout, 'stdout')
stderr = _bounded_output(logs.stderr, 'stderr')
if logs.returncode:
raise subprocess.CalledProcessError(
logs.returncode, ['docker', 'logs', name], output=stdout, stderr=stderr)
if exit_status:
raise subprocess.CalledProcessError(
exit_status, ['docker', 'container', 'probe', name],
output=stdout, stderr=stderr)
if stderr:
_report_best_effort(f'Runtime-image probe stderr:\n{stderr}')
return stdout
except BaseException as error:
primary_error = error
try:
_diagnose_owned_container(name)
except BaseException as diagnostic_error:
_safe_report(
f'Owned runtime-image probe diagnostics failed: {type(diagnostic_error).__name__}')
raise
finally:
docker('rm', '-f', name, check=False)
cleanup_error = None
try:
result = docker('rm', '-f', name, timeout=10, check=False)
if result.returncode:
cleanup_error = subprocess.CalledProcessError(
result.returncode, ['docker', 'rm', '-f', name],
output=result.stdout, stderr=result.stderr)
except BaseException as error:
cleanup_error = error
if cleanup_error is not None:
if primary_error is None:
raise cleanup_error
_safe_report(
f'Owned runtime-image probe cleanup failed after '
f'{type(primary_error).__name__}: {type(cleanup_error).__name__}')
def assemble(args):
+59 -3
View File
@@ -9,12 +9,43 @@ import subprocess
from docker_smoke_http import ISOLATION, docker, prepare_probe, request
def report_best_effort(message):
try:
print(message, file=sys.stderr, flush=True)
except Exception:
pass
def diagnose_owned_container(name):
"""Emit bounded state/log diagnostics for this invocation's unique container."""
commands = (
('inspect', ('inspect', '--format', '{{json .State}}', name)),
('logs', ('logs', '--tail', '40', name)),
)
for label, args in commands:
try:
result = docker(*args, check=False, timeout=8)
output = (result.stdout or '') + (result.stderr or '')
if len(output) > 8192:
output = '[earlier output truncated]\n' + output[-8192:]
if output:
report_best_effort(
f'Owned container {label} (exit {result.returncode}):\n{output}')
else:
report_best_effort(
f'Owned container {label}: no output (exit {result.returncode})')
except Exception as error:
report_best_effort(
f'Owned container {label} diagnostics unavailable: {type(error).__name__}')
def main(image):
name = 'strata-cli-smoke-' + uuid.uuid4().hex
common = ['--name', name, *ISOLATION]
root = Path(__file__).resolve().parents[1]
prepare_probe()
primary_error = None
try:
version = docker('run', '--rm', *common, '--network', 'none', image, '--version').stdout
assert version.startswith('strata-next '), version
@@ -24,8 +55,16 @@ def main(image):
info = json.loads(docker('run', '--rm', *common, '--network', 'none', image,
'engine-info').stdout)
assert info['embedded'] is False and info['model_bundled'] is False, info
docker('run', '-d', *common, '--network', 'none',
'-e', 'STRATA_BIND=127.0.0.1:8081', image, 'serve')
try:
docker('run', '-d', *common, '--network', 'none',
'-e', 'STRATA_BIND=127.0.0.1:8081', image, 'serve', timeout=120)
except subprocess.TimeoutExpired:
try:
diagnose_owned_container(name)
except Exception as error:
report_best_effort(
f'Owned container diagnostics failed: {type(error).__name__}')
raise
deadline = time.monotonic() + 15
while True:
try:
@@ -42,8 +81,25 @@ def main(image):
assert state['ExitCode'] == 0 and not state['OOMKilled'], state
print('CLI OCI passed: actual image, exact upstream license, no embedded engine/model, '
'non-root read-only health200/ready503, graceful stop. No GPU inference qualified.')
except BaseException as error:
primary_error = error
raise
finally:
docker('rm', '-f', name, check=False)
cleanup_error = None
try:
result = docker('rm', '-f', name, check=False, timeout=10)
if result.returncode:
cleanup_error = subprocess.CalledProcessError(
result.returncode, ['docker', 'rm', '-f', name],
output=result.stdout, stderr=result.stderr)
except Exception as error:
cleanup_error = error
if cleanup_error is not None:
if primary_error is None:
raise cleanup_error
report_best_effort(
f'Owned container cleanup failed after {type(primary_error).__name__}: '
f'{type(cleanup_error).__name__}')
if __name__ == '__main__':
+139
View File
@@ -3,6 +3,7 @@
import importlib.util
import hashlib
import json
import subprocess
from pathlib import Path
import shutil
import tempfile
@@ -156,5 +157,143 @@ class PackageTests(unittest.TestCase):
b.frozen_file(self.pkg/b.NAME, Path(stage)/'out', 1)
class IsolatedProbeTests(unittest.TestCase):
def setUp(self):
reporter = patch.object(b, '_report_best_effort')
reporter.start()
self.addCleanup(reporter.stop)
def fake_docker(self, calls, *, wait_stdout='0\n', wait_stderr='', wait_rc=0,
logs_stdout='probe output\n', logs_stderr='', logs_rc=0,
start_error=None, wait_error=None, cleanup_error=None, logs_size=None):
container = None
def invoke(*args, timeout=30, check=True):
nonlocal container
calls.append((args, timeout, check))
if args[0] == 'create':
container = args[args.index('--name') + 1]
return SimpleNamespace(stdout='a' * 64 + '\n', stderr='', returncode=0)
if args[0] == 'start':
self.assertEqual(args[1], container)
if start_error is not None:
raise start_error
return SimpleNamespace(stdout=container + '\n', stderr='', returncode=0)
if args[0] == 'wait':
self.assertEqual(args[1], container)
if wait_error is not None:
raise wait_error
return SimpleNamespace(stdout=wait_stdout, stderr=wait_stderr, returncode=wait_rc)
if args[0] == 'logs':
self.assertEqual(args[-1], container)
stdout = logs_stdout if logs_size is None else 'x' * logs_size
return SimpleNamespace(stdout=stdout, stderr=logs_stderr, returncode=logs_rc)
if args[:2] == ('inspect', '--format'):
self.assertEqual(args[-1], container)
raise OSError('synthetic inspect unavailable')
if args[0] == 'inspect':
self.assertEqual(args[-1], container)
raise OSError('synthetic inspect unavailable')
if args[:2] == ('rm', '-f'):
self.assertEqual(args[-1], container)
if cleanup_error is not None:
raise cleanup_error
return SimpleNamespace(stdout='', stderr='', returncode=0)
raise AssertionError(f'unexpected Docker call: {args!r}')
return invoke
def test_probe_uses_long_infrastructure_deadline_and_original_cli_deadline(self):
calls = []
with patch.object(b, 'docker', side_effect=self.fake_docker(calls)):
output = b.isolated_run('sha256:' + 'a' * 64, ['engine-info'], entrypoint='strata-next')
self.assertEqual(output, 'probe output\n')
operations = [call[0][0] for call in calls]
self.assertEqual(operations, ['create', 'start', 'wait', 'logs', 'rm'])
create, start, wait, logs, remove = calls
self.assertEqual(create[1], 120)
self.assertEqual(start[1], 120)
self.assertEqual(wait[1], 30)
self.assertEqual(logs[1], 30)
self.assertEqual(remove[1], 10)
self.assertNotIn('--rm', create[0])
self.assertEqual(create[0][create[0].index('--network') + 1], 'none')
self.assertIn('--read-only', create[0])
self.assertIn('--cap-drop', create[0])
self.assertIn('65532:65532', create[0])
self.assertIn('strata-next', create[0])
self.assertEqual(start[0][1], create[0][create[0].index('--name') + 1])
self.assertEqual(wait[0][1], start[0][1])
self.assertEqual(logs[0][-1], start[0][1])
self.assertEqual(remove[0][-1], start[0][1])
def test_probe_rejects_malformed_wait_status_and_bounds_both_streams(self):
for status in ('', '0\n1\n', '-1\n', '256\n'):
with self.subTest(status=status):
calls = []
with patch.object(b, 'docker', side_effect=self.fake_docker(calls, wait_stdout=status)):
with self.assertRaisesRegex(ValueError, 'malformed CLI exit status|outside 0..255'):
b.isolated_run('image', ['engine-help'])
self.assertEqual([x[0][0] for x in calls[:3]], ['create', 'start', 'wait'])
self.assertEqual(calls[-1][0][0:2], ('rm', '-f'))
for stream in ('stdout', 'stderr'):
with self.subTest(stream=stream):
calls = []
kwargs = {'logs_size': b.PROBE_OUTPUT_LIMIT + 1} if stream == 'stdout' else {
'logs_stderr': 'x' * (b.PROBE_OUTPUT_LIMIT + 1)}
with patch.object(b, 'docker', side_effect=self.fake_docker(calls, **kwargs)):
with self.assertRaisesRegex(ValueError, f'CLI {stream} exceeds'):
b.isolated_run('image', ['engine-help'])
self.assertEqual(calls[-1][0][0:2], ('rm', '-f'))
def test_nonzero_cli_exit_preserves_both_streams(self):
calls = []
with patch.object(b, 'docker', side_effect=self.fake_docker(
calls, wait_stdout='17\n', logs_stdout='help stdout', logs_stderr='help stderr')):
with self.assertRaises(subprocess.CalledProcessError) as raised:
b.isolated_run('image', ['engine-help'])
self.assertEqual(raised.exception.returncode, 17)
self.assertEqual(raised.exception.output, 'help stdout')
self.assertEqual(raised.exception.stderr, 'help stderr')
self.assertEqual([x[0][0] for x in calls[:4]], ['create', 'start', 'wait', 'logs'])
self.assertEqual(calls[-1][0][0:2], ('rm', '-f'))
def test_infrastructure_timeout_keeps_original_across_broken_reporting_and_cleanup(self):
calls = []
timeout = subprocess.TimeoutExpired(['docker', 'start'], 120)
with patch.object(b, 'docker', side_effect=self.fake_docker(
calls, start_error=timeout,
cleanup_error=subprocess.TimeoutExpired(['docker', 'rm'], 10))), \
patch.object(b, '_report_best_effort', side_effect=BrokenPipeError('closed stderr')):
with self.assertRaises(subprocess.TimeoutExpired) as raised:
b.isolated_run('image', ['engine-info'])
self.assertIs(raised.exception, timeout)
operations = [x[0][0] for x in calls]
self.assertEqual(operations, ['create', 'start', 'inspect', 'logs', 'rm'])
container = calls[0][0][calls[0][0].index('--name') + 1]
self.assertTrue(all(call[0][-1] == container for call in calls[2:]))
self.assertTrue(all(call[1] <= 10 for call in calls[2:]))
def test_application_timeout_is_not_extended_by_infrastructure_deadlines(self):
calls = []
timeout = subprocess.TimeoutExpired(['docker', 'wait'], 30)
with patch.object(b, 'docker', side_effect=self.fake_docker(calls, wait_error=timeout)):
with self.assertRaises(subprocess.TimeoutExpired) as raised:
b.isolated_run('image', ['engine-help'])
self.assertIs(raised.exception, timeout)
self.assertEqual([x[1] for x in calls[:3]], [120, 120, 30])
self.assertEqual(calls[-1][0][:2], ('rm', '-f'))
def test_cleanup_failure_after_success_is_not_silently_ignored(self):
calls = []
with patch.object(b, 'docker', side_effect=self.fake_docker(
calls, cleanup_error=OSError('synthetic cleanup failure'))):
with self.assertRaisesRegex(OSError, 'synthetic cleanup failure'):
b.isolated_run('image', ['engine-info'])
self.assertEqual(calls[-1][0][0:2], ('rm', '-f'))
self.assertEqual(calls[-1][1], 10)
if __name__ == '__main__':
unittest.main()