From patchwork Thu Dec 3 21:20:48 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kanavin X-Patchwork-Id: 107227 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.3769.1796332863993996433 for ; Thu, 03 Dec 2026 13:21:04 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20260707 header.b=aarrLRwl; spf=pass (domain: gmail.com, ip: 209.85.128.53, mailfrom: alex.kanavin@gmail.com) Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4a2153c8525so1478845e9.3 for ; Thu, 03 Dec 2026 13:21:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796332862; x=1796937662; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=va2p8Q71onOV8TNHMFI51XaNViEYDRwiwvnfSyBGAcU=; b=aarrLRwlLO/9AbXxxTjFTL9PlLQ8slJwhhZRguhSyRm6ef6xGNshFhBgFyPxAdZmxL RzjC00KtaoxbY5ODpdHAss0VEWytlSxUAbPlzuxtwb2vIyKct7y3ZvdNnx1x2o6Xb6g9 GhyZToXPEsWZ75qQfNXL7v149wCb2yc1qm7DpO94MNkSMdwZ/fwUe3jAni/bVI5FtE9D xujHNvrZFyBJXxOgkH0zP4L2BrNE8H5cqu8oIc2oDD4sCQx0HWWXRkI3XAEOX3BLUDIE yDfI809MyG7EQVs1+XtGJa50tmOhMhuVc/jaissFo4M7DOCzBe+wVFVaNn3dCGoY+PpE KGEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796332862; x=1796937662; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=va2p8Q71onOV8TNHMFI51XaNViEYDRwiwvnfSyBGAcU=; b=KrJWBhSmfE/e0DPyM876dQxs9SRHtKAcy7bkunbvH0CBT0PD8MCVqIe3Z251PTEcjC j41iiaGl7HXjIPgZcKJHCsKer4Ir1Qb0S8SeuJiRaTi9F9VhcCXcCynoFf+DXsHa2Efz gJ8e8hx0Wz8hDz61Rw8aEnWn8m1jWi4xM7jsRGkErX1PRQPOhrD/KcbbfVLKfhqrcNqb clLuKjHRyQqp89ouTkkYZ75JV8v108PrpPEr8mnHeJbHBbSU/QT4TlfiyAe2HG5SuRIH STsUeHyAXw8z9UpagjcxlyOksyMcSW4B3sbDhaus5Eb/9nOofz24A65BKh+2C3Se6SBn anEQ== X-Gm-Message-State: APuU4Z/vLzql1BnsQMZsn16iu3Grba/bdNDxaDUylGQKkx5RyqqWuoV7 rSZGFpJb4dFFv5SggapgY0vst6wUm22Gp4/pX5IZ1rMYgEiujCnx/Z7QZ802iQ== X-Gm-Gg: AZFdTZef2NL/2ZpIARPILlm9t9FEYWApvEe91b8KmH2NijH5OjKbJZKq610GvY1R1Xq tx1xv1Uvv/E76Xwkd/xNNhsb+dHPZ0d+kZLr2IVhs62EQYEwH8hl95jEmJt1zo+WVM4+eea2OeB R1vUbTnkOdFSnOkSgo7oYZA9WoY1ZXu7RkODpcDc97ADcykvBWmiL+9LKKuV+CuTadiKXktDrH3 5rezsqUCQX7vgKv9/sWC14zl5tb8mY7v46KkkEe7baAc76cj30duHpd4Pl6+zck3AQDEeBtWGg4 WT64jJGmqp0wJpp5zY6KwTLQwk+UBHWK9m/YyL68em08BraQX321DClUXhv0NkTXrfVFCsjwSxU /y4avEv80kQnQX3KmTuVAsZzqGdI5O+NQqB/QubaJ7yldq2N8HLN9u0nym0UTWtACf8sX249oAM nThs2V2cHm6r0ZgEST8jek4pwCj35f1BRteyyqJWIK/1mewSN8BVcssoyg7EDBixG/fs2Mhew9m c6V2ujJH1RoeAVmbMEFfhDGlDP+jnbhLLoJJZpz/vctA9y2c/OjhBYjaIc097uLKDgYfjl26jMw Mutwi9ItYUqBhCW+4vnLtW0tjy3GeVhRid0CUgmq2KhpcGHeqqcMSHqzAnB1JZf+ X-Received: by 2002:a05:600c:848d:b0:4ac:86c9:b09c with SMTP id 5b1f17b1804b1-4bb88811da9mr906392815e9.13.1796332862298; Thu, 03 Dec 2026 13:21:02 -0800 (PST) Return-Path: Received: from Zen2.lab.linutronix.de. (drugstore.linutronix.de. [80.153.143.164]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4d1724ad3a5sm1860126f8f.9.2026.12.03.13.21.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 13:21:01 -0800 (PST) From: Alexander Kanavin X-Google-Original-From: Alexander Kanavin To: yocto-patches@lists.yoctoproject.org Cc: daniel.turull@ericsson.com, Alexander Kanavin Subject: [auh][PATCH v2 1/3] modules/state: rework state to include both original and updated version Date: Thu, 3 Dec 2026 22:20:48 +0100 Message-ID: <20261203212050.799982-1-alex@linutronix.de> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Thu, 03 Dec 2026 21:21:06 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/5664 The state information in incremental mode did not keep the original versions that recipes were updated from, only the new versions. This is problematic when upstreams release new versions in quick succession: if a layer updates a recipe to an intermediate version after AUH produced an update from the original version to latest version, AUH will not re-roll the update from an intermediate to latest because it doesn't track the original versions, and the update will only be retried after a retry period (typically 30 days) expires. Additionally, it would be useful to know when the original version, or the latest version was first seen by AUH; if either period grows too much, that means the AUH upgrade attempts are being ignored, the recipe isn't being updated, and the situation needs to be looked at. The patch reworks the state format from being a dict of recipes containing a dict of (latest) versions to a flat dict of recipes that contains the original version, the new version, when either was first seen, and when an AUH did the update. The rest of the code is adapted to that; it's difficult to test all the corner cases, but I confirmed that at least the update and the skipping after work as they should. Note that AUH will not try to migrate the v1 state to v2 state. It will simply detect that the state is not usable, and re-run the full update cycle to repopulate state. AI-Generated: Claude Sonnet 5.5 Signed-off-by: Alexander Kanavin --- modules/state.py | 77 +++++++++++++++++++++-------------------------- upgrade-helper.py | 8 ++--- 2 files changed, 39 insertions(+), 46 deletions(-) diff --git a/modules/state.py b/modules/state.py index d70972b..9a10d32 100644 --- a/modules/state.py +++ b/modules/state.py @@ -32,7 +32,7 @@ RESULT_SUCCESS = "success" RESULT_FAILURE = "failure" STATE_FILENAME = "auh-state.json" -STATE_VERSION = 1 +STATE_VERSION = 2 SECONDS_PER_DAY = 86400 DEFAULT_RETRY_SAME_VERSION_DAYS = 30 @@ -41,7 +41,9 @@ DEFAULT_SUCCESS_MAX_AGE_DAYS = 30 class State: - """Tracks upgrade attempts as {recipe: {version: {timestamp, result}}}.""" + """Tracks upgrade attempts as a flat dict, one entry per recipe: + {recipe: {oldversion, oldversion_firstseen, newversion, newversion_firstseen, + timestamp, result}}.""" def __init__(self, state_dir, retry_same_version_days=DEFAULT_RETRY_SAME_VERSION_DAYS, @@ -53,10 +55,9 @@ class State: self.success_max_age = success_max_age_days * SECONDS_PER_DAY self.retry_any_version = retry_any_version_days * SECONDS_PER_DAY self.any_version_recipes = set(retry_any_version_recipes or []) - self.data = self._load() - self._prune() + self.data = self._load_state_file() - def _load(self): + def _load_state_file(self): if os.path.exists(self.path): try: with open(self.path) as f: @@ -76,38 +77,46 @@ class State: json.dump({"version": STATE_VERSION, "recipes": self.data}, f, indent=2) - def record(self, pn, version, result): - entry = {"timestamp": time.time(), "result": result} - if pn not in self.data: - self.data[pn] = {} - self.data[pn][version] = entry - - def should_skip(self, pn, version): - """Return True if this recipe/version should not be attempted.""" - return self.check(pn, version)['skip'] - - def skip_reason(self, pn, version): - """Return a human-readable string explaining why pn/version is being skipped.""" - return self.check(pn, version)['reason'] - - def check(self, pn, version): + def record(self, pn, old_version, new_version, result): + current_time = time.time() + oldversion_firstseen = current_time + newversion_firstseen = current_time + + if pn in self.data: + if self.data[pn]['oldversion'] == old_version: + oldversion_firstseen = self.data[pn]['oldversion_firstseen'] + if self.data[pn]['newversion'] == new_version: + newversion_firstseen = self.data[pn]['newversion_firstseen'] + + self.data[pn] = {"timestamp": current_time, + "result": result, + "oldversion": old_version, + "oldversion_firstseen": oldversion_firstseen, + "newversion": new_version, + "newversion_firstseen": newversion_firstseen, + } + + def check(self, pn, old_version, new_version): """Return {'skip': bool, 'reason': str} for a recipe/version pair. For any_version_recipes, any recent attempt (any version) causes a skip. - For normal recipes, only a matching version entry causes a skip. + For normal recipes, only an entry for the same old and new version + causes a skip. """ + + entry = self.data.get(pn, {}) + + if not entry: + return {'skip': False, 'reason': ''} + if pn in self.any_version_recipes: - entry = self._newest_entry(pn) max_age = self.retry_any_version else: - entry = self.data.get(pn, {}).get(version) - if entry is None: - return {'skip': False, 'reason': ''} max_age = self.success_max_age \ if entry.get("result") == RESULT_SUCCESS \ else self.retry_same_version - if not entry: + if pn not in self.any_version_recipes and (entry['oldversion'] != old_version or entry['newversion'] != new_version): return {'skip': False, 'reason': ''} ts = entry.get("timestamp", 0) @@ -122,19 +131,3 @@ class State: return {'skip': True, 'reason': "%slast attempt %s result=%s; will retry in %d day(s)" % (prefix, when, result, retry_in)} - - def _newest_entry(self, pn): - """Return the most recent entry for a recipe across all versions.""" - versions = self.data.get(pn, {}) - return max(versions.values(), key=lambda e: e.get("timestamp", 0), - default={}) - - def _prune(self): - """Remove entries that check() would no longer skip.""" - for pn in list(self.data): - versions = self.data[pn] - for ver in list(versions): - if not self.check(pn, ver)['skip']: - del versions[ver] - if not versions: - del self.data[pn] diff --git a/upgrade-helper.py b/upgrade-helper.py index 56b1f02..8e47e40 100755 --- a/upgrade-helper.py +++ b/upgrade-helper.py @@ -498,10 +498,10 @@ class Updater(object): if self.state: kept = [] for g in pkggroups_ctx: - pn, npv = g['pkgs'][0]['PN'], g['pkgs'][0]['NPV'] - r = self.state.check(pn, npv) + pn, opv, npv = g['pkgs'][0]['PN'], g['pkgs'][0]['PV'], g['pkgs'][0]['NPV'] + r = self.state.check(pn, opv, npv) if r['skip']: - I(" %s %s: skipping (%s)" % (pn, npv, r['reason'])) + I(" %s %s -> %s: skipping (%s)" % (pn, opv, npv, r['reason'])) self.statistics.skip(g, r['reason']) else: kept.append(g) @@ -579,7 +579,7 @@ class Updater(object): # upgrades them atomically; individual outcomes are not tracked. for pkg_ctx in g['pkgs']: I(" %s %s: recording result=%s" % (pkg_ctx['PN'], pkg_ctx['NPV'], result)) - self.state.record(pkg_ctx['PN'], pkg_ctx['NPV'], result) + self.state.record(pkg_ctx['PN'], pkg_ctx['PV'], pkg_ctx['NPV'], result) if self.state: self.state.save()