Skip to content

Commit

Permalink
Be a bit more aggressive about expiring old soversions
Browse files Browse the repository at this point in the history
Allow the source package responsible for the old soversion to be
completely expired if it wouldn't normally be kept, and all of it's
install packages have no external rdepends.
  • Loading branch information
jon-turney committed Apr 23, 2024
1 parent f4dd6de commit 8078633
Showing 1 changed file with 31 additions and 9 deletions.
40 changes: 31 additions & 9 deletions calm/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -1660,7 +1660,7 @@ def mark_fn(packages, po, v, certain_age, vault_requests):
# shouldn't retain anything.
#
if pn.endswith('-debuginfo'):
return Freshness.conditional
return (Freshness.conditional, False)

# - shared library packages which don't come from the current version of
# source (i.e. is superseded or removed), have no packages from a
Expand All @@ -1674,25 +1674,25 @@ def mark_fn(packages, po, v, certain_age, vault_requests):
mtime = po.tar(v).mtime
if mtime < certain_age:
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))))
return Freshness.conditional
return (Freshness.conditional, True)

# - if package depends on anything in expired_provides
#
requires = po.version_hints[v].get('depends', [])
if any(ep in requires for ep in past_mistakes.expired_provides):
logging.debug("package '%s' version '%s' not retained as it requires a provide known to be expired" % (pn, v))
return Freshness.conditional
return (Freshness.conditional, False)

# - marked via 'calm-tool vault'
#
es = po.srcpackage(v, suffix=False)
if es in vault_requests:
if v in vault_requests[es]:
logging.info("package '%s' version '%s' not retained due vault request" % (pn, v))
return Freshness.conditional
return (Freshness.conditional, False)

# otherwise, make no change
return Freshness.fresh
return (Freshness.fresh, False)


#
Expand All @@ -1708,9 +1708,6 @@ def stale_packages(packages, vault_requests):

# mark install packages for freshness
for pn, po in packages.items():
if po.kind != Kind.binary:
continue

# mark as fresh any versions explicitly listed in the keep: override
# hint (unconditionally)
for v in po.override_hints.get('keep', '').split():
Expand Down Expand Up @@ -1759,13 +1756,38 @@ def stale_packages(packages, vault_requests):
if newer:
mark_package_fresh(packages, pn, v)

for pn, po in packages.items():
if po.kind != Kind.binary:
continue

# overwrite with 'conditional' package retention mark if it meets
# various criteria
for v in sorted(po.versions(), key=lambda v: SetupVersion(v)):
mark = mark_fn(packages, po, v, certain_age, vault_requests)
(mark, others) = mark_fn(packages, po, v, certain_age, vault_requests)
if mark != Freshness.fresh:
mark_package_fresh(packages, pn, v, mark)

# also look over the other install packages generated by the
# source...
if others:
es = po.version_hints[v].get('external-source', None)
if es:
es_po = packages[es]
# ... if the source package version doesn't count as kept ...
#
# (set above using same critera as for install package
# e.g. we have an excess number of packages)
logging.warning("considering other packages from source package '%s' version '%s'" % (es, v))
if getattr(es_po.tar(v), 'fresh', Freshness.stale) != Freshness.fresh:
# ... additionally mark anything with no other-source
# rdepends
for opn in sorted(es_po.is_used_by):
if v in packages[opn].versions():
if not any(packages[p].srcpackage(v) != es for p in packages[opn].rdepends):
mark_package_fresh(packages, opn, v, mark)
else:
logging.warning("package '%s' version '%s' retained due to being used" % (opn, v))

# mark source packages as fresh if any install package which uses it is fresh
for po in packages.values():
if po.kind == Kind.source:
Expand Down

0 comments on commit 8078633

Please sign in to comment.