Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: set quay image expiry to prevent overflow of images #157

Merged
merged 2 commits into from
Sep 20, 2024

Conversation

KevFan
Copy link
Contributor

@KevFan KevFan commented Sep 17, 2024

Description

Part of: Kuadrant/kuadrant-operator#769
Associated with: Kuadrant/kuadrant-operator#843

Currently, all built Quay images never expire and are consuming unnecessary quota on Quay.io. Quay provides a way to set tag expiration from a Dockerfile to prevent this issue for images that don't need to be kept indefinitely, such as development branches and nightly builds. This can help prevent the problem from escalating over time.

Verification

@codecov-commenter
Copy link

codecov-commenter commented Sep 17, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.21%. Comparing base (8d7e9ed) to head (8031ad1).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #157      +/-   ##
==========================================
- Coverage   85.71%   85.21%   -0.51%     
==========================================
  Files          19       19              
  Lines         994      994              
==========================================
- Hits          852      847       -5     
- Misses         93       96       +3     
- Partials       49       51       +2     
Flag Coverage Δ
integration 79.57% <ø> (-0.71%) ⬇️
unit 66.51% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
api/v1alpha1 (u) 100.00% <ø> (ø)
pkg/helpers (u) 83.87% <ø> (ø)
pkg/log (u) 94.73% <ø> (ø)
pkg/reconcilers (u) 74.67% <ø> (ø)
pkg/limitador (u) 98.11% <ø> (ø)
controllers (i) 76.00% <ø> (-1.67%) ⬇️
pkg/upgrades 88.88% <ø> (ø)

see 2 files with indirect coverage changes

@KevFan KevFan marked this pull request as ready for review September 17, 2024 13:54
@KevFan KevFan self-assigned this Sep 18, 2024
@KevFan KevFan added kind/enhancement New feature or request size/small labels Sep 18, 2024
@KevFan KevFan requested a review from eguzki September 18, 2024 10:32
Copy link
Contributor

@eguzki eguzki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Just one comment around ENV in dockerfile

Dockerfile Outdated
@@ -31,4 +31,9 @@ WORKDIR /
COPY --from=builder /workspace/manager .
USER 65532:65532

# Quay image expiry
ARG QUAY_IMAGE_EXPIRY
ENV QUAY_IMAGE_EXPIRY=${QUAY_IMAGE_EXPIRY:-never}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this ENV?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I was following the current examples of how this was done. I assumed it was to use the enviroment default value 🤔

# Build
ARG GIT_SHA
ARG DIRTY
ENV GIT_SHA=${GIT_SHA:-unknown}
ENV DIRTY=${DIRTY:-unknown}
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -ldflags "-X main.gitSHA=${GIT_SHA} -X main.dirty=${DIRTY}" -o manager main.go

But this probably can be simpler by doing the following instead if we want to always take it in from the build argument instead

Suggested change
ENV QUAY_IMAGE_EXPIRY=${QUAY_IMAGE_EXPIRY:-never}
ARG QUAY_IMAGE_EXPIRY=never

Let me give it a try and push an update


# Quay image expiry
ARG QUAY_IMAGE_EXPIRY
ENV QUAY_IMAGE_EXPIRY=${QUAY_IMAGE_EXPIRY:-never}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this ENV?

@KevFan KevFan merged commit cc70e4c into main Sep 20, 2024
16 checks passed
@eguzki eguzki deleted the quay-expire-image branch September 23, 2024 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request size/small
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants