Fix expiry time for Git SHA tagged Docker images

Aperta
#67 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
docker, github-actions
Ambito
ci-cd, devops

Direzione di ricerca

Inizia da .github/workflows/build-image.yaml, quindi esamina la label del Dockerfile e l’impostazione QUAY_IMAGE_EXPIRY del Makefile. Confronta la gestione dei tag e della scadenza del workflow con la documentazione di Quay sulla scadenza delle immagini e conferma che i tag main, latest e release non scadano mai, mentre i tag Git SHA scadano dopo 3 settimane, senza modificare il comportamento dei tag dei branch.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

triage/accepted

Summary

Docker images tagged with Git SHA are not expiring as expected on Quay.io. Currently, SHA-tagged images are set to never expire, leading to storage accumulation.

Current Behavior

Looking at quay.io/kuadrant/developer-portal-controller, images with Git SHA tags (e.g., b2ab687...) do not have an expiry time set.

Expected Behavior

Images should automatically expire based on their tags:

  • Images with main tag: Never expire
  • Images with latest tag: Never expire
  • Release tag images (e.g., v0.4.0, v1.2.3-alpha.1): Never expire
  • Git SHA tagged images: Expire after 3 weeks
  • Branch tagged images (non-main branches): Expire after 3 weeks ✅ (already working correctly)

Root Cause

The issue is in .github/workflows/build-image.yaml. When a push to the main branch occurs:

  1. The metadata action generates multiple tags for a single build: main, latest, and the Git SHA
  2. The expiry logic evaluates to expiry=never because github.ref_name == "main"
  3. The Docker build uses a single QUAY_IMAGE_EXPIRY value for all tags via the LABEL quay.expires-after directive
  4. Result: All tags including the Git SHA inherit quay.expires-after=never

This is a Docker/Quay limitation - you cannot set different expiry times for different tags in the same image build because the label is set at the image layer level, not per-tag.

Possible Solutions

Option 1: Separate Builds for Different Expiry Requirements

Split the image building into separate jobs with different QUAY_IMAGE_EXPIRY build args:

  • Job 1: Build and tag with main and latest (expiry = never)
  • Job 2: Build and tag with Git SHA (expiry = 3w)
Option 2: Use Quay API to Set Tag Expiry Post-Build

After the image is built and pushed, use the Quay API to programmatically set expiration time for the Git SHA tag only.

Additional Context

Lingua principale
Go
Stelle
3
Fork
15
Merge medio
1g 21h
PR unite (30g)
4

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Kuadrant/developer-portal-controller

Tutte le issue di Kuadrant/developer-portal-controller

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.