128 lines
7.3 KiB
Markdown
128 lines
7.3 KiB
Markdown
# Synology CI foundation
|
|
|
|
This additive `gitea-ci` component creates only the Gitea build runner. It does
|
|
not activate automatic production apply, change Gitea itself, recreate Device
|
|
Core, open a port or modify application databases. Track activation in
|
|
DCPLATFORM-37; the canonical runner extension belongs to DCPLATFORM-21.
|
|
|
|
Initial policy: Device Core push to main automatically qualifies, then deploys
|
|
once the separate production controller and recurring release contract have
|
|
been accepted. Later repositories receive explicit registrations/policies.
|
|
|
|
## Reviewed contract
|
|
|
|
- Root: `/volume1/docker/nodedc-gitea-ci`.
|
|
- Compose project: `nodedc-gitea-ci`; selected service: `build-runner`.
|
|
- Three fixed data files: Compose, runner config, versioned descriptor.
|
|
- 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
|
|
these two digests. No repository-provided image names or commands.
|
|
- Current Synology v3 profile: daemon CPU shares 64, 512 MiB RAM, 128 PIDs,
|
|
readonly root filesystem. Build jobs: one at a time, CPU shares 128,
|
|
2 GiB RAM, 256 PIDs, no privileged mode, no host bind
|
|
mounts, no host execution label and no Docker socket in job containers.
|
|
- CPU shares give low relative priority during contention, not a hard CPU
|
|
quota. Job swap uses the Docker/host default. The v1/v2 historical profiles
|
|
retain their exact 0.5/1 NanoCPU quotas and original immutable config hashes.
|
|
- No published ports or host networking. Runner cache and metrics listeners
|
|
are disabled. Communication uses outbound HTTPS to the existing Gitea.
|
|
- Only the trusted runner daemon mounts the Docker socket. That daemon is
|
|
privileged infrastructure even with dropped Linux capabilities: access to
|
|
Docker is host authority. It is not passed to repository jobs.
|
|
- The first worker is registered for `SILVER/NODEDC_DEVICE_CORE`; sharing with
|
|
other repositories requires a reviewed enrollment/registry transition.
|
|
|
|
## Enrollment, separately from the artifact
|
|
|
|
Use the authenticated Gitea API to obtain the Device Core repository runner
|
|
registration token. Do not copy a personal Git token into the runner.
|
|
Stage `/volume1/docker/nodedc-deploy/runtime/gitea-ci/enrollment.pending.json`
|
|
through the operator's authenticated SMB session, containing only the exact
|
|
repository identity and its registration token. Never put this file in Git,
|
|
inbox, artifact payload, logs, Ops text or chat. This is a temporary handoff,
|
|
not the runtime secret. The NAS owner must be `dctouch` or root. The v2
|
|
preflight opens it with `O_NOFOLLOW`, rejects symlinks/hardlinks/special files,
|
|
limits the input to 2048 bytes, validates its schema and checks for concurrent
|
|
changes. Plan reports only safe filesystem metadata and does not change rights.
|
|
|
|
On 2026-09-29 the first v1 plan rejected this file's NAS metadata even though
|
|
the Mac SMB mount displayed 0700/regular/nlink1. A Mac `chmod 600` and a
|
|
successful Mac stat are not proof of the actual NAS permissions. V1's strict
|
|
private-file check is retained; use the explicit v2 import transition for SMB.
|
|
|
|
V2 apply creates the private file on NAS as root: `secrets/registration-token`
|
|
is 0600, its directory is 0700. Publication is atomic without overwriting an
|
|
existing identity, file and directory entries are fsynced, then the private
|
|
copy is revalidated. Only after that is the staging input removed. A mismatch
|
|
with an existing private copy is rejected. An interrupted apply can reuse the
|
|
same verified private copy after the canonical failure/retry review. Gitea
|
|
creates the persistent `/data/.runner` identity on first start. Neither private
|
|
file is part of the artifact, source backup, journal or diagnostic output.
|
|
|
|
The bootstrap accepts no existing installed CI descriptor or CI container.
|
|
Preflight reads Docker's actual resource capabilities before any runtime
|
|
mutation, and reports only allowlisted version/kernel/resource fields. V3
|
|
requires Linux amd64 plus CPU shares, memory and PIDs controls. V1/v2 additionally
|
|
require CFS period/quota and swap accounting. Missing or non-boolean 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 pinned images, but Docker rejected `NanoCPUs`: this NAS kernel does not
|
|
provide the needed CFS bandwidth control. Canonical rollback completed with
|
|
`ok:gitea-ci-bootstrap`; the private enrollment is retained for v3 reuse.
|
|
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
|
|
`bootstrap-v3.json`; historical payloads remain byte-for-byte reproducible.
|
|
|
|
## Build and install
|
|
|
|
From a clean Platform commit:
|
|
|
|
```sh
|
|
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>
|
|
```
|
|
|
|
The first use requires promotion of the reviewed root runner through the
|
|
separate atomic administrative gate and fresh `verify-install`. Stage the
|
|
immutable `.tgz` in the canonical inbox and inspect its lifecycle. Obtain a
|
|
fresh `nodedc-deploy plan`, review exact scope, then apply that artifact once.
|
|
|
|
`apply` snapshots the source partition and identities of all preexisting
|
|
containers. Acceptance checks the pinned image, Compose identity, mounts,
|
|
resource limits, privileges and absence of port publications. It requires
|
|
registration plus ten seconds of stable daemon operation and unchanged
|
|
preexisting container identities. All secrets and application data are outside
|
|
the artifact/backup source partition.
|
|
|
|
If startup or acceptance fails, rollback removes only `build-runner` and
|
|
restores only the three source paths. Runner registration and enrollment are
|
|
preserved for diagnosis. A failed attempt may leave an offline registration in
|
|
Gitea; do not create another token or delete persistent identity blindly.
|
|
The global failed-artifact replay rule remains in force.
|
|
|
|
After `deploy-ok`, verify online registration and a real qualification job via
|
|
Gitea API/UI. This is separate functional acceptance; do not ask an operator
|
|
to re-prove Docker/runtime checks with NAS shell commands. Do not describe the
|
|
runner bootstrap or a green build as a completed automatic production deploy.
|
|
|
|
## Validation baseline
|
|
|
|
Installed predecessor confirmed by the operator on 2026-09-29:
|
|
`f21936f131365bd3993e2d746e332538d628ba50ef62c1cce833161171ffde47`,
|
|
Python 3.8.15, `verify-install-ok`. This matches Platform commit
|
|
`11b73e64681f83aa2ebfd89ef266d3be2869f7e1`. The older SMB runner copy is not the
|
|
installed authority. Historical Gitea recovery guards remain unchanged.
|
|
|
|
Tests cover deterministic packaging, exact runtime/payload boundaries, secret
|
|
file handling, bootstrap reuse rejection, preserved container identity, real
|
|
synthetic-host apply receipts, and failed-health source rollback with runtime
|
|
registration retained. Existing Platform/Device/Gitea regression suites are
|
|
also required before promotion.
|
|
|
|
References: [official runner configuration](https://docs.gitea.com/runner/configuration/),
|
|
[Docker installation](https://docs.gitea.com/runner/installation/docker/),
|
|
[Docker resource constraints](https://docs.docker.com/engine/containers/resource_constraints/),
|
|
[Docker capabilities API](https://docs.docker.com/reference/api/engine/version/v1.40/).
|