Skip to content

Commit e1c2bc5

Browse files
committed
Don't retain obsolete packages
Don't retain obsolete packages over a certain age threshold (when they are effectively just adding an obsolete: to another package). This is safe, as commit 17dc61e (persisting missing_obsoletes) ensures that if the obsoletion was old-style (and thus only recorded in the obsoleted package, with the new-style obsoletes: hint in the obsoleteing package being synthesized by commit eca3a88), the fact of that obsoletion isn't forgotten once the obsolete package itself is removed.
1 parent 4ebc883 commit e1c2bc5

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

calm/package.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,7 +1648,7 @@ def mark_package_fresh(packages, p, v, mark=Freshness.fresh):
16481648
# helper function evaluate if package needs marking for conditional retention
16491649
#
16501650

1651-
def mark_fn(packages, po, v, certain_age, vault_requests):
1651+
def mark_fn(packages, po, v, certain_age, obs_threshold, vault_requests):
16521652
pn = po.name
16531653
bv = po.best_version
16541654

@@ -1676,6 +1676,17 @@ def mark_fn(packages, po, v, certain_age, vault_requests):
16761676
logging.debug("deprecated soversion package '%s' version '%s' mtime '%s' is over cut-off age" % (pn, v, time.strftime("%F %T %Z", time.localtime(mtime))))
16771677
return (Freshness.conditional, True)
16781678

1679+
# - package is an old-style obsoletion, over a certain age, and not marked
1680+
# as self-destruct
1681+
#
1682+
if '_obsolete' in po.version_hints[v]['category']:
1683+
mtime = po.tar(v).mtime
1684+
if mtime < obs_threshold:
1685+
provides = po.version_hints[v].get('provides', [])
1686+
if '_self-destruct' not in provides:
1687+
logging.debug("obsolete package '%s' version '%s' mtime '%s' is over cut-off age" % (pn, v, time.strftime("%F %T %Z", time.localtime(mtime))))
1688+
return (Freshness.conditional, False)
1689+
16791690
# - if package depends on anything in expired_provides
16801691
#
16811692
requires = po.version_hints[v].get('depends', [])
@@ -1700,12 +1711,16 @@ def mark_fn(packages, po, v, certain_age, vault_requests):
17001711
#
17011712

17021713
SO_AGE_THRESHOLD_YEARS = 5
1714+
OBSOLETE_AGE_THRESHOLD_YEARS = 10
17031715

17041716

17051717
def stale_packages(packages, vault_requests):
17061718
certain_age = time.time() - (SO_AGE_THRESHOLD_YEARS * 365.25 * 24 * 60 * 60)
17071719
logging.debug("cut-off date for soversion package to be considered old is %s" % (time.strftime("%F %T %Z", time.localtime(certain_age))))
17081720

1721+
obs_threshold = time.time() - (OBSOLETE_AGE_THRESHOLD_YEARS * 365.25 * 24 * 60 * 60)
1722+
logging.debug("cut-off date for obsolete package to be considered old is %s" % (time.strftime("%F %T %Z", time.localtime(obs_threshold))))
1723+
17091724
# mark install packages for freshness
17101725
for pn, po in packages.items():
17111726
# mark as fresh any versions explicitly listed in the keep: override
@@ -1763,7 +1778,7 @@ def stale_packages(packages, vault_requests):
17631778
# overwrite with 'conditional' package retention mark if it meets
17641779
# various criteria
17651780
for v in sorted(po.versions(), key=lambda v: SetupVersion(v)):
1766-
(mark, others) = mark_fn(packages, po, v, certain_age, vault_requests)
1781+
(mark, others) = mark_fn(packages, po, v, certain_age, obs_threshold, vault_requests)
17671782
if mark != Freshness.fresh:
17681783
mark_package_fresh(packages, pn, v, mark)
17691784

0 commit comments

Comments
 (0)