Skip to content

fix: prevent arch layers of private images from being marked as dangling in container-package-cleanup#656

Merged
nookyo merged 12 commits intomainfrom
534-bug-cleanup-job-remove-images-included-in-image-manifest-for-tag
Mar 16, 2026
Merged

fix: prevent arch layers of private images from being marked as dangling in container-package-cleanup#656
nookyo merged 12 commits intomainfrom
534-bug-cleanup-job-remove-images-included-in-image-manifest-for-tag

Conversation

@nookyo
Copy link
Copy Markdown
Collaborator

@nookyo nookyo commented Mar 16, 2026

Pull Request

Summary

Fix dangling layer detection for private/multi-arch container images in the container-package-cleanup action.
When a tagged image is private, docker manifest inspect was failing with unauthorized, causing arch layers of protected tags to not be added to protectedDigests, and subsequently being incorrectly marked as dangling and deleted.

Issue

Fixes #534

Breaking Change?

  • Yes
  • No

Scope / Project

actions/container-package-cleanup

Implementation Notes

  • Added ensureDockerLogin() method to OctokitWrapper that performs docker login ghcr.io using the PACKAGE_TOKEN before calling docker manifest inspect. This allows the action to fetch manifests for private images.
  • Fixed manifest.manifests ?? [] to handle single-arch images that do not have a manifests array in their manifest response.
  • Migrated the action from CJS to ESM ("type": "module" in package.json), matching the approach used in metadata-action.
  • Switched bundler to esbuild (same as metadata-action) with dist/package.json set to {"type":"commonjs"} so the compiled bundle runs correctly under Node.
  • Rewrote all Jest tests to use jest.unstable_mockModule + await import() for ESM compatibility.
  • listPackagesForOrganization now makes three parallel requests with explicit visibility: 'public', 'internal', and 'private' using Promise.allSettled, so each visibility bucket is logged separately and partial failures don't abort the whole fetch.
  • Added debug log in getManifestDigests showing the ref and returned digests for each tag, making it easier to trace which arch layers belong to which tag.
  • Updated action.yml using from node20 to node24.

Tests / Evidence

  • All 60 unit tests pass (npm test).
  • Dry-run execution against testpatchesorg/qubership-kafka confirms:
    • latest and 1.0.2 (protected) → their arch layers correctly added to protectedDigestsdanglingLayers: none
    • kafka-3.9.1-patched-8 and feature_integration-build (not protected, old) → tagged version + its arch layers correctly scheduled for deletion
    • No false dangling deletions observed.

Additional Notes

  • Private packages (visibility: private) are not returned by listPackagesForOrganization GitHub REST API even with an admin token — this is a known GitHub API limitation and is out of scope for this PR.
  • The three-visibility fetch logs (Found X public/internal/private packages) are intentionally kept for observability.

@nookyo nookyo requested a review from borislavr as a code owner March 16, 2026 14:47
@github-actions github-actions bot added bug Something isn't working enhancement New feature or request refactor labels Mar 16, 2026
@nookyo nookyo moved this to In Progress in qubership-DevOps Mar 16, 2026
@nookyo nookyo added enhancement New feature or request and removed enhancement New feature or request labels Mar 16, 2026
@nookyo nookyo merged commit 3b5d5ff into main Mar 16, 2026
25 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in qubership-DevOps Mar 16, 2026
@nookyo nookyo deleted the 534-bug-cleanup-job-remove-images-included-in-image-manifest-for-tag branch March 16, 2026 14:56
@github-actions github-actions bot locked and limited conversation to collaborators Mar 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Something isn't working enhancement New feature or request refactor

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: Cleanup job remove images included in image manifest for tag

2 participants