Enable Actions on existing Gitea through an exact configuration transition
This commit is contained in:
@@ -70,6 +70,15 @@ GITEA_CI_V4_SOURCE_SHA256 = {
|
||||
"docker-compose.gitea-ci.yml": "dd218ef77a6505042484bbdb5cb329da043801a42e13af746fc8ba23c05e0f9c",
|
||||
"runner.yaml": "94d8e4d8345b2b5bc7c8923bff7c31ff59083ec7115d633af10152b93bcd9da6",
|
||||
}
|
||||
GITEA_ACTIONS_ROOT = Path("/volume1/docker/nodedc-gitea-actions")
|
||||
GITEA_ACTIONS_ENTRY = "deployment/actions-enable-v1.json"
|
||||
GITEA_ACTIONS_LEGACY = Path("/volume1/docker/gitea-clean-standalone-v1")
|
||||
GITEA_ACTIONS_CONFIG = Path("/volume1/docker/gitea-clean-20260820/config/app.ini")
|
||||
GITEA_ACTIONS_CONTAINER = "clean-gitea-20260820"
|
||||
GITEA_ACTIONS_IMAGE = "docker.gitea.com/gitea:1.27.2-rootless@sha256:7de5f49ada687b8c8d2938f547cdb7634839764ba51f297457bae35cee3abd2c"
|
||||
GITEA_ACTIONS_BEFORE = "38a60b2fff6b40de6bb97959eb0abd1c7797aba9b1e9760f66f25f79cd337336"
|
||||
GITEA_ACTIONS_AFTER = "67d22244db2fd6217072d928969d1b694d89b8b0f5c73b4ff628733e72136b27"
|
||||
GITEA_ACTIONS_PING = "/api/actions/ping.v1.PingService/Ping"
|
||||
MAP_GATEWAY_SECRET_DIR = Path("/volume1/docker/nodedc-platform/secrets")
|
||||
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"
|
||||
@@ -3092,6 +3101,16 @@ COMPONENTS = {
|
||||
# separately registers the third stateless service.
|
||||
"services": ("device-control-core", "device-gateway"),
|
||||
},
|
||||
"gitea-actions-config": {
|
||||
"payload_root": GITEA_ACTIONS_ROOT,
|
||||
"compose_root": GITEA_ACTIONS_LEGACY,
|
||||
"compose_project": "clean-gitea",
|
||||
"compose_files": (GITEA_ACTIONS_LEGACY / "compose.yaml",),
|
||||
"compose_env_file": GITEA_ACTIONS_LEGACY / "production.env",
|
||||
"bootstrap_root": True,
|
||||
"compose_no_deps": True,
|
||||
"services": ("gitea",),
|
||||
},
|
||||
"gitea-ci": {
|
||||
"payload_root": GITEA_CI_ROOT,
|
||||
"compose_root": GITEA_CI_ROOT,
|
||||
@@ -4938,6 +4957,10 @@ def allowed_payload_path(component, rel):
|
||||
if reason:
|
||||
die(f"path rejected: {rel}: {reason}")
|
||||
|
||||
if component == "gitea-actions-config":
|
||||
if rel in ("deployment", GITEA_ACTIONS_ENTRY):
|
||||
return True
|
||||
die("Gitea Actions accepts only its activation descriptor")
|
||||
if component == "gitea-ci":
|
||||
if rel in GITEA_CI_ENTRIES + GITEA_CI_V2_ENTRIES + GITEA_CI_V3_ENTRIES + GITEA_CI_V4_ENTRIES or rel == "deployment":
|
||||
return True
|
||||
@@ -11544,6 +11567,8 @@ def load_artifact(artifact, work_dir):
|
||||
die(f"files.txt entry missing in payload: {rel}")
|
||||
|
||||
validate_payload_tree(manifest["component"], payload_dir, entries)
|
||||
if manifest["component"] == "gitea-actions-config":
|
||||
validate_gitea_actions_payload(payload_dir, entries, manifest["id"])
|
||||
if manifest["component"] == "gitea-ci":
|
||||
validate_gitea_ci_payload(payload_dir, entries, manifest["id"])
|
||||
if manifest["component"] == "mission-core-map-access":
|
||||
@@ -31405,6 +31430,236 @@ def rollback_map_access(root, backup_dir, entries, current_stamp):
|
||||
die("Map access rollback policy verification failed")
|
||||
|
||||
|
||||
def validate_gitea_actions_payload(payload_dir, entries, release_id):
|
||||
if tuple(entries) != (GITEA_ACTIONS_ENTRY,) or not re.fullmatch(
|
||||
r"gitea-actions-enable-v1-[a-zA-Z0-9._-]{1,65}", release_id):
|
||||
die("Gitea Actions transition identity mismatch")
|
||||
expected = {"schemaVersion": "nodedc.gitea.actions-enable.v1", "releaseId": release_id,
|
||||
"action": "enable-instance-actions", "service": "gitea",
|
||||
"productionDeployEnabled": False}
|
||||
if read_strict_json(payload_dir / GITEA_ACTIONS_ENTRY, "Gitea Actions descriptor") != expected:
|
||||
die("Gitea Actions descriptor mismatch")
|
||||
|
||||
|
||||
def gitea_actions_read_config():
|
||||
for parent in GITEA_ACTIONS_CONFIG.parents:
|
||||
if parent.is_symlink():
|
||||
die("Gitea Actions config parent symlink rejected")
|
||||
fd = os.open(str(GITEA_ACTIONS_CONFIG), os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK)
|
||||
with os.fdopen(fd, "rb") as stream:
|
||||
info = os.fstat(stream.fileno())
|
||||
if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1 or not 0 < info.st_size < 65536:
|
||||
die("Gitea Actions config metadata rejected")
|
||||
data = stream.read(65536)
|
||||
return data, info
|
||||
|
||||
|
||||
def gitea_actions_transform(data):
|
||||
# Never parse/re-serialize the full INI: unrelated settings and secrets retain exact bytes.
|
||||
if hashlib.sha256(data).hexdigest() != GITEA_ACTIONS_BEFORE:
|
||||
die("Gitea Actions config predecessor mismatch")
|
||||
matches = list(re.finditer(rb"(?ms)^\[actions\][ \t]*\r?\n(.*?)(?=^\[|\Z)", data))
|
||||
if len(matches) != 1:
|
||||
die("Gitea Actions section mismatch")
|
||||
match = matches[0]
|
||||
section, count = re.subn(rb"(?m)^(ENABLED[ \t]*=[ \t]*)false([ \t]*\r?)$",
|
||||
rb"\g<1>true\2", match.group(1))
|
||||
target = data[:match.start(1)] + section + data[match.end(1):]
|
||||
if count != 1 or hashlib.sha256(target).hexdigest() != GITEA_ACTIONS_AFTER:
|
||||
die("Gitea Actions exact target mismatch")
|
||||
return target
|
||||
|
||||
|
||||
def gitea_actions_http(base, path, ping=False):
|
||||
request = urllib.request.Request(base + path)
|
||||
if ping:
|
||||
request = urllib.request.Request(base + path, data=b'{"data":"nodedc-ci-probe"}',
|
||||
headers={"Content-Type": "application/json", "Connect-Protocol-Version": "1"})
|
||||
# Instance/paths are constants in this runner; no credential or arbitrary URL is accepted.
|
||||
opener = urllib.request.build_opener(urllib.request.ProxyHandler({}))
|
||||
try:
|
||||
with opener.open(request, timeout=8) as response:
|
||||
if response.geturl() != base + path:
|
||||
die("Gitea Actions endpoint redirected")
|
||||
raw = response.read(4097)
|
||||
if len(raw) > 4096:
|
||||
die("Gitea Actions response too large")
|
||||
return response.status, json.loads(raw)
|
||||
except urllib.error.HTTPError as error:
|
||||
return error.code, None
|
||||
except (urllib.error.URLError, OSError, ValueError):
|
||||
die("Gitea Actions endpoint unavailable (DNS/TLS/network/JSON)")
|
||||
|
||||
|
||||
def require_gitea_actions_ping(base="https://git.dcserve.ru"):
|
||||
status, value = gitea_actions_http(base, GITEA_ACTIONS_PING, ping=True)
|
||||
if status != 200 or value != {"data": "Hello, nodedc-ci-probe!"}:
|
||||
die(f"Gitea Actions RPC unavailable: HTTP {status}; enable instance Actions before CI bootstrap")
|
||||
|
||||
|
||||
def gitea_actions_container(require_running=True):
|
||||
info = inspect_container(GITEA_ACTIONS_CONTAINER)
|
||||
config = info.get("Config", {})
|
||||
labels = config.get("Labels", {})
|
||||
if (info.get("Name") != "/" + GITEA_ACTIONS_CONTAINER
|
||||
or config.get("Image") != GITEA_ACTIONS_IMAGE
|
||||
or labels.get("com.docker.compose.project") != "clean-gitea"
|
||||
or labels.get("com.docker.compose.service") != "gitea"
|
||||
or (require_running and not info.get("State", {}).get("Running"))
|
||||
or config.get("Cmd") != ["web", "--config", "/etc/gitea/app.ini"]
|
||||
or any(x.upper().startswith("GITEA__ACTIONS__") for x in config.get("Env", []))):
|
||||
die("Gitea Actions existing container identity mismatch")
|
||||
ports = info.get("HostConfig", {}).get("PortBindings")
|
||||
if ports != {"3000/tcp": [{"HostIp": "172.22.0.222", "HostPort": "3000"}],
|
||||
"2222/tcp": [{"HostIp": "0.0.0.0", "HostPort": "4022"}]}:
|
||||
die("Gitea Actions existing port bindings mismatch")
|
||||
mounts = {x.get("Destination"): (x.get("Source"), x.get("RW")) for x in info.get("Mounts", [])}
|
||||
if (mounts.get("/etc/gitea/app.ini") != (str(GITEA_ACTIONS_CONFIG), False)
|
||||
or mounts.get("/var/lib/gitea") != (str(GITEA_ACTIONS_CONFIG.parent.parent / "data"), True)):
|
||||
die("Gitea Actions existing data/config mounts mismatch")
|
||||
networks = info.get("NetworkSettings", {}).get("Networks", {})
|
||||
network = networks.get("clean-gitea_clean_gitea", {})
|
||||
if (set(networks) != {"clean-gitea_clean_gitea"}
|
||||
or (info.get("State", {}).get("Running") and network.get("IPAddress") != "172.22.27.2")):
|
||||
die("Gitea Actions existing network mismatch")
|
||||
return info
|
||||
|
||||
|
||||
def gitea_actions_fingerprint(info):
|
||||
fields = {key: info.get(key) for key in ("Id", "Image", "Config", "HostConfig", "Mounts")}
|
||||
fields["networks"] = sorted(info.get("NetworkSettings", {}).get("Networks", {}))
|
||||
return hashlib.sha256(json.dumps(fields, sort_keys=True).encode()).hexdigest()
|
||||
|
||||
|
||||
def preflight_gitea_actions():
|
||||
expected = {"compose.yaml": "c21ef87833f87623f8352477d2b541d0a0f48769d8f9f79251d58033e90197ff",
|
||||
"production.env": "9ebbf8638e035dddca25fd455b2ac4d4b6db306e1a6a4debd973b133fdeb5bb7"}
|
||||
for rel, digest in expected.items():
|
||||
path = GITEA_ACTIONS_LEGACY / rel
|
||||
if any(parent.is_symlink() for parent in (path, *path.parents)) or sha256_file(path) != digest:
|
||||
die("Gitea Actions effective Compose context mismatch")
|
||||
if (GITEA_ACTIONS_ROOT / GITEA_ACTIONS_ENTRY).exists():
|
||||
die("Gitea Actions activation is already installed")
|
||||
data, metadata = gitea_actions_read_config()
|
||||
gitea_actions_transform(data)
|
||||
info = gitea_actions_container()
|
||||
if info.get("Image") != inspect_local_image(GITEA_ACTIONS_IMAGE, "Gitea Actions preserved image"):
|
||||
die("Gitea Actions existing image digest mismatch")
|
||||
if info.get("State", {}).get("Health", {}).get("Status") != "healthy":
|
||||
die("Gitea Actions predecessor must be healthy")
|
||||
status, version = gitea_actions_http("http://172.22.27.2:3000", "/api/v1/version")
|
||||
if status != 200 or version != {"version": "1.27.2"}:
|
||||
die("Gitea Actions predecessor version mismatch")
|
||||
status, _ = gitea_actions_http("http://172.22.27.2:3000", GITEA_ACTIONS_PING, ping=True)
|
||||
if status != 404:
|
||||
die("Gitea Actions predecessor must have inactive RPC")
|
||||
inventory = gitea_ci_inventory()
|
||||
inventory.pop(info["Id"], None)
|
||||
return {"config": data, "metadata": metadata, "containerId": info["Id"],
|
||||
"fingerprint": gitea_actions_fingerprint(info), "inventory": inventory}
|
||||
|
||||
|
||||
def gitea_actions_replace(expected_sha, data, metadata):
|
||||
current, current_stat = gitea_actions_read_config()
|
||||
if (hashlib.sha256(current).hexdigest() != expected_sha
|
||||
or (current_stat.st_uid, current_stat.st_gid, stat.S_IMODE(current_stat.st_mode)) !=
|
||||
(metadata.st_uid, metadata.st_gid, stat.S_IMODE(metadata.st_mode))):
|
||||
die("Gitea Actions config changed before atomic replacement")
|
||||
fd, name = tempfile.mkstemp(prefix=".actions-enable-", dir=str(GITEA_ACTIONS_CONFIG.parent))
|
||||
try:
|
||||
with os.fdopen(fd, "wb") as stream:
|
||||
os.fchown(stream.fileno(), metadata.st_uid, metadata.st_gid)
|
||||
os.fchmod(stream.fileno(), stat.S_IMODE(metadata.st_mode))
|
||||
stream.write(data)
|
||||
stream.flush()
|
||||
os.fsync(stream.fileno())
|
||||
if sha256_file(GITEA_ACTIONS_CONFIG) != expected_sha:
|
||||
die("Gitea Actions config changed during replacement")
|
||||
os.replace(name, str(GITEA_ACTIONS_CONFIG))
|
||||
fsync_directory(GITEA_ACTIONS_CONFIG.parent)
|
||||
finally:
|
||||
if os.path.exists(name):
|
||||
os.unlink(name)
|
||||
|
||||
|
||||
def apply_gitea_actions(before, backup_dir):
|
||||
private = RUNTIME_DIR / "gitea-actions" / backup_dir.name
|
||||
for parent in (private, *private.parents):
|
||||
if parent.is_symlink():
|
||||
die("Gitea Actions private backup parent symlink rejected")
|
||||
private.parent.mkdir(mode=0o700, parents=True, exist_ok=True)
|
||||
os.chown(str(private.parent), 0, 0)
|
||||
private.parent.chmod(0o700)
|
||||
private.mkdir(mode=0o700)
|
||||
fd = os.open(str(private / "app.ini.before"), os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0o600)
|
||||
with os.fdopen(fd, "wb") as stream:
|
||||
os.fchown(stream.fileno(), 0, 0)
|
||||
stream.write(before["config"])
|
||||
stream.flush()
|
||||
os.fsync(stream.fileno())
|
||||
fsync_directory(private)
|
||||
fsync_directory(private.parent)
|
||||
fsync_directory(RUNTIME_DIR)
|
||||
receipt = {key: before[key] for key in ("containerId", "fingerprint", "inventory")}
|
||||
receipt.update({"configBeforeSha256": GITEA_ACTIONS_BEFORE, "configAfterSha256": GITEA_ACTIONS_AFTER})
|
||||
(backup_dir / "gitea-actions-before.json").write_text(json.dumps(receipt, sort_keys=True) + "\n")
|
||||
if gitea_actions_fingerprint(gitea_actions_container()) != before["fingerprint"]:
|
||||
die("Gitea Actions runtime changed before mutation")
|
||||
gitea_actions_replace(GITEA_ACTIONS_BEFORE, gitea_actions_transform(before["config"]), before["metadata"])
|
||||
subprocess.run([str(DOCKER), "restart", "--time", "60", before["containerId"]],
|
||||
check=True, capture_output=True, timeout=90)
|
||||
|
||||
|
||||
def accept_gitea_actions(before, enabled=True):
|
||||
deadline = time.monotonic() + 120
|
||||
while True:
|
||||
try:
|
||||
info = gitea_actions_container()
|
||||
if gitea_actions_fingerprint(info) != before["fingerprint"]:
|
||||
die("Gitea Actions runtime configuration drift")
|
||||
expected = GITEA_ACTIONS_AFTER if enabled else GITEA_ACTIONS_BEFORE
|
||||
if sha256_file(GITEA_ACTIONS_CONFIG) != expected:
|
||||
die("Gitea Actions config acceptance mismatch")
|
||||
status, version = gitea_actions_http("http://172.22.27.2:3000", "/api/v1/version")
|
||||
if status != 200 or version != {"version": "1.27.2"}:
|
||||
die("Gitea Actions version acceptance mismatch")
|
||||
status, ping = gitea_actions_http("http://172.22.27.2:3000", GITEA_ACTIONS_PING, ping=True)
|
||||
if enabled:
|
||||
if status != 200 or ping != {"data": "Hello, nodedc-ci-probe!"}:
|
||||
die("Gitea Actions RPC acceptance mismatch")
|
||||
elif status != 404:
|
||||
die("Gitea Actions rollback RPC acceptance mismatch")
|
||||
if info.get("State", {}).get("Health", {}).get("Status") != "healthy":
|
||||
die("Gitea Actions waiting for health")
|
||||
inventory = gitea_ci_inventory()
|
||||
inventory.pop(before["containerId"], None)
|
||||
if inventory != before["inventory"]:
|
||||
die("Gitea Actions preserved inventory mismatch")
|
||||
print("gitea_actions_accept=" + ("enabled" if enabled else "restored-disabled") + ";data-and-other-services=preserved")
|
||||
return
|
||||
except DeployError:
|
||||
if time.monotonic() >= deadline:
|
||||
raise
|
||||
time.sleep(2)
|
||||
|
||||
|
||||
def rollback_gitea_actions(root, backup_dir, entries, current_stamp, before, runtime_started):
|
||||
if runtime_started:
|
||||
info = gitea_actions_container(require_running=False)
|
||||
if gitea_actions_fingerprint(info) != before["fingerprint"]:
|
||||
die("Gitea Actions rollback runtime drift")
|
||||
current = sha256_file(GITEA_ACTIONS_CONFIG)
|
||||
if current == GITEA_ACTIONS_AFTER:
|
||||
gitea_actions_replace(GITEA_ACTIONS_AFTER, before["config"], before["metadata"])
|
||||
elif current != GITEA_ACTIONS_BEFORE:
|
||||
die("Gitea Actions rollback refuses unrelated config drift")
|
||||
if current == GITEA_ACTIONS_AFTER or not info.get("State", {}).get("Running"):
|
||||
subprocess.run([str(DOCKER), "restart", "--time", "60", before["containerId"]],
|
||||
check=True, capture_output=True, timeout=90)
|
||||
accept_gitea_actions(before, enabled=False)
|
||||
restore_overlay_source(root, backup_dir, entries, current_stamp)
|
||||
|
||||
|
||||
def validate_gitea_ci_payload(payload_dir, entries, release_id):
|
||||
v2 = tuple(entries) == GITEA_CI_V2_ENTRIES
|
||||
v3 = tuple(entries) == GITEA_CI_V3_ENTRIES
|
||||
@@ -31648,6 +31903,7 @@ def preflight_gitea_ci(entries=GITEA_CI_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")
|
||||
gitea_ci_host_capabilities(entries)
|
||||
require_gitea_actions_ping()
|
||||
if gitea_ci_container_ids(own=True):
|
||||
die("Gitea CI bootstrap requires no existing CI containers")
|
||||
if tuple(entries) in (GITEA_CI_V2_ENTRIES, GITEA_CI_V3_ENTRIES, GITEA_CI_V4_ENTRIES):
|
||||
@@ -31779,8 +32035,37 @@ def accept_gitea_ci(entries=GITEA_CI_ENTRIES):
|
||||
time.sleep(2)
|
||||
|
||||
|
||||
def capture_gitea_ci_diagnostics(backup_dir):
|
||||
# Logs can contain tokens. Retain only fixed categories and counts, never raw text.
|
||||
report = {"containers": [], "rawLogsSaved": False}
|
||||
try:
|
||||
for container_id in gitea_ci_container_ids(own=True):
|
||||
result = subprocess.run([str(DOCKER), "logs", "--tail", "60", container_id],
|
||||
capture_output=True, text=True, timeout=10)
|
||||
text = (result.stdout + result.stderr).lower()
|
||||
signatures = {"dns": ("no such host", "server misbehaving"),
|
||||
"tls": ("x509", "tls handshake"),
|
||||
"network": ("connection refused", "i/o timeout", "no route to host"),
|
||||
"actions-disabled-or-route": ("404", "not found"),
|
||||
"token-rejected": ("registration token", "unauthenticated"),
|
||||
"filesystem": ("permission denied", "read-only file system"),
|
||||
"configuration": ("unmarshal", "yaml:", "invalid config"),
|
||||
"registered": ("runner registered successfully",)}
|
||||
reasons = [key for key, patterns in signatures.items() if any(p in text for p in patterns)]
|
||||
report["containers"].append({"id": container_id, "categories": reasons or ["unclassified"],
|
||||
"logLines": len(text.splitlines())})
|
||||
except Exception:
|
||||
report["diagnosticStatus"] = "unavailable"
|
||||
(backup_dir / "ci-startup-diagnostics.json").write_text(json.dumps(report, sort_keys=True) + "\n")
|
||||
print("ci_startup_diagnostics=" + json.dumps(report, sort_keys=True))
|
||||
|
||||
|
||||
def rollback_gitea_ci(root, backup_dir, entries, current_stamp, runtime_started):
|
||||
if runtime_started:
|
||||
try:
|
||||
capture_gitea_ci_diagnostics(backup_dir)
|
||||
except Exception:
|
||||
print("ci_startup_diagnostics=unavailable")
|
||||
stop_and_remove_compose_services("gitea-ci", ("build-runner",))
|
||||
restore_overlay_source(root, backup_dir, entries, current_stamp)
|
||||
if gitea_ci_container_ids(own=True):
|
||||
@@ -31849,6 +32134,8 @@ def plan_artifact(artifact):
|
||||
preflight_map_access(payload_dir, entries)
|
||||
if manifest["component"] == "gitea-ci":
|
||||
preflight_gitea_ci(entries)
|
||||
if manifest["component"] == "gitea-actions-config":
|
||||
preflight_gitea_actions()
|
||||
reject_failed_artifact_replay(manifest, sha)
|
||||
reject_terminal_engine_l2_failed_artifact(manifest, sha)
|
||||
reject_terminal_device_plane_foundation_artifact(manifest, sha)
|
||||
@@ -32432,6 +32719,14 @@ def plan_artifact(artifact):
|
||||
print(f"component={component}")
|
||||
print(f"type={manifest['type']}")
|
||||
print(f"payload_root={root}")
|
||||
if component == "gitea-actions-config":
|
||||
print("gitea_actions_transition=disabled-to-enabled;production_deploy=false")
|
||||
print("gitea_actions_runtime=restart-existing-clean-gitea-20260820;brief-web-and-ssh-interruption")
|
||||
print("gitea_actions_config=one-boolean-only;owner-and-mode=preserved")
|
||||
print(f"gitea_actions_config_before={GITEA_ACTIONS_BEFORE}")
|
||||
print(f"gitea_actions_config_after={GITEA_ACTIONS_AFTER}")
|
||||
print("gitea_actions_preserved=images,ports,mounts,databases,repositories,LFS,other-containers")
|
||||
print("gitea_actions_rollback=private-root0600-config-copy;restore-flag-and-restart-same-container")
|
||||
if component == "gitea-ci":
|
||||
print("ci_transition=bootstrap-build-runner;production_deploy=false")
|
||||
print("ci_ports=none;cache=false;metrics=false;capacity=1")
|
||||
@@ -37984,6 +38279,11 @@ process.stdout.write('engine-l2-closed-loop:0.7.0:cas+safe-profile+external-plan
|
||||
|
||||
|
||||
def run_healthchecks(component, entries=None, services=None):
|
||||
if component == "gitea-actions-config":
|
||||
if tuple(services or ()) != ("gitea",) or tuple(entries or ()) != (GITEA_ACTIONS_ENTRY,):
|
||||
die("Gitea Actions service/entry set mismatch")
|
||||
# Context-aware acceptance runs in apply immediately after the restart.
|
||||
return
|
||||
if component == "gitea-ci":
|
||||
if tuple(services or ()) != ("build-runner",):
|
||||
die("Gitea CI service set mismatch")
|
||||
@@ -39091,6 +39391,7 @@ def apply_artifact(artifact):
|
||||
engine_backend_initial_mode = None
|
||||
runtime_started = False
|
||||
gitea_ci_before = None
|
||||
gitea_actions_before = None
|
||||
current_stamp = stamp()
|
||||
|
||||
with DeployLock():
|
||||
@@ -39137,6 +39438,8 @@ def apply_artifact(artifact):
|
||||
preflight_map_access(payload_dir, entries)
|
||||
if component == "gitea-ci":
|
||||
gitea_ci_before = preflight_gitea_ci(entries)
|
||||
if component == "gitea-actions-config":
|
||||
gitea_actions_before = preflight_gitea_actions()
|
||||
artifact_only = component_artifact_only(component)
|
||||
defer_bootstrap_root = is_gitea_bootstrap_slice(
|
||||
component,
|
||||
@@ -39749,6 +40052,10 @@ def apply_artifact(artifact):
|
||||
# can be safely reconciled by recreating on that runtime.
|
||||
engine_backend_recreated = True
|
||||
run_compose(component, services, entries)
|
||||
elif component == "gitea-actions-config":
|
||||
runtime_started = True
|
||||
apply_gitea_actions(gitea_actions_before, backup_dir)
|
||||
accept_gitea_actions(gitea_actions_before)
|
||||
elif component == "device-plane":
|
||||
def mark_device_plane_runtime_started():
|
||||
nonlocal runtime_started
|
||||
@@ -39858,7 +40165,14 @@ def apply_artifact(artifact):
|
||||
and backup_dir is not None
|
||||
and root is not None
|
||||
):
|
||||
if component == "gitea-ci":
|
||||
if component == "gitea-actions-config":
|
||||
try:
|
||||
rollback_gitea_actions(root, backup_dir, entries, current_stamp,
|
||||
gitea_actions_before, runtime_started)
|
||||
rollback_status = "ok:gitea-actions-config"
|
||||
except Exception as rollback_exc:
|
||||
rollback_status = f"failed:{type(rollback_exc).__name__}"
|
||||
elif component == "gitea-ci":
|
||||
try:
|
||||
rollback_gitea_ci(root, backup_dir, entries, current_stamp, runtime_started)
|
||||
if gitea_ci_inventory() != gitea_ci_before:
|
||||
|
||||
Reference in New Issue
Block a user