Add Synology CPUSet CI bootstrap for actual NAS capabilities
This commit is contained in:
@@ -55,6 +55,9 @@ GITEA_CI_V2_ENTRIES = (
|
|||||||
GITEA_CI_V3_ENTRIES = (
|
GITEA_CI_V3_ENTRIES = (
|
||||||
"docker-compose.gitea-ci.yml", "runner.yaml", "deployment/bootstrap-v3.json",
|
"docker-compose.gitea-ci.yml", "runner.yaml", "deployment/bootstrap-v3.json",
|
||||||
)
|
)
|
||||||
|
GITEA_CI_V4_ENTRIES = (
|
||||||
|
"docker-compose.gitea-ci.yml", "runner.yaml", "deployment/bootstrap-v4.json",
|
||||||
|
)
|
||||||
GITEA_CI_SOURCE_SHA256 = {
|
GITEA_CI_SOURCE_SHA256 = {
|
||||||
"docker-compose.gitea-ci.yml": "851d22ae9823c30508a552ec6abb7f547ceda671f3ca77552fb7032bc807ae09",
|
"docker-compose.gitea-ci.yml": "851d22ae9823c30508a552ec6abb7f547ceda671f3ca77552fb7032bc807ae09",
|
||||||
"runner.yaml": "8634e5427986423ccd8fe18e3bf5072c53addbf17f1efc1395b3a473671d78fe",
|
"runner.yaml": "8634e5427986423ccd8fe18e3bf5072c53addbf17f1efc1395b3a473671d78fe",
|
||||||
@@ -63,6 +66,10 @@ GITEA_CI_V3_SOURCE_SHA256 = {
|
|||||||
"docker-compose.gitea-ci.yml": "775440b6a4d122793b8f1474a8a1a028ece98c4bebd54962e3418f0405c89c89",
|
"docker-compose.gitea-ci.yml": "775440b6a4d122793b8f1474a8a1a028ece98c4bebd54962e3418f0405c89c89",
|
||||||
"runner.yaml": "c1e76972236b7610a167b2304967d401efdaabfd221229bdd55c63c98a34eea6",
|
"runner.yaml": "c1e76972236b7610a167b2304967d401efdaabfd221229bdd55c63c98a34eea6",
|
||||||
}
|
}
|
||||||
|
GITEA_CI_V4_SOURCE_SHA256 = {
|
||||||
|
"docker-compose.gitea-ci.yml": "dd218ef77a6505042484bbdb5cb329da043801a42e13af746fc8ba23c05e0f9c",
|
||||||
|
"runner.yaml": "94d8e4d8345b2b5bc7c8923bff7c31ff59083ec7115d633af10152b93bcd9da6",
|
||||||
|
}
|
||||||
MAP_GATEWAY_SECRET_DIR = Path("/volume1/docker/nodedc-platform/secrets")
|
MAP_GATEWAY_SECRET_DIR = Path("/volume1/docker/nodedc-platform/secrets")
|
||||||
MAP_GATEWAY_SECRET_FILE = MAP_GATEWAY_SECRET_DIR / "map-gateway-admin-secret"
|
MAP_GATEWAY_SECRET_FILE = MAP_GATEWAY_SECRET_DIR / "map-gateway-admin-secret"
|
||||||
MAP_EGRESS_PROXY_SECRET_FILE = MAP_GATEWAY_SECRET_DIR / "map-egress-proxy-token"
|
MAP_EGRESS_PROXY_SECRET_FILE = MAP_GATEWAY_SECRET_DIR / "map-egress-proxy-token"
|
||||||
@@ -4932,7 +4939,7 @@ def allowed_payload_path(component, rel):
|
|||||||
die(f"path rejected: {rel}: {reason}")
|
die(f"path rejected: {rel}: {reason}")
|
||||||
|
|
||||||
if component == "gitea-ci":
|
if component == "gitea-ci":
|
||||||
if rel in GITEA_CI_ENTRIES + GITEA_CI_V2_ENTRIES + GITEA_CI_V3_ENTRIES or rel == "deployment":
|
if rel in GITEA_CI_ENTRIES + GITEA_CI_V2_ENTRIES + GITEA_CI_V3_ENTRIES + GITEA_CI_V4_ENTRIES or rel == "deployment":
|
||||||
return True
|
return True
|
||||||
die("Gitea CI accepts only its exact bootstrap contract")
|
die("Gitea CI accepts only its exact bootstrap contract")
|
||||||
|
|
||||||
@@ -31401,12 +31408,13 @@ def rollback_map_access(root, backup_dir, entries, current_stamp):
|
|||||||
def validate_gitea_ci_payload(payload_dir, entries, release_id):
|
def validate_gitea_ci_payload(payload_dir, entries, release_id):
|
||||||
v2 = tuple(entries) == GITEA_CI_V2_ENTRIES
|
v2 = tuple(entries) == GITEA_CI_V2_ENTRIES
|
||||||
v3 = tuple(entries) == GITEA_CI_V3_ENTRIES
|
v3 = tuple(entries) == GITEA_CI_V3_ENTRIES
|
||||||
if tuple(entries) not in (GITEA_CI_ENTRIES, GITEA_CI_V2_ENTRIES, GITEA_CI_V3_ENTRIES):
|
v4 = tuple(entries) == GITEA_CI_V4_ENTRIES
|
||||||
|
if tuple(entries) not in (GITEA_CI_ENTRIES, GITEA_CI_V2_ENTRIES, GITEA_CI_V3_ENTRIES, GITEA_CI_V4_ENTRIES):
|
||||||
die("Gitea CI bootstrap entry set mismatch")
|
die("Gitea CI bootstrap entry set mismatch")
|
||||||
version = "v3" if v3 else "v2" if v2 else "v1"
|
version = "v4" if v4 else "v3" if v3 else "v2" if v2 else "v1"
|
||||||
if not release_id.startswith("gitea-ci-bootstrap-" + version + "-"):
|
if not release_id.startswith("gitea-ci-bootstrap-" + version + "-"):
|
||||||
die("Gitea CI bootstrap release identity mismatch")
|
die("Gitea CI bootstrap release identity mismatch")
|
||||||
sources = GITEA_CI_V3_SOURCE_SHA256 if v3 else GITEA_CI_SOURCE_SHA256
|
sources = GITEA_CI_V4_SOURCE_SHA256 if v4 else GITEA_CI_V3_SOURCE_SHA256 if v3 else GITEA_CI_SOURCE_SHA256
|
||||||
for rel, expected in sources.items():
|
for rel, expected in sources.items():
|
||||||
if sha256_file(payload_dir / rel) != expected:
|
if sha256_file(payload_dir / rel) != expected:
|
||||||
die(f"Gitea CI immutable configuration mismatch: {rel}")
|
die(f"Gitea CI immutable configuration mismatch: {rel}")
|
||||||
@@ -31422,10 +31430,12 @@ def validate_gitea_ci_payload(payload_dir, entries, release_id):
|
|||||||
"publishedPorts": [],
|
"publishedPorts": [],
|
||||||
"capacity": 1,
|
"capacity": 1,
|
||||||
}
|
}
|
||||||
if v2 or v3:
|
if v2 or v3 or v4:
|
||||||
expected["enrollment"] = "import-dctouch-staging-to-root-private-runtime"
|
expected["enrollment"] = "import-dctouch-staging-to-root-private-runtime"
|
||||||
if v3:
|
if v3:
|
||||||
expected["resourceProfile"] = "synology-cpu-shares-v1"
|
expected["resourceProfile"] = "synology-cpu-shares-v1"
|
||||||
|
if v4:
|
||||||
|
expected["resourceProfile"] = "synology-cpuset-v1"
|
||||||
if descriptor != expected:
|
if descriptor != expected:
|
||||||
die("Gitea CI bootstrap descriptor mismatch")
|
die("Gitea CI bootstrap descriptor mismatch")
|
||||||
return descriptor
|
return descriptor
|
||||||
@@ -31584,6 +31594,18 @@ def gitea_ci_inventory():
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def gitea_ci_check_affinity(pid, exact=False):
|
||||||
|
if type(pid) is not int or pid < 0 or (exact and pid == 0):
|
||||||
|
die("Gitea CI CPU affinity process identity is invalid")
|
||||||
|
try:
|
||||||
|
available = os.sched_getaffinity(pid)
|
||||||
|
except (AttributeError, OSError):
|
||||||
|
die("Gitea CI CPU affinity cannot be verified")
|
||||||
|
valid = available == {7} if exact else 7 in available
|
||||||
|
if not valid:
|
||||||
|
die("Gitea CI requires logical CPU7 affinity")
|
||||||
|
|
||||||
|
|
||||||
def gitea_ci_host_capabilities(entries):
|
def gitea_ci_host_capabilities(entries):
|
||||||
result = subprocess.run([str(DOCKER), "info", "--format", "{{json .}}"],
|
result = subprocess.run([str(DOCKER), "info", "--format", "{{json .}}"],
|
||||||
capture_output=True, text=True, check=True, timeout=30)
|
capture_output=True, text=True, check=True, timeout=30)
|
||||||
@@ -31599,16 +31621,23 @@ def gitea_ci_host_capabilities(entries):
|
|||||||
"CPUShares", "CPUSet", "PidsLimit", "CgroupVersion")
|
"CPUShares", "CPUSet", "PidsLimit", "CgroupVersion")
|
||||||
report = {key: raw.get(key) for key in fields}
|
report = {key: raw.get(key) for key in fields}
|
||||||
print("ci_host=" + json.dumps(report, sort_keys=True, separators=(",", ":")))
|
print("ci_host=" + json.dumps(report, sort_keys=True, separators=(",", ":")))
|
||||||
required = ["MemoryLimit", "PidsLimit"]
|
required = ["MemoryLimit"]
|
||||||
if tuple(entries) == GITEA_CI_V3_ENTRIES:
|
if tuple(entries) == GITEA_CI_V4_ENTRIES:
|
||||||
|
required += ["CPUShares", "CPUSet", "SwapLimit"]
|
||||||
|
elif tuple(entries) == GITEA_CI_V3_ENTRIES:
|
||||||
|
required.append("PidsLimit")
|
||||||
required.append("CPUShares")
|
required.append("CPUShares")
|
||||||
else:
|
else:
|
||||||
required += ["CpuCfsPeriod", "CpuCfsQuota", "SwapLimit"]
|
required += ["PidsLimit", "CpuCfsPeriod", "CpuCfsQuota", "SwapLimit"]
|
||||||
missing = [name for name in required if raw.get(name) is not True]
|
missing = [name for name in required if raw.get(name) is not True]
|
||||||
if missing:
|
if missing:
|
||||||
die("Gitea CI host lacks required resource controls: " + ",".join(missing))
|
die("Gitea CI host lacks required resource controls: " + ",".join(missing))
|
||||||
if raw.get("OSType") != "linux" or raw.get("Architecture") not in ("amd64", "x86_64"):
|
if raw.get("OSType") != "linux" or raw.get("Architecture") not in ("amd64", "x86_64"):
|
||||||
die("Gitea CI pinned worker requires Linux amd64")
|
die("Gitea CI pinned worker requires Linux amd64")
|
||||||
|
if tuple(entries) == GITEA_CI_V4_ENTRIES:
|
||||||
|
if type(raw.get("NCPU")) is not int or raw["NCPU"] < 8:
|
||||||
|
die("Gitea CI CPU7 profile requires at least eight logical CPUs")
|
||||||
|
gitea_ci_check_affinity(0)
|
||||||
return report
|
return report
|
||||||
|
|
||||||
|
|
||||||
@@ -31616,12 +31645,12 @@ def preflight_gitea_ci(entries=GITEA_CI_ENTRIES):
|
|||||||
for parent in (GITEA_CI_ROOT, *GITEA_CI_ROOT.parents):
|
for parent in (GITEA_CI_ROOT, *GITEA_CI_ROOT.parents):
|
||||||
if parent.is_symlink():
|
if parent.is_symlink():
|
||||||
die("Gitea CI root contains a symlink")
|
die("Gitea CI root contains a symlink")
|
||||||
if any((GITEA_CI_ROOT / rel).exists() for rel in GITEA_CI_ENTRIES + GITEA_CI_V2_ENTRIES + GITEA_CI_V3_ENTRIES):
|
if any((GITEA_CI_ROOT / rel).exists() for rel in GITEA_CI_ENTRIES + GITEA_CI_V2_ENTRIES + GITEA_CI_V3_ENTRIES + GITEA_CI_V4_ENTRIES):
|
||||||
die("Gitea CI bootstrap requires no installed release; use a versioned upgrade")
|
die("Gitea CI bootstrap requires no installed release; use a versioned upgrade")
|
||||||
gitea_ci_host_capabilities(entries)
|
gitea_ci_host_capabilities(entries)
|
||||||
if gitea_ci_container_ids(own=True):
|
if gitea_ci_container_ids(own=True):
|
||||||
die("Gitea CI bootstrap requires no existing CI containers")
|
die("Gitea CI bootstrap requires no existing CI containers")
|
||||||
if tuple(entries) in (GITEA_CI_V2_ENTRIES, GITEA_CI_V3_ENTRIES):
|
if tuple(entries) in (GITEA_CI_V2_ENTRIES, GITEA_CI_V3_ENTRIES, GITEA_CI_V4_ENTRIES):
|
||||||
preflight_gitea_ci_v2_enrollment()
|
preflight_gitea_ci_v2_enrollment()
|
||||||
else:
|
else:
|
||||||
read_gitea_ci_enrollment()
|
read_gitea_ci_enrollment()
|
||||||
@@ -31638,7 +31667,7 @@ def preflight_gitea_ci(entries=GITEA_CI_ENTRIES):
|
|||||||
|
|
||||||
|
|
||||||
def prepare_gitea_ci(entries=GITEA_CI_ENTRIES):
|
def prepare_gitea_ci(entries=GITEA_CI_ENTRIES):
|
||||||
token = (import_gitea_ci_v2_enrollment() if tuple(entries) in (GITEA_CI_V2_ENTRIES, GITEA_CI_V3_ENTRIES)
|
token = (import_gitea_ci_v2_enrollment() if tuple(entries) in (GITEA_CI_V2_ENTRIES, GITEA_CI_V3_ENTRIES, GITEA_CI_V4_ENTRIES)
|
||||||
else read_gitea_ci_enrollment())
|
else read_gitea_ci_enrollment())
|
||||||
for directory in (GITEA_CI_ROOT / "data", GITEA_CI_ROOT / "secrets"):
|
for directory in (GITEA_CI_ROOT / "data", GITEA_CI_ROOT / "secrets"):
|
||||||
if directory.is_symlink():
|
if directory.is_symlink():
|
||||||
@@ -31685,14 +31714,22 @@ def accept_gitea_ci_container(info, entries=GITEA_CI_ENTRIES):
|
|||||||
die("Gitea CI runner host isolation mismatch")
|
die("Gitea CI runner host isolation mismatch")
|
||||||
if any(value.startswith("GITEA_RUNNER_REGISTRATION_TOKEN=") for value in config.get("Env", [])):
|
if any(value.startswith("GITEA_RUNNER_REGISTRATION_TOKEN=") for value in config.get("Env", [])):
|
||||||
die("Gitea CI registration token must remain file-backed")
|
die("Gitea CI registration token must remain file-backed")
|
||||||
if tuple(entries) == GITEA_CI_V3_ENTRIES:
|
v4 = tuple(entries) == GITEA_CI_V4_ENTRIES
|
||||||
|
if v4 or tuple(entries) == GITEA_CI_V3_ENTRIES:
|
||||||
valid_cpu = (host.get("CpuShares") == 64 and not host.get("NanoCpus")
|
valid_cpu = (host.get("CpuShares") == 64 and not host.get("NanoCpus")
|
||||||
and not host.get("CpuQuota") and not host.get("CpuPeriod"))
|
and not host.get("CpuQuota") and not host.get("CpuPeriod"))
|
||||||
else:
|
else:
|
||||||
valid_cpu = host.get("NanoCpus") == 500000000
|
valid_cpu = host.get("NanoCpus") == 500000000
|
||||||
|
valid_pids = host.get("PidsLimit") in (None, 0, -1) if v4 else host.get("PidsLimit") == 128
|
||||||
|
if v4:
|
||||||
|
valid_cpu = valid_cpu and host.get("CpusetCpus") == "7"
|
||||||
|
if host.get("MemorySwap") != 512 * 1024 ** 2:
|
||||||
|
die("Gitea CI daemon memory/swap limit mismatch")
|
||||||
if (host.get("Memory") != 512 * 1024 ** 2
|
if (host.get("Memory") != 512 * 1024 ** 2
|
||||||
or not valid_cpu or host.get("PidsLimit") != 128):
|
or not valid_cpu or not valid_pids):
|
||||||
die("Gitea CI daemon resource limit mismatch")
|
die("Gitea CI daemon resource limit mismatch")
|
||||||
|
if v4:
|
||||||
|
gitea_ci_check_affinity(info.get("State", {}).get("Pid"), exact=True)
|
||||||
expected_mounts = {
|
expected_mounts = {
|
||||||
"/config/runner.yaml": (str(GITEA_CI_ROOT / "runner.yaml"), False),
|
"/config/runner.yaml": (str(GITEA_CI_ROOT / "runner.yaml"), False),
|
||||||
"/data": (str(GITEA_CI_ROOT / "data"), True),
|
"/data": (str(GITEA_CI_ROOT / "data"), True),
|
||||||
@@ -32398,7 +32435,10 @@ def plan_artifact(artifact):
|
|||||||
if component == "gitea-ci":
|
if component == "gitea-ci":
|
||||||
print("ci_transition=bootstrap-build-runner;production_deploy=false")
|
print("ci_transition=bootstrap-build-runner;production_deploy=false")
|
||||||
print("ci_ports=none;cache=false;metrics=false;capacity=1")
|
print("ci_ports=none;cache=false;metrics=false;capacity=1")
|
||||||
if tuple(entries) == GITEA_CI_V3_ENTRIES:
|
if tuple(entries) == GITEA_CI_V4_ENTRIES:
|
||||||
|
print("ci_cpu=cpuset:7;shared_by_daemon_and_job;relative_shares=64,128;capacity=1")
|
||||||
|
print("ci_memory_and_swap=daemon:512MiB,job:2GiB;ci_pids=not-enforced-kernel-unsupported")
|
||||||
|
elif tuple(entries) == GITEA_CI_V3_ENTRIES:
|
||||||
print("ci_cpu=relative-shares;daemon:64,job:128;hard_cpu_quota=none")
|
print("ci_cpu=relative-shares;daemon:64,job:128;hard_cpu_quota=none")
|
||||||
print("ci_memory=daemon:512MiB,job:2GiB;ci_pids=daemon:128,job:256;swap=host-default")
|
print("ci_memory=daemon:512MiB,job:2GiB;ci_pids=daemon:128,job:256;swap=host-default")
|
||||||
else:
|
else:
|
||||||
@@ -32406,7 +32446,7 @@ def plan_artifact(artifact):
|
|||||||
print(f"ci_runner_image={GITEA_CI_IMAGE}")
|
print(f"ci_runner_image={GITEA_CI_IMAGE}")
|
||||||
print(f"ci_job_image={GITEA_CI_JOB_IMAGE}")
|
print(f"ci_job_image={GITEA_CI_JOB_IMAGE}")
|
||||||
print("ci_pull=exact-digests-only;registration=separate-runtime-enrollment")
|
print("ci_pull=exact-digests-only;registration=separate-runtime-enrollment")
|
||||||
if tuple(entries) in (GITEA_CI_V2_ENTRIES, GITEA_CI_V3_ENTRIES):
|
if tuple(entries) in (GITEA_CI_V2_ENTRIES, GITEA_CI_V3_ENTRIES, GITEA_CI_V4_ENTRIES):
|
||||||
print("ci_enrollment=" + preflight_gitea_ci_v2_enrollment())
|
print("ci_enrollment=" + preflight_gitea_ci_v2_enrollment())
|
||||||
print("ci_enrollment_apply=copy-to-root0600;private-directory0700;remove-staging-after-verification")
|
print("ci_enrollment_apply=copy-to-root0600;private-directory0700;remove-staging-after-verification")
|
||||||
print("ci_preserved=all-existing-containers,databases,volumes;rollback=bootstrap-source-and-runner-only")
|
print("ci_preserved=all-existing-containers,databases,volumes;rollback=bootstrap-source-and-runner-only")
|
||||||
|
|||||||
+23
-12
@@ -17,13 +17,15 @@ been accepted. Later repositories receive explicit registrations/policies.
|
|||||||
- Runner and Node images use official Linux amd64 manifest digests (not mutable
|
- Runner and Node images use official Linux amd64 manifest digests (not mutable
|
||||||
tags), resolved from Docker Hub on 2026-09-29. The deploy runner pulls exactly
|
tags), resolved from Docker Hub on 2026-09-29. The deploy runner pulls exactly
|
||||||
these two digests. No repository-provided image names or commands.
|
these two digests. No repository-provided image names or commands.
|
||||||
- Current Synology v3 profile: daemon CPU shares 64, 512 MiB RAM, 128 PIDs,
|
- Current Synology v4 profile: daemon and the single job share logical CPU7
|
||||||
readonly root filesystem. Build jobs: one at a time, CPU shares 128,
|
through CPUSet. Their combined CPU ceiling is one logical CPU. Daemon:
|
||||||
2 GiB RAM, 256 PIDs, no privileged mode, no host bind
|
CPU shares64, 512 MiB RAM+swap, readonly root filesystem. Job: CPU shares128,
|
||||||
|
2 GiB RAM+swap, no privileged mode, no host bind
|
||||||
mounts, no host execution label and no Docker socket in job containers.
|
mounts, no host execution label and no Docker socket in job containers.
|
||||||
- CPU shares give low relative priority during contention, not a hard CPU
|
- CPU shares also give low relative priority during contention. The NAS kernel
|
||||||
quota. Job swap uses the Docker/host default. The v1/v2 historical profiles
|
lacks a PIDs controller, so v4 does not set or claim a process-count limit.
|
||||||
retain their exact 0.5/1 NanoCPU quotas and original immutable config hashes.
|
V1/v2 retain their exact 0.5/1 NanoCPU quotas; v3 retains its shares-only/PIDs
|
||||||
|
profile. Historical configuration hashes are not changed.
|
||||||
- No published ports or host networking. Runner cache and metrics listeners
|
- No published ports or host networking. Runner cache and metrics listeners
|
||||||
are disabled. Communication uses outbound HTTPS to the existing Gitea.
|
are disabled. Communication uses outbound HTTPS to the existing Gitea.
|
||||||
- Only the trusted runner daemon mounts the Docker socket. That daemon is
|
- Only the trusted runner daemon mounts the Docker socket. That daemon is
|
||||||
@@ -61,11 +63,13 @@ file is part of the artifact, source backup, journal or diagnostic output.
|
|||||||
|
|
||||||
The bootstrap accepts no existing installed CI descriptor or CI container.
|
The bootstrap accepts no existing installed CI descriptor or CI container.
|
||||||
Preflight reads Docker's actual resource capabilities before any runtime
|
Preflight reads Docker's actual resource capabilities before any runtime
|
||||||
mutation, and reports only allowlisted version/kernel/resource fields. V3
|
mutation, and reports only allowlisted version/kernel/resource fields. V4
|
||||||
requires Linux amd64 plus CPU shares, memory and PIDs controls. V1/v2 additionally
|
requires Linux amd64, CPUSet, CPU shares, memory/swap controls, at least eight
|
||||||
require CFS period/quota and swap accounting. Missing or non-boolean capability
|
logical CPUs and CPU7 available in the installer's affinity. Acceptance also
|
||||||
values do not pass. Preflight also checks at least 8 GiB free disk and 3 GiB
|
verifies the actual daemon affinity is exactly CPU7. V3 requires a PIDs
|
||||||
currently available memory.
|
controller; V1/v2 additionally require CFS period/quota. Missing or non-boolean
|
||||||
|
required capability values do not pass. Preflight also checks at least 8 GiB
|
||||||
|
free disk and 3 GiB currently available memory.
|
||||||
|
|
||||||
The v2 apply on 2026-09-29 imported the private token successfully and pulled
|
The v2 apply on 2026-09-29 imported the private token successfully and pulled
|
||||||
the pinned images, but Docker rejected `NanoCPUs`: this NAS kernel does not
|
the pinned images, but Docker rejected `NanoCPUs`: this NAS kernel does not
|
||||||
@@ -75,13 +79,20 @@ Artifact `gitea-ci-bootstrap-v2-20260929-002` is terminal failed and must not be
|
|||||||
restaged or retried. V3 uses separate reviewed `synology-v3/` configurations and
|
restaged or retried. V3 uses separate reviewed `synology-v3/` configurations and
|
||||||
`bootstrap-v3.json`; historical payloads remain byte-for-byte reproducible.
|
`bootstrap-v3.json`; historical payloads remain byte-for-byte reproducible.
|
||||||
|
|
||||||
|
The subsequent v3 plan established the actual host matrix: Docker24.0.2,
|
||||||
|
kernel4.4.302+, cgroupv1, x86_64, eight logical CPUs, MemTotal16743616512.
|
||||||
|
CPUSet/CPUShares/MemoryLimit/SwapLimit=true; CFS period/quota and PidsLimit=false.
|
||||||
|
It stopped before apply. V4 uses this verified matrix, with separate
|
||||||
|
`synology-v4/` templates and `bootstrap-v4.json`. The private token from the
|
||||||
|
rolled-back v2 attempt is reused. Neither v2 nor v3 is the next install target.
|
||||||
|
|
||||||
## Build and install
|
## Build and install
|
||||||
|
|
||||||
From a clean Platform commit:
|
From a clean Platform commit:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
python3 -m unittest discover -s infra/gitea-ci -p 'test_*.py'
|
python3 -m unittest discover -s infra/gitea-ci -p 'test_*.py'
|
||||||
python3 infra/gitea-ci/build_artifact.py --patch-id gitea-ci-bootstrap-v3-<unique-id> --source-commit <full-sha> --output-dir <output-dir>
|
python3 infra/gitea-ci/build_artifact.py --patch-id gitea-ci-bootstrap-v4-<unique-id> --source-commit <full-sha> --output-dir <output-dir>
|
||||||
```
|
```
|
||||||
|
|
||||||
The first use requires promotion of the reviewed root runner through the
|
The first use requires promotion of the reviewed root runner through the
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"schemaVersion": "nodedc.gitea-ci.bootstrap.v4",
|
||||||
|
"releaseId": "__PATCH_ID__",
|
||||||
|
"action": "bootstrap-build-runner",
|
||||||
|
"repository": "SILVER/NODEDC_DEVICE_CORE",
|
||||||
|
"instance": "https://git.dcserve.ru",
|
||||||
|
"runnerName": "synology-device-core-build",
|
||||||
|
"productionDeployEnabled": false,
|
||||||
|
"publishedPorts": [],
|
||||||
|
"capacity": 1,
|
||||||
|
"enrollment": "import-dctouch-staging-to-root-private-runtime",
|
||||||
|
"resourceProfile": "synology-cpuset-v1"
|
||||||
|
}
|
||||||
@@ -16,11 +16,14 @@ SOURCE = Path(__file__).resolve().parent
|
|||||||
ENTRIES = ("docker-compose.gitea-ci.yml", "runner.yaml", "deployment/bootstrap-v1.json")
|
ENTRIES = ("docker-compose.gitea-ci.yml", "runner.yaml", "deployment/bootstrap-v1.json")
|
||||||
V2_ENTRIES = ("docker-compose.gitea-ci.yml", "runner.yaml", "deployment/bootstrap-v2.json")
|
V2_ENTRIES = ("docker-compose.gitea-ci.yml", "runner.yaml", "deployment/bootstrap-v2.json")
|
||||||
V3_ENTRIES = ("docker-compose.gitea-ci.yml", "runner.yaml", "deployment/bootstrap-v3.json")
|
V3_ENTRIES = ("docker-compose.gitea-ci.yml", "runner.yaml", "deployment/bootstrap-v3.json")
|
||||||
|
V4_ENTRIES = ("docker-compose.gitea-ci.yml", "runner.yaml", "deployment/bootstrap-v4.json")
|
||||||
|
|
||||||
|
|
||||||
def entries_for(patch_id):
|
def entries_for(patch_id):
|
||||||
if not re.fullmatch(r"gitea-ci-bootstrap-v[123]-[a-zA-Z0-9._-]{1,65}", patch_id):
|
if not re.fullmatch(r"gitea-ci-bootstrap-v[1234]-[a-zA-Z0-9._-]{1,65}", patch_id):
|
||||||
raise ValueError("invalid_bootstrap_identity")
|
raise ValueError("invalid_bootstrap_identity")
|
||||||
|
if patch_id.startswith("gitea-ci-bootstrap-v4-"):
|
||||||
|
return V4_ENTRIES
|
||||||
if patch_id.startswith("gitea-ci-bootstrap-v3-"):
|
if patch_id.startswith("gitea-ci-bootstrap-v3-"):
|
||||||
return V3_ENTRIES
|
return V3_ENTRIES
|
||||||
return V2_ENTRIES if patch_id.startswith("gitea-ci-bootstrap-v2-") else ENTRIES
|
return V2_ENTRIES if patch_id.startswith("gitea-ci-bootstrap-v2-") else ENTRIES
|
||||||
@@ -28,7 +31,7 @@ def entries_for(patch_id):
|
|||||||
|
|
||||||
def bundle(patch_id, source=SOURCE):
|
def bundle(patch_id, source=SOURCE):
|
||||||
entries = entries_for(patch_id)
|
entries = entries_for(patch_id)
|
||||||
config_source = source / "synology-v3" if entries == V3_ENTRIES else source
|
config_source = source / "synology-v4" if entries == V4_ENTRIES else source / "synology-v3" if entries == V3_ENTRIES else source
|
||||||
descriptor = json.loads((source / Path(entries[2]).name).read_text())
|
descriptor = json.loads((source / Path(entries[2]).name).read_text())
|
||||||
if descriptor["releaseId"] != "__PATCH_ID__":
|
if descriptor["releaseId"] != "__PATCH_ID__":
|
||||||
raise ValueError("bootstrap_template_identity_mismatch")
|
raise ValueError("bootstrap_template_identity_mismatch")
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
services:
|
||||||
|
build-runner:
|
||||||
|
image: docker.io/gitea/runner@sha256:05e100d9c2268fb300f929cab014e9930591a2d66822454e175c1099d1464b14
|
||||||
|
platform: linux/amd64
|
||||||
|
pull_policy: never
|
||||||
|
restart: unless-stopped
|
||||||
|
read_only: true
|
||||||
|
cpu_shares: 64
|
||||||
|
cpuset: "7"
|
||||||
|
mem_limit: 512m
|
||||||
|
memswap_limit: 512m
|
||||||
|
cap_drop: [ALL]
|
||||||
|
security_opt: [no-new-privileges:true]
|
||||||
|
tmpfs:
|
||||||
|
- /tmp:rw,nosuid,nodev,size=134217728
|
||||||
|
environment:
|
||||||
|
HOME: /data
|
||||||
|
XDG_CACHE_HOME: /data/.cache
|
||||||
|
CONFIG_FILE: /config/runner.yaml
|
||||||
|
GITEA_INSTANCE_URL: https://git.dcserve.ru
|
||||||
|
GITEA_RUNNER_NAME: synology-device-core-build
|
||||||
|
GITEA_RUNNER_REGISTRATION_TOKEN_FILE: /run/secrets/registration-token
|
||||||
|
volumes:
|
||||||
|
- type: bind
|
||||||
|
source: /volume1/docker/nodedc-gitea-ci/runner.yaml
|
||||||
|
target: /config/runner.yaml
|
||||||
|
read_only: true
|
||||||
|
bind: {create_host_path: false}
|
||||||
|
- type: bind
|
||||||
|
source: /volume1/docker/nodedc-gitea-ci/data
|
||||||
|
target: /data
|
||||||
|
bind: {create_host_path: false}
|
||||||
|
- type: bind
|
||||||
|
source: /volume1/docker/nodedc-gitea-ci/secrets/registration-token
|
||||||
|
target: /run/secrets/registration-token
|
||||||
|
read_only: true
|
||||||
|
bind: {create_host_path: false}
|
||||||
|
- type: bind
|
||||||
|
source: /var/run/docker.sock
|
||||||
|
target: /var/run/docker.sock
|
||||||
|
read_only: true
|
||||||
|
bind: {create_host_path: false}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
log:
|
||||||
|
level: info
|
||||||
|
runner:
|
||||||
|
file: /data/.runner
|
||||||
|
capacity: 1
|
||||||
|
timeout: 1h
|
||||||
|
shutdown_timeout: 45m
|
||||||
|
insecure: false
|
||||||
|
fetch_interval: 5s
|
||||||
|
env_file: ""
|
||||||
|
envs:
|
||||||
|
NODE_OPTIONS: --max-old-space-size=1536
|
||||||
|
labels:
|
||||||
|
- nodedc-node22-build:docker://docker.io/library/node@sha256:9887ee8a5e5aa4fb02e09f03cdf81ef1b52184665549836fe3943eb0c2eaefdb
|
||||||
|
cache:
|
||||||
|
enabled: false
|
||||||
|
container:
|
||||||
|
network: ""
|
||||||
|
privileged: false
|
||||||
|
options: --cpuset-cpus=7 --cpu-shares=128 --memory=2g --memory-swap=2g --cap-drop=ALL --security-opt=no-new-privileges
|
||||||
|
valid_volumes: []
|
||||||
|
docker_host: "-"
|
||||||
|
force_pull: false
|
||||||
|
bind_workdir: false
|
||||||
|
metrics:
|
||||||
|
enabled: false
|
||||||
@@ -159,8 +159,8 @@ class BootstrapTests(unittest.TestCase):
|
|||||||
|
|
||||||
def apply_in_synthetic_host(self, fail_health=False, version="v1"):
|
def apply_in_synthetic_host(self, fail_health=False, version="v1"):
|
||||||
expected_entries = RUNNER.GITEA_CI_ENTRIES
|
expected_entries = RUNNER.GITEA_CI_ENTRIES
|
||||||
if version in ("v2", "v3"):
|
if version in ("v2", "v3", "v4"):
|
||||||
expected_entries = RUNNER.GITEA_CI_V3_ENTRIES if version == "v3" else RUNNER.GITEA_CI_V2_ENTRIES
|
expected_entries = getattr(RUNNER, "GITEA_CI_" + version.upper() + "_ENTRIES")
|
||||||
self.artifact.write_bytes(build_artifact.bundle("gitea-ci-bootstrap-" + version + "-test-001"))
|
self.artifact.write_bytes(build_artifact.bundle("gitea-ci-bootstrap-" + version + "-test-001"))
|
||||||
host = self.root / "host"
|
host = self.root / "host"
|
||||||
host.mkdir()
|
host.mkdir()
|
||||||
@@ -256,6 +256,18 @@ class BootstrapTests(unittest.TestCase):
|
|||||||
self.assertEqual((app / "data/registration-marker").read_text(), "preserve-on-rollback")
|
self.assertEqual((app / "data/registration-marker").read_text(), "preserve-on-rollback")
|
||||||
self.assertEqual(json.loads(paths["FAILED_STATE_FILE"].read_text())["rollback_status"], "ok:gitea-ci-bootstrap")
|
self.assertEqual(json.loads(paths["FAILED_STATE_FILE"].read_text())["rollback_status"], "ok:gitea-ci-bootstrap")
|
||||||
|
|
||||||
|
def test_v4_apply_and_receipt(self):
|
||||||
|
paths, app, candidate, output = self.apply_in_synthetic_host(version="v4")
|
||||||
|
self.assertTrue((app / "deployment/bootstrap-v4.json").is_file())
|
||||||
|
self.assertEqual(json.loads(paths["STATE_FILE"].read_text())["status"], "ok")
|
||||||
|
self.assertIn("deploy-ok patch=gitea-ci-bootstrap-v4-test-001", output)
|
||||||
|
|
||||||
|
def test_v4_rollback_preserves_identity(self):
|
||||||
|
paths, app, candidate, output = self.apply_in_synthetic_host(fail_health=True, version="v4")
|
||||||
|
self.assertFalse((app / "deployment/bootstrap-v4.json").exists())
|
||||||
|
self.assertEqual((app / "data/registration-marker").read_text(), "preserve-on-rollback")
|
||||||
|
self.assertEqual(json.loads(paths["FAILED_STATE_FILE"].read_text())["rollback_status"], "ok:gitea-ci-bootstrap")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ class SynologyV3Tests(unittest.TestCase):
|
|||||||
for patch, sha in (
|
for patch, sha in (
|
||||||
("gitea-ci-bootstrap-v1-20260929-001", "ba942839c5815d09ac8f3c8dc23acdcf53ad9ef098a74c26b14c8b81afcf6a20"),
|
("gitea-ci-bootstrap-v1-20260929-001", "ba942839c5815d09ac8f3c8dc23acdcf53ad9ef098a74c26b14c8b81afcf6a20"),
|
||||||
("gitea-ci-bootstrap-v2-20260929-002", "f9381e1ca59372f75277b6a6207ac9e35acaf29fd8ffa5dcf6afafa2daf80630"),
|
("gitea-ci-bootstrap-v2-20260929-002", "f9381e1ca59372f75277b6a6207ac9e35acaf29fd8ffa5dcf6afafa2daf80630"),
|
||||||
|
("gitea-ci-bootstrap-v3-20260929-003", "9df6c741e2432c0cac9fe2f2c7d90348a61d75b28098146018467050ef21ab9a"),
|
||||||
):
|
):
|
||||||
self.assertEqual(hashlib.sha256(build_artifact.bundle(patch)).hexdigest(), sha)
|
self.assertEqual(hashlib.sha256(build_artifact.bundle(patch)).hexdigest(), sha)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,106 @@
|
|||||||
|
import io
|
||||||
|
import json
|
||||||
|
from contextlib import redirect_stdout
|
||||||
|
from pathlib import Path
|
||||||
|
import tempfile
|
||||||
|
from types import SimpleNamespace
|
||||||
|
import unittest
|
||||||
|
from unittest import mock
|
||||||
|
|
||||||
|
import build_artifact
|
||||||
|
from test_bootstrap import RUNNER, container_info
|
||||||
|
|
||||||
|
|
||||||
|
def nas_capabilities():
|
||||||
|
return {"Architecture": "x86_64", "CPUSet": True, "CPUShares": True,
|
||||||
|
"CgroupVersion": "1", "CpuCfsPeriod": False, "CpuCfsQuota": False,
|
||||||
|
"KernelVersion": "4.4.302+", "MemTotal": 16743616512,
|
||||||
|
"MemoryLimit": True, "NCPU": 8, "OSType": "linux",
|
||||||
|
"PidsLimit": False, "ServerVersion": "24.0.2", "SwapLimit": True}
|
||||||
|
|
||||||
|
|
||||||
|
def v4_container():
|
||||||
|
info = container_info()
|
||||||
|
info["State"]["Pid"] = 1234
|
||||||
|
info["HostConfig"].update({"NanoCpus": 0, "CpuShares": 64, "CpusetCpus": "7",
|
||||||
|
"PidsLimit": None, "MemorySwap": 512 * 1024 ** 2})
|
||||||
|
return info
|
||||||
|
|
||||||
|
|
||||||
|
class SynologyV4Tests(unittest.TestCase):
|
||||||
|
def query(self, info, affinity=None):
|
||||||
|
with mock.patch.object(RUNNER.subprocess, "run", return_value=SimpleNamespace(stdout=json.dumps(info))):
|
||||||
|
with mock.patch.object(RUNNER.os, "sched_getaffinity", create=True, return_value=set(range(8)) if affinity is None else affinity):
|
||||||
|
with redirect_stdout(io.StringIO()):
|
||||||
|
return RUNNER.gitea_ci_host_capabilities(RUNNER.GITEA_CI_V4_ENTRIES)
|
||||||
|
|
||||||
|
def test_actual_nas_capability_matrix_passes_without_cfs_or_pids(self):
|
||||||
|
report = self.query(nas_capabilities())
|
||||||
|
self.assertFalse(report["PidsLimit"])
|
||||||
|
self.assertFalse(report["CpuCfsQuota"])
|
||||||
|
self.assertTrue(report["CPUSet"])
|
||||||
|
|
||||||
|
def test_required_supported_controls_are_not_optional(self):
|
||||||
|
for key in ("CPUSet", "CPUShares", "MemoryLimit", "SwapLimit"):
|
||||||
|
info = nas_capabilities()
|
||||||
|
info[key] = False
|
||||||
|
with self.subTest(key=key), self.assertRaisesRegex(RUNNER.DeployError, key):
|
||||||
|
self.query(info)
|
||||||
|
|
||||||
|
def test_cpu7_must_exist_and_be_available(self):
|
||||||
|
info = nas_capabilities()
|
||||||
|
info["NCPU"] = 4
|
||||||
|
with self.assertRaisesRegex(RUNNER.DeployError, "eight logical"):
|
||||||
|
self.query(info)
|
||||||
|
with self.assertRaisesRegex(RUNNER.DeployError, "CPU7 affinity"):
|
||||||
|
self.query(nas_capabilities(), affinity={0, 1})
|
||||||
|
|
||||||
|
def test_exact_runtime_cpu_affinity_memory_swap_and_no_pids_contract(self):
|
||||||
|
with mock.patch.object(RUNNER.os, "sched_getaffinity", create=True, return_value={7}) as affinity:
|
||||||
|
RUNNER.accept_gitea_ci_container(v4_container(), RUNNER.GITEA_CI_V4_ENTRIES)
|
||||||
|
affinity.assert_called_once_with(1234)
|
||||||
|
|
||||||
|
def test_broad_affinity_unbounded_swap_or_reintroduced_unsupported_limit_rejected(self):
|
||||||
|
for field, value in (("CpusetCpus", "0-7"), ("MemorySwap", -1), ("Memory", 0),
|
||||||
|
("NanoCpus", 500000000), ("PidsLimit", 128), ("CpuShares", 0)):
|
||||||
|
info = v4_container()
|
||||||
|
info["HostConfig"][field] = value
|
||||||
|
with mock.patch.object(RUNNER.os, "sched_getaffinity", create=True, return_value={7}):
|
||||||
|
with self.subTest(field=field), self.assertRaises(RUNNER.DeployError):
|
||||||
|
RUNNER.accept_gitea_ci_container(info, RUNNER.GITEA_CI_V4_ENTRIES)
|
||||||
|
with mock.patch.object(RUNNER.os, "sched_getaffinity", create=True, return_value={0, 7}):
|
||||||
|
with self.assertRaisesRegex(RUNNER.DeployError, "CPU7 affinity"):
|
||||||
|
RUNNER.accept_gitea_ci_container(v4_container(), RUNNER.GITEA_CI_V4_ENTRIES)
|
||||||
|
|
||||||
|
def test_affinity_requires_a_positive_numeric_runtime_pid(self):
|
||||||
|
for pid in (None, 0, -1, True, "1234"):
|
||||||
|
with self.subTest(pid=pid), self.assertRaisesRegex(RUNNER.DeployError, "process identity"):
|
||||||
|
RUNNER.gitea_ci_check_affinity(pid, exact=True)
|
||||||
|
|
||||||
|
def test_v4_bundle_pins_same_single_cpu_for_daemon_and_job(self):
|
||||||
|
patch = "gitea-ci-bootstrap-v4-test-001"
|
||||||
|
data = build_artifact.bundle(patch)
|
||||||
|
self.assertEqual(data, build_artifact.bundle(patch))
|
||||||
|
with tempfile.TemporaryDirectory() as directory:
|
||||||
|
root = Path(directory)
|
||||||
|
artifact = root / "test.tgz"
|
||||||
|
artifact.write_bytes(data)
|
||||||
|
target = root / "unpacked"
|
||||||
|
target.mkdir()
|
||||||
|
_, entries, payload = RUNNER.load_artifact(artifact, target)
|
||||||
|
self.assertEqual(tuple(entries), RUNNER.GITEA_CI_V4_ENTRIES)
|
||||||
|
compose = (payload / "docker-compose.gitea-ci.yml").read_text()
|
||||||
|
runner = (payload / "runner.yaml").read_text()
|
||||||
|
self.assertIn('cpuset: "7"', compose)
|
||||||
|
self.assertIn('memswap_limit: 512m', compose)
|
||||||
|
self.assertNotIn('pids_limit:', compose)
|
||||||
|
self.assertIn('--cpuset-cpus=7', runner)
|
||||||
|
self.assertIn('--memory=2g --memory-swap=2g', runner)
|
||||||
|
self.assertNotIn('--pids-limit', runner)
|
||||||
|
(payload / "runner.yaml").write_text(runner.replace('--cpuset-cpus=7', '--cpuset-cpus=0-7'))
|
||||||
|
with self.assertRaisesRegex(RUNNER.DeployError, "immutable configuration"):
|
||||||
|
RUNNER.validate_gitea_ci_payload(payload, entries, patch)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
Reference in New Issue
Block a user