Update rehearsal: downgrade check for deploys, -N versions, failed logs
coreapp deploy refuses a lower version than the installed one without --downgrade, as coreapp install does. Versions with -N (the Coreapp's own fix on the same upstream version) order after the upstream one, for releases too. A failed start keeps the container's whole log, from its first start, in <name>-failed-start.log. coreapp status shows the installed version beside the folder's. Skill: references/updating.md (versions, what to check between versions, testing an update over real data and its rollback, no copy after a successful update); reading the installer's bash -x log. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+38
-4
@@ -504,12 +504,25 @@ def normalize_url(url):
|
||||
return f"{scheme}://{host.lower()}/{path}"
|
||||
|
||||
|
||||
# A release's version: numbers with dots, and a -N for the Coreapp's own
|
||||
# fixes on the same upstream version (8.8.6-2 comes after 8.8.6)
|
||||
VERSION_ORDER = r"([0-9]+(?:\.[0-9]+)*)(?:-([0-9]+))?"
|
||||
|
||||
|
||||
def is_release(tag):
|
||||
return bool(re.fullmatch(r"v[0-9]+(?:\.[0-9]+)*", tag or ""))
|
||||
return bool(re.fullmatch("v" + VERSION_ORDER, tag or ""))
|
||||
|
||||
|
||||
def version_order(version):
|
||||
"""Comparable form of a version like 6.2.0 or 6.2.0-2, else None."""
|
||||
found = re.fullmatch(VERSION_ORDER, version or "")
|
||||
if not found:
|
||||
return None
|
||||
return [int(part) for part in found.group(1).split(".")], int(found.group(2) or 0)
|
||||
|
||||
|
||||
def version_key(tag):
|
||||
return [int(part) for part in tag[1:].split(".")]
|
||||
return version_order(tag[1:])
|
||||
|
||||
|
||||
def git(args, cwd=None, auth=None):
|
||||
@@ -696,6 +709,17 @@ def plan(m, origin=None, downgrade=False, drop_database=False):
|
||||
"To install it anyway, add --downgrade (if it fails to start, the update "
|
||||
"rolls back).")
|
||||
p["downgrade_from"] = installed_tag
|
||||
# The same from a folder (coreapp deploy), by coreapp.toml's version
|
||||
installed_version = service_value(f"{APPS}/{name}/.env", "IMAGE_VERSION")
|
||||
old, new = version_order(installed_version), version_order(m["version"])
|
||||
if not origin and old and new and new < old:
|
||||
if not downgrade:
|
||||
raise Refused(
|
||||
f"'{name}' has version {installed_version} installed; {m['version']} is "
|
||||
"older, and may not understand the data the newer version left (its "
|
||||
"database and /data). To deploy it anyway, add --downgrade (if it fails "
|
||||
"to start, the update rolls back).")
|
||||
p["downgrade_from"] = installed_version
|
||||
else:
|
||||
p["new_needs"] = list(m["needs"])
|
||||
p["dropped_needs"] = []
|
||||
@@ -1485,7 +1509,17 @@ def wait_until_answering(m, p):
|
||||
sys.stderr.write(logs.stdout + logs.stderr)
|
||||
raise Refused(f"{name} doesn't answer at {url} after "
|
||||
f"{time.monotonic() - started:.0f} s (state: {state or 'missing'}; "
|
||||
"its log is above).")
|
||||
f"the end of its log is above). {keep_failed_log(name)}")
|
||||
|
||||
|
||||
def keep_failed_log(name):
|
||||
"""The failed container's whole log, every restart (its first start,
|
||||
which ran the migrations, too), before a rollback removes it."""
|
||||
path = log_path(name, "failed-start")
|
||||
with open(path, "w") as out:
|
||||
subprocess.run(["docker", "logs", "--timestamps", name], stdout=out,
|
||||
stderr=subprocess.STDOUT)
|
||||
return f"Its whole log, from its first start: {path} on the Core."
|
||||
|
||||
|
||||
def wait_for_route(m, p):
|
||||
@@ -1513,7 +1547,7 @@ def wait_for_route(m, p):
|
||||
return
|
||||
health = container_health(m["name"])
|
||||
if health == "unhealthy":
|
||||
raise Refused(unhealthy_message(m, host))
|
||||
raise Refused(f"{unhealthy_message(m, host)} {keep_failed_log(m['name'])}")
|
||||
if health != "starting" and time.monotonic() - started > 30:
|
||||
break
|
||||
time.sleep(2)
|
||||
|
||||
Reference in New Issue
Block a user