Fixes from the third Supermarket run: coreapp mail, route wait, skill edges

coreapp mail shows what the Core's mail server did with the app's mail
(from its log: accepted, delivered, deferred or bounced). Deploy waits
until traefik routes the public address, so it doesn't answer 404 just
after "Updated". The skill's settings rules no longer contradict, the
lowest role means read-only, the Core's admin gets no local password or
reset, and SQLite may need allowing in an app's multi-user edition.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 19:36:28 -07:00
co-authored by Claude Opus 5.5
parent d860dd9200
commit 2d29ca62b3
6 changed files with 135 additions and 15 deletions
+62
View File
@@ -23,6 +23,8 @@ coreapps login <host> <user> keep a token (read from stdin) for
installing private apps from host
coreapps logout <host> forget host's token
coreapps logins the hosts this Core has tokens for
coreapps mail <name> what the Core's mail server did with the
mail the app sent in the last day
coreapps core what this Core offers apps: its services
and their versions, and the machine
coreapps test-account [--remove] make (or refresh, with the password on
@@ -875,6 +877,7 @@ def install_app(m, p, folder, origin, addon_ok, recreate):
# installapp's start step only knows Federated's own apps
compose_up(m, log)
wait_until_answering(m, p)
wait_for_route(m, p)
else:
before = service_value(f"{APPS}/{name}/.env", "IMAGE_VERSION")
if before == m["version"]:
@@ -899,6 +902,7 @@ def install_app(m, p, folder, origin, addon_ok, recreate):
raise Refused(f"Updating failed (whole log on the Core: {log}).")
compose_up(m, log, recreate)
wait_until_answering(m, p)
wait_for_route(m, p)
except (Exception, KeyboardInterrupt) as e:
say(f"{e}" if isinstance(e, Refused) else f"Updating failed: {e!r}")
raise Refused(roll_back(m, p, backup, log)) from e
@@ -1176,6 +1180,21 @@ def wait_until_answering(m, p):
"its log is above).")
def wait_for_route(m, p):
"""Until traefik routes https://<name>.<domain> to the new container
(it answers 404 for a few seconds after a container starts)."""
host = f"{m['name']}.{p['domain']}"
traefik = service_value(os.path.join(SERVICES, "traefik", "service"), "INTERNAL_IP")
if not traefik:
return
for _ in range(30):
code = run(["curl", "-sk", "-o", "/dev/null", "-w", "%{http_code}", "--max-time", "3",
"--resolve", f"{host}:443:{traefik}", f"https://{host}{m['health']}"]).stdout
if code not in ("", "000", "404", "502", "503"):
return
time.sleep(1)
say(f"Note: traefik doesn't route https://{host}/ to it yet; it may take a moment.")
def update(name, addon_ok):
"""An app installed from a repository, to its newest release."""
@@ -1301,6 +1320,47 @@ def core_info():
return 0
# --- The app's mail (coreapp mail) ---------------------------------------------------
def app_mail(name, since="24h"):
"""What the Core's mail server did with the mail the app sent: accepted
from its account, then delivered, deferred or bounced, per recipient."""
if not re.fullmatch(FIELDS["name"], name) or not is_ours(name):
raise Refused(f"No app called '{name}' installed by coreapps on this Core.")
out = run(["docker", "logs", "--since", since, "mail"])
lines = (out.stdout + out.stderr).splitlines()
account = re.compile(r" ([0-9A-F]{6,}): client=\S+, sasl_method=\S+, sasl_username=coreapp-"
+ re.escape(name) + r"@")
ids = {}
for line in lines:
found = account.search(line)
if found:
ids[found.group(1)] = line[:19].replace("T", " ")
if not ids:
say(f"The Core's mail server has no mail from {name} in the last {since} "
f"(from its account, coreapp-{name}).")
return 0
for qid, when in list(ids.items())[-20:]:
sender, results = "", []
for line in lines:
if f" {qid}: " not in line:
continue
found = re.search(r"from=<([^>]*)>", line)
if found and not sender:
sender = found.group(1)
found = re.search(r"to=<([^>]*)>.*status=(\w+)(?: \((.*)\))?", line)
if found:
to, status, why = found.groups()
results.append(f" to {to}: {status}"
+ (f" ({why[:160]})" if why and status != "sent" else ""))
say(f"{when} from {sender or '?'}, accepted")
for r in dict.fromkeys(results):
say(r)
if not results:
say(" (no delivery yet)")
return 0
# --- The test account (coreapp signin) ---------------------------------------------
# A person in the Core's LDAP that coreapp signin signs in with, on a
@@ -1429,6 +1489,8 @@ def main(args):
return list_logins()
if cmd == "list" and not rest:
return list_apps()
if cmd == "mail" and len(rest) == 1:
return app_mail(rest[0])
if cmd == "core" and not rest:
return core_info()
if cmd == "test-account" and rest in ([], ["--remove"]):