fix(deploy): include legacy longconn profile during migration checks

The exported live-deployment baseline declares longconn under a Compose
profile. Default profile filtering can omit the already-running receiver
and make preflight report an unexpected service set.

Explicitly select only the known longconn profile for config and targeted
migration commands. Preserve strict service-set validation and report only
missing/extra service names, never resolved environment or secrets. Up still
targets connector/router with --no-deps, without starting another receiver.

Add regressions for profiled service omission and safe mismatch diagnostics.
Validation: 242 passed, 3 skipped (no real PostgreSQL), 30 existing dependency
warnings. Tool-specific coverage: 29 passed. Python 3.7 syntax and diff pass.
Actual ECS preflight must be rerun to verify its current service set; no
remote configuration, key material or running containers were changed.
This commit is contained in:
ex_tianzy
2026-11-04 12:27:49 +08:00
parent da1b4230b9
commit d3ce0099b7
4 changed files with 61 additions and 5 deletions
+14 -5
View File
@@ -61,7 +61,8 @@ def service(project, name):
def compose(plan, override=None):
args = ["docker", "compose", "--project-directory", plan["deployment_root"],
"--env-file", str(Path(plan["deployment_root"])/".env"), "-p", plan["project"]]
"--env-file", str(Path(plan["deployment_root"])/".env"), "-p", plan["project"],
"--profile", "longconn"]
for file in plan["compose_files"]:
args.extend(["-f", file])
if override:
@@ -69,6 +70,14 @@ def compose(plan, override=None):
return args
def require_services(names):
expected = {"connector","router","longconn","enrollment-signer","postgres","redis","edge"}
if set(names) != expected:
# Service names only, never resolved environment/configuration contents.
raise DeployError("unexpected Compose services; missing="+json.dumps(sorted(expected-set(names)))
+"; extra="+json.dumps(sorted(set(names)-expected)))
def profiles_from(path):
try:
data = json.loads(path.read_text(encoding="utf-8"))
@@ -86,8 +95,8 @@ def profiles_from(path):
def validate_overlay(base, merged, candidate):
old, new = base["services"], merged["services"]
if set(old) != set(new) or set(old) != {"connector","router","longconn","enrollment-signer","postgres","redis","edge"}:
raise DeployError("unexpected Compose services; migration requires review")
require_services(old)
require_services(new)
for name in set(old)-{"connector","router"}:
if old[name] != new[name]:
raise DeployError("overlay changes an unrelated relay service: "+name)
@@ -147,8 +156,7 @@ def preflight(args):
"compose_files":[str(p) for p in files]}
base = run(compose(plan)+["config","--format","json"],True)
names = set(base["services"])
if names != {"connector","router","longconn","enrollment-signer","postgres","redis","edge"}:
raise DeployError("unexpected Compose services")
require_services(names)
architecture = run(["docker","image","inspect",current["image"],"--format","{{.Architecture}}"])
if architecture != "arm64":
raise DeployError("expected current ARM64 runtime")
@@ -158,6 +166,7 @@ def preflight(args):
env = base["services"]["connector"].get("environment",{})
print("Project: "+plan["project"])
print("Compose files: "+str(len(files)))
print("Compose profile included: longconn (configuration parsing; no service startup)")
print("Current credential mode: "+env.get("HN_CREDENTIAL_MODE","legacy"))
print("Preflight complete; no files, keys or services changed. Resolved settings withheld.")