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

Do not reconcile images and builds being deleted #1820

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

danail-branekov
Copy link
Contributor

When an image is being deleted, k8s does not delete the object immediately, instead it sets the deletion timestamp awaiting finalization. See
k8s docs for details

If the kpack image (or its builds) has a finalizer being added by an external component (such as
Korifi), then when the client request the object to be deleted, the image/build reconcilers keep reconciling the image/build causing new build pods to be created as the image is being deleted. Even though eventually the image gets deleted, it takes significant amount of time.

In order to address this, this PR "short-circuits" the image and build reconcilers to immediately return whenever an image or a build has their deletion timestamp set, thus preventing builds and build pods being rescheduled.

When an image is being deleted, k8s does not delete the object
immediately, instead it sets the deletion timestamp awaiting
finalization. See [k8s
docs](https://github.com/kubernetes/apimachinery/blob/45d29dc4d66fc2ac83e736e79752ad81a9c6195f/pkg/apis/meta/v1/types.go#L190-L209)
for details

If the kpack image (or its builds) has a finalizer being added by an
external component (such as
[Korifi](https://github.com/cloudfoundry/korifi/blob/17557eb68fed830f3f57abd651882a712fc25f5f/kpack-image-builder/controllers/webhooks/finalizer/finalizer_webhook.go#L25)),
then when the client request the object to be deleted, the image/build
reconcilers keep reconciling the image/build causing new build pods to
be created as the image is being deleted. Even though eventually the
image gets deleted, it takes significant amount of time.

Signed-off-by: Danail Branekov <danailster@gmail.com>
@codecov-commenter
Copy link

⚠️ 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 35.33%. Comparing base (49014e2) to head (5ff9f2a).
Report is 95 commits behind head on main.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1820       +/-   ##
===========================================
- Coverage   67.34%   35.33%   -32.02%     
===========================================
  Files         140      257      +117     
  Lines        8886    19968    +11082     
===========================================
+ Hits         5984     7055     +1071     
- Misses       2393    12311     +9918     
- Partials      509      602       +93     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants