jojo/services
forgejo-backport-action dbdbd0f5e6 [v14.0/forgejo] fix: cleanup of multi-platform container images (#11254)
**Backport:** https://codeberg.org/forgejo/forgejo/pulls/11246

This change fixes an issue that makes Forgejo clean up too many versions of a container package even though it should keep them according to the rules set for the package.

The issue affects multi-platform container images.
Forgejo adds a package version for each platform (for example `linux/amd64`, `linux/arm64`) in addition to the actual tag (for example `0.6.0` or `latest`).

This results in rows in the table `package_version` similar to this (unimportant columns omitted for brevity):

| **lower_version** | **created_unix** |
|---|---|
| `latest` | `1768742887`|
| `0.6.0` | `1768742886` |
| `sha256:038e...` | `1768742886` |
| `sha256:fc38...` | `1768742886` |
| `0.5.0` | `1768742864` |
| `sha256:806d...` | `1768742864` |
| `sha256:0a19...` | `1768742864` |
| `0.4.0` | `1768742848` |
| `...` | `...` |

The code assumes that the first `<keep count>` entries can be ignored and considers every entry after `<keep count>` as eligible for cleanup.
That doesn't work for multi-platform container images because, for `<keep count>=5`, it considers version `0.4.0` as eligible.

## Checklist

The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org).

### Tests

- I added test coverage for Go changes...
  - [x] in their respective `*_test.go` for unit tests.
  - [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server.
- I added test coverage for JavaScript changes...
  - [ ] in `web_src/js/*.test.js` if it can be unit tested.
  - [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)).

### Documentation

- [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change.
- [x] I did not document these changes and I do not expect someone else to do it.

### Release notes

- [x] This change will be noticed by a Forgejo user or admin (feature, bug fix, performance, etc.). I suggest to include a release note for this change.
- [ ] This change is not visible to a Forgejo user or admin (refactor, dependency upgrade, etc.). I think there is no need to add a release note for this change.

*The decision if the pull request will be shown in the release notes is up to the mergers / release team.*

The content of the `release-notes/<pull request number>.md` file will serve as the basis for the release notes. If the file does not exist, the title of the pull request will be used instead.

<!--start release-notes-assistant-->

## Release notes
<!--URL:https://codeberg.org/forgejo/forgejo-->
- Bug fixes
  - [PR](https://codeberg.org/forgejo/forgejo/pulls/11246): <!--number 11246 --><!--line 0 --><!--description Y2xlYW51cCBvZiBtdWx0aS1wbGF0Zm9ybSBjb250YWluZXIgaW1hZ2Vz-->cleanup of multi-platform container images<!--description-->
<!--end release-notes-assistant-->

Co-authored-by: wandhydrant <wandhydrant@noreply.codeberg.org>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/11254
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.codeberg.org>
Co-authored-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
Co-committed-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
2026-02-23 18:49:26 +01:00
..
actions [v14.0/forgejo] fix: when expanding a dynamic matrix, original 'needs' access was lost (#11166) 2026-02-15 23:55:05 +01:00
agit fix: correctly mark reviews as stale for AGit PRs (#8450) 2025-07-09 07:38:00 +02:00
asymkey chore: do not clobber ~/.ssh/authorized_keys in certain tests (#10163) 2025-11-19 16:14:16 +01:00
attachment [v14.0/forgejo] chore(cleanup): move all test blank imports in a single package (#10672) 2026-01-05 12:14:11 +01:00
auth feat: allow sync quota groups with oauth2 auth source (#8554) 2025-12-01 14:12:00 +01:00
automerge fix: check PR reference on base repository (#8431) 2025-07-06 14:23:47 +02:00
context fix: don't use attachment size as max memory for ParseMultipart 2026-01-06 10:33:22 -07:00
contexttest Replace the 'relative-time' element scripting with custom, translatable rewrite (#6154) 2025-05-03 14:11:01 +00:00
convert fix: hide user profile anonymous options on public repo APIs 2026-01-06 10:33:22 -07:00
cron fix: garbage collect lingering actions logs (#10009) 2025-11-18 18:59:01 +01:00
doctor feat: ensure only expected ssh public keys are in authorized_keys file (#10010) 2025-11-09 01:06:04 +01:00
externalaccount chore(cleanup): replaces unnecessary calls to formatting functions by non-formatting equivalents (#7994) 2025-05-29 17:34:29 +02:00
f3 chore: ensure consistent import aliasing for services and models (#10253) 2025-11-30 17:00:57 +01:00
federation fix(user): set ActivityPub users to ProhibitLogin (#10434) 2025-12-17 15:38:32 +01:00
feed fix: load reviewer for pull review dismiss action notifier 2026-01-06 10:33:22 -07:00
forgejo [v14.0/forgejo] chore(cleanup): move all test blank imports in a single package (#10672) 2026-01-05 12:14:11 +01:00
forms feat: allow sync quota groups with oauth2 auth source (#8554) 2025-12-01 14:12:00 +01:00
gitdiff [v14.0/forgejo] chore(cleanup): move all test blank imports in a single package (#10672) 2026-01-05 12:14:11 +01:00
indexer chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue [v14.0/forgejo] chore(cleanup): move all test blank imports in a single package (#10672) 2026-01-05 12:14:11 +01:00
lfs fix: return on error if an LFS token cannot be parsed 2025-10-25 10:41:49 -06:00
mailer [v14.0/forgejo] chore(cleanup): move all test blank imports in a single package (#10672) 2026-01-05 12:14:11 +01:00
markup chore: remove branding from context imports (#9628) 2025-10-11 01:52:51 +02:00
migrations [v14.0/forgejo] fix: migrations/github: avoid getting the first issues page twice (#11055) 2026-01-27 01:45:57 +01:00
mirror fix: don't push LFS when using SSH authentication (#10475) 2025-12-18 23:23:07 +01:00
moderation [v14.0/forgejo] chore(cleanup): move all test blank imports in a single package (#10672) 2026-01-05 12:14:11 +01:00
notify chore: Dead Code: DeleteIssue Notify Topic (#10046) 2025-11-17 02:13:38 +01:00
org chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
packages [v14.0/forgejo] fix: cleanup of multi-platform container images (#11254) 2026-02-23 18:49:26 +01:00
pull [v14.0/forgejo] fix: correctly compute required commit status (#10788) 2026-01-12 13:05:58 +01:00
redirect [v14.0/forgejo] chore(cleanup): move all test blank imports in a single package (#10672) 2026-01-05 12:14:11 +01:00
release [v14.0/forgejo] chore(cleanup): move all test blank imports in a single package (#10672) 2026-01-05 12:14:11 +01:00
remote chore: tune down remote user promotion debug message shown as error (#7687) 2025-04-27 20:50:48 +00:00
repository [v14.0/forgejo] fix: internal server error on a large .gitmodules (#10767) 2026-01-11 09:32:09 +01:00
secrets feat: migrate action secrets to keying to store them more securely (#8692) 2025-07-29 01:03:36 +02:00
shared/automerge fix: suppress false-positive error log when PR is already in the automerge queue (#9784) 2025-10-21 08:19:33 +02:00
stats fix: possible cause of invalid issue counts; cache invalidation occurs before a active transaction is committed (#10130) 2025-11-17 01:07:29 +01:00
task feat: cache derived keys for faster keying (#10114) 2025-11-16 14:29:14 +01:00
uinotification chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
user [v14.0/forgejo] fix: decrease watch count when blocking user (#11060) 2026-01-27 13:57:57 +01:00
webhook [v14.0/forgejo] fix: allow test delivery for webhooks not enabled for push events (#11074) 2026-01-28 16:09:43 +01:00
wiki [v14.0/forgejo] chore(cleanup): move all test blank imports in a single package (#10672) 2026-01-05 12:14:11 +01:00