Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
769fd29dcf | ||
|
|
41e80643c0 | ||
|
|
7147d777ee | ||
|
|
10ecb741e7 | ||
|
|
04e50c7c17 | ||
|
|
611e16f62d | ||
|
|
f42dbc3f82 | ||
|
|
1415cc53c6 | ||
|
|
12dee8bf75 | ||
|
|
8de2b125e9 | ||
|
|
1c70b9e61a | ||
|
|
b7bf41057a | ||
|
|
1c2d5e9f7f |
@@ -3,5 +3,6 @@
|
|||||||
# Keep credentials, tokens, and keys in /srv/cc-ci/.testenv. The orchestrator
|
# Keep credentials, tokens, and keys in /srv/cc-ci/.testenv. The orchestrator
|
||||||
# loads this file first via cc-ci-plan/load-env.sh.
|
# loads this file first via cc-ci-plan/load-env.sh.
|
||||||
GITEA_USERNAME=autonomic-bot
|
GITEA_USERNAME=autonomic-bot
|
||||||
|
GITEA_URL=git.autonomic.zone
|
||||||
TINFOIL_MODEL=deepseek-v4-pro
|
TINFOIL_MODEL=deepseek-v4-pro
|
||||||
TINFOIL_BASE_URL=https://inference.tinfoil.sh/v1
|
TINFOIL_BASE_URL=https://inference.tinfoil.sh/v1
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ let
|
|||||||
nsadmin = "hostmaster.commoninternet.net"
|
nsadmin = "hostmaster.commoninternet.net"
|
||||||
records = [
|
records = [
|
||||||
"acme.commoninternet.net. NS ns-acme.commoninternet.net.",
|
"acme.commoninternet.net. NS ns-acme.commoninternet.net.",
|
||||||
|
"ns-acme.commoninternet.net. A 91.98.47.73",
|
||||||
]
|
]
|
||||||
debug = false
|
debug = false
|
||||||
|
|
||||||
@@ -27,9 +28,9 @@ let
|
|||||||
ip = "127.0.0.1"
|
ip = "127.0.0.1"
|
||||||
port = "8080"
|
port = "8080"
|
||||||
tls = "none"
|
tls = "none"
|
||||||
# Bootstrap registration is deliberately temporary. Once the single Lego
|
# The one Lego account was bootstrapped before this configuration was
|
||||||
# account exists, change this to true in a follow-up reviewed deployment.
|
# hardened. Updates authenticated by that account remain available.
|
||||||
disable_registration = false
|
disable_registration = true
|
||||||
corsorigins = []
|
corsorigins = []
|
||||||
|
|
||||||
[logconfig]
|
[logconfig]
|
||||||
@@ -56,6 +57,12 @@ in
|
|||||||
|
|
||||||
environment.etc."acme-dns/lego.env".source = legoEnvironment;
|
environment.etc."acme-dns/lego.env".source = legoEnvironment;
|
||||||
|
|
||||||
|
# The staging order has completed successfully. This marker permits the
|
||||||
|
# production ACME post-run hook to hand a renewed certificate to Traefik.
|
||||||
|
systemd.tmpfiles.rules = [
|
||||||
|
"f /var/lib/ci-certs/acme-production-enabled 0600 root root -"
|
||||||
|
];
|
||||||
|
|
||||||
networking.firewall = {
|
networking.firewall = {
|
||||||
allowedTCPPorts = [ 53 ];
|
allowedTCPPorts = [ 53 ];
|
||||||
allowedUDPPorts = [ 53 ];
|
allowedUDPPorts = [ 53 ];
|
||||||
@@ -130,15 +137,15 @@ in
|
|||||||
certs."ci.commoninternet.net" = {
|
certs."ci.commoninternet.net" = {
|
||||||
domain = "ci.commoninternet.net";
|
domain = "ci.commoninternet.net";
|
||||||
extraDomainNames = [ "*.ci.commoninternet.net" ];
|
extraDomainNames = [ "*.ci.commoninternet.net" ];
|
||||||
# The pinned Lego provider spells this `acmedns`; keep the service on
|
# Staging issuance succeeded using the permanent, narrowly delegated
|
||||||
# staging until the operator has installed the permanent CNAME.
|
# CNAME. Production uses the same restricted acme-dns account.
|
||||||
dnsProvider = "acmedns";
|
dnsProvider = "acmedns";
|
||||||
environmentFile = "/etc/acme-dns/lego.env";
|
environmentFile = "/etc/acme-dns/lego.env";
|
||||||
dnsResolver = "1.1.1.1:53";
|
dnsResolver = "1.1.1.1:53";
|
||||||
server = "https://acme-staging-v02.api.letsencrypt.org/directory";
|
server = "https://acme-v02.api.letsencrypt.org/directory";
|
||||||
postRun = ''
|
postRun = ''
|
||||||
# Production cutover creates this marker in a separate reviewed
|
# The production marker is deployed only after staging proves the
|
||||||
# deployment. Staging issuance must never replace the live cert.
|
# permanent CNAME and restricted acme-dns account work end to end.
|
||||||
if [ -e /var/lib/ci-certs/acme-production-enabled ]; then
|
if [ -e /var/lib/ci-certs/acme-production-enabled ]; then
|
||||||
${pkgs.systemd}/bin/systemctl --no-block start cc-ci-acme-traefik-handoff.service
|
${pkgs.systemd}/bin/systemctl --no-block start cc-ci-acme-traefik-handoff.service
|
||||||
fi
|
fi
|
||||||
|
|||||||
+4
-11
@@ -37,17 +37,10 @@
|
|||||||
bridge_drone_token = { };
|
bridge_drone_token = { };
|
||||||
bridge_gitea_token = { };
|
bridge_gitea_token = { };
|
||||||
|
|
||||||
# Phase-1c C2: the wildcard TLS cert+key are now sops secrets (in cc-ci-secrets), decrypted at
|
# The wildcard certificate and private key are issued and renewed locally
|
||||||
# activation to /var/lib/ci-certs/live/{fullchain.pem,privkey.pem} — the exact path the traefik
|
# by security.acme. Do not restore the retired SOPS pair here: activation
|
||||||
# reconcile (modules/proxy.nix) already reads. Replaces the prior operator-drops-a-cert-file step.
|
# would overwrite a freshly renewed ACME certificate before Traefik can
|
||||||
wildcard_cert = {
|
# consume it.
|
||||||
path = "/var/lib/ci-certs/live/fullchain.pem";
|
|
||||||
mode = "0444"; # leaf+intermediate chain — not secret
|
|
||||||
};
|
|
||||||
wildcard_key = {
|
|
||||||
path = "/var/lib/ci-certs/live/privkey.pem";
|
|
||||||
mode = "0400"; # private key — root only
|
|
||||||
};
|
|
||||||
|
|
||||||
# Phase-2 rate-limit fix (Class A1 registry creds, operator-2026-05-28). Authenticated Docker
|
# Phase-2 rate-limit fix (Class A1 registry creds, operator-2026-05-28). Authenticated Docker
|
||||||
# Hub pulls (200/6h per-account) replace the exhausted 100/6h shared-IP anonymous limit that
|
# Hub pulls (200/6h per-account) replace the exhausted 100/6h shared-IP anonymous limit that
|
||||||
|
|||||||
@@ -55,7 +55,29 @@ def wildcard_secret_version(cert_dir: str = CERT_DIR) -> str:
|
|||||||
return "v" + digest[:16]
|
return "v" + digest[:16]
|
||||||
|
|
||||||
|
|
||||||
def _traefik_setup(recipe: str, domain: str, version: str) -> None:
|
def _traefik_requires_certificate_rollout(domain: str, secret_version: str) -> bool:
|
||||||
|
"""Whether Traefik's active service still references an older cert version."""
|
||||||
|
stack = lifecycle._stack_name(domain) # noqa: SLF001
|
||||||
|
service = f"{stack}_app"
|
||||||
|
result = _run(
|
||||||
|
[
|
||||||
|
"docker",
|
||||||
|
"service",
|
||||||
|
"inspect",
|
||||||
|
service,
|
||||||
|
"--format",
|
||||||
|
"{{range .Spec.TaskTemplate.ContainerSpec.Secrets}}{{.SecretName}} {{end}}",
|
||||||
|
],
|
||||||
|
timeout=30,
|
||||||
|
)
|
||||||
|
expected = {
|
||||||
|
f"{stack}_ssl_cert_{secret_version}",
|
||||||
|
f"{stack}_ssl_key_{secret_version}",
|
||||||
|
}
|
||||||
|
return not expected.issubset(set(result.stdout.split()))
|
||||||
|
|
||||||
|
|
||||||
|
def _traefik_setup(recipe: str, domain: str, version: str) -> bool:
|
||||||
"""Per-app config for the traefik reverse-proxy reconcile — preserves EXACTLY what the prior
|
"""Per-app config for the traefik reverse-proxy reconcile — preserves EXACTLY what the prior
|
||||||
proxy.nix bash reconcile did (wildcard/file-provider mode serving the pre-issued cert as
|
proxy.nix bash reconcile did (wildcard/file-provider mode serving the pre-issued cert as
|
||||||
ssl_cert/ssl_key swarm secrets; NO ACME). Uses the proven abra.env_set (newline-safe, unlike the
|
ssl_cert/ssl_key swarm secrets; NO ACME). Uses the proven abra.env_set (newline-safe, unlike the
|
||||||
@@ -118,6 +140,7 @@ def _traefik_setup(recipe: str, domain: str, version: str) -> None:
|
|||||||
timeout=120,
|
timeout=120,
|
||||||
check=True,
|
check=True,
|
||||||
)
|
)
|
||||||
|
return _traefik_requires_certificate_rollout(domain, secret_version)
|
||||||
|
|
||||||
|
|
||||||
SPECS: dict[str, dict] = {
|
SPECS: dict[str, dict] = {
|
||||||
@@ -476,8 +499,9 @@ def reconcile(app: str) -> str:
|
|||||||
# Per-app config/secrets: a spec may provide its own `setup` (traefik's cert/file-provider wiring);
|
# Per-app config/secrets: a spec may provide its own `setup` (traefik's cert/file-provider wiring);
|
||||||
# otherwise the default keycloak-shaped path (app new + DOMAIN/LETS_ENCRYPT + generate secrets).
|
# otherwise the default keycloak-shaped path (app new + DOMAIN/LETS_ENCRYPT + generate secrets).
|
||||||
setup = spec.get("setup")
|
setup = spec.get("setup")
|
||||||
|
setup_needs_rollout = False
|
||||||
if setup:
|
if setup:
|
||||||
setup(recipe, domain, latest)
|
setup_needs_rollout = bool(setup(recipe, domain, latest))
|
||||||
else:
|
else:
|
||||||
ensure_app_config(recipe, domain, latest)
|
ensure_app_config(recipe, domain, latest)
|
||||||
ensure_secrets(domain)
|
ensure_secrets(domain)
|
||||||
@@ -495,6 +519,20 @@ def reconcile(app: str) -> str:
|
|||||||
write_last_good(recipe, target)
|
write_last_good(recipe, target)
|
||||||
return f"deployed-fresh:{target}"
|
return f"deployed-fresh:{target}"
|
||||||
|
|
||||||
|
# A certificate rotation changes Traefik's immutable Swarm secrets but
|
||||||
|
# must not be held hostage by an unrelated recipe-major upgrade policy.
|
||||||
|
# Redeploy the current recipe version so its compose spec references the
|
||||||
|
# just-created cert/key secret pair, then apply the usual health gate.
|
||||||
|
if setup_needs_rollout:
|
||||||
|
if not current:
|
||||||
|
raise RuntimeError(f"{app} has services but no current version")
|
||||||
|
print(f"[{app}] certificate changed → redeploy {current}", flush=True)
|
||||||
|
deploy_version(recipe, domain, current, dt)
|
||||||
|
if not wait_healthy(spec):
|
||||||
|
raise RuntimeError(f"{app} certificate rollout {current} did not become healthy")
|
||||||
|
write_last_good(recipe, current)
|
||||||
|
return f"certificate-rolled-out:{current}"
|
||||||
|
|
||||||
# Deployed & already on latest → converge to a no-op (commit last-good if healthy).
|
# Deployed & already on latest → converge to a no-op (commit last-good if healthy).
|
||||||
if current == latest:
|
if current == latest:
|
||||||
if wait_healthy(spec, timeout=60):
|
if wait_healthy(spec, timeout=60):
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
from types import SimpleNamespace
|
||||||
|
|
||||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", ".."))
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "runner"))
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "runner"))
|
||||||
@@ -115,6 +116,20 @@ def test_traefik_spec_is_stateless_with_setup():
|
|||||||
assert "setup" not in wr.SPECS["keycloak"]
|
assert "setup" not in wr.SPECS["keycloak"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_traefik_certificate_rollout_detects_active_secret_version(monkeypatch):
|
||||||
|
stack = "traefik_ci_commoninternet_net"
|
||||||
|
monkeypatch.setattr(wr.lifecycle, "_stack_name", lambda _domain: stack)
|
||||||
|
monkeypatch.setattr(
|
||||||
|
wr,
|
||||||
|
"_run",
|
||||||
|
lambda *_args, **_kwargs: SimpleNamespace(
|
||||||
|
stdout=f"{stack}_ssl_cert_vnew {stack}_ssl_key_vnew"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
assert not wr._traefik_requires_certificate_rollout("traefik.ci.commoninternet.net", "vnew")
|
||||||
|
assert wr._traefik_requires_certificate_rollout("traefik.ci.commoninternet.net", "vold")
|
||||||
|
|
||||||
|
|
||||||
def test_manual_migration_markers():
|
def test_manual_migration_markers():
|
||||||
assert wr.notes_flag_manual_migration("This release requires a MANUAL MIGRATION of the DB.")
|
assert wr.notes_flag_manual_migration("This release requires a MANUAL MIGRATION of the DB.")
|
||||||
assert wr.notes_flag_manual_migration("Breaking change: action required before upgrade.")
|
assert wr.notes_flag_manual_migration("Breaking change: action required before upgrade.")
|
||||||
|
|||||||
Reference in New Issue
Block a user