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

Skip garbage collection of objects with owner references #411

Merged
merged 2 commits into from
Aug 26, 2021

Conversation

stefanprodan
Copy link
Member

@stefanprodan stefanprodan commented Aug 18, 2021

Looks like #362 didn't do much, various Kubernetes controllers copy the metadata (labels and annotations) from their custom resources to generated objects. To fix this once and for all, kustomize-controller will skip pruning any object that has ownerReference.BlockOwnerDeletion=true. There is no reason why Flux should try to delete objects with BlockOwnerDeletion as Kubernetes GC should prune them.

Fix: #415
Fix: #410

Test image

To test this PR please use the following image:

ghcr.io/fluxcd/kustomize-controller:rc-a49bbf9e

To upgrade kustomize-controller on an cluster bootstrapped with flux, add the following images section to your flux-system/kustomization.yaml:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - gotk-components.yaml
  - gotk-sync.yaml
images:
- name: ghcr.io/fluxcd/kustomize-controller
  newName: ghcr.io/fluxcd/kustomize-controller
  newTag: rc-a49bbf9e

@stefanprodan stefanprodan requested a review from hiddeco August 18, 2021 08:26
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
@stefanprodan stefanprodan force-pushed the skip-gc-for-ownerReference branch from 94f68a8 to a49bbf9 Compare August 18, 2021 09:49
@phillebaba
Copy link
Member

I think that it would be good to add a small test for this if possible just because the impact seems to be very large on end users if this is ever removed in the future by accident. Other than that this looks good.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
@stefanprodan stefanprodan force-pushed the skip-gc-for-ownerReference branch from 59376db to 16c451b Compare August 19, 2021 14:15
@stefanprodan stefanprodan requested review from phillebaba and removed request for hiddeco August 19, 2021 14:26
@stefanprodan
Copy link
Member Author

@phillebaba I've added tests for when BlockOwnerDeletion is enabled or not.

Copy link
Member

@phillebaba phillebaba left a comment

Choose a reason for hiding this comment

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

LGTM

@stefanprodan stefanprodan merged commit c637838 into main Aug 26, 2021
@stefanprodan stefanprodan deleted the skip-gc-for-ownerReference branch August 26, 2021 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants