-
Notifications
You must be signed in to change notification settings - Fork 187
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
Garbage collection conflicts with Stash controller #315
Comments
Maybe they are not in a namespace that was targeted by Kustomization with prune enabled? It is hard to say what might be inconsistent about Flux's behavior, or if it is more likely a configuration surprise that we will understand only by reviewing details of your implementation... https://toolkit.fluxcd.io/components/kustomize/kustomization/#garbage-collection There's a workaround for you, in case you can't get Stash to stop doing that and you are still struggling with this until a fix is available, just disable garbage collection of your BackupConfigurations with an annotation or label. Let Stash go on copying the labels, it will copy this one to the service accounts too. (I guess also be sure to re-enable pruning first in the event you ever need to disable and delete an old BackupConfiguration.)
kustomize.toolkit.fluxcd.io/prune: disabled |
It’s a race condition, by the time Flux gets to those SAs, Stash has copied the label value with the new checksum. I don’t see how we can fix any of this in kustomize-controller. |
Everything in the cluster is managed by flux, I used the flux bootstrap command to create a single Kustomization which reconciles all namespaces. For example, in the
|
@stefanprodan What exactly is stored in the checksum and how does flux decide if it should delete the resource? |
The value is computed from the source artifact, it changes every time there is a change in the manifests that are included in the kustomize overlay. Do you know if Stash copies annotations too? |
OK, now I understand the race condition. Flux updates the checksum on the all resources, including the The only strange thing here is, why does Stash not recreate the SA with the new checksum after they have been deleted. Is the checksum the same for all resources of the same Kustomization for a specific source artifact revision?
No it only copies the labels. |
I don't understand the problem in detail. Experiencing same with Strimzi Kafk Operator |
We're moving the checksum from labels to annotations in #362 but if Strimzi copies the annotations then it's the same issue. Seems that for Stash is will work as it copies only labels from the custom resource to the generated objects. |
This is Custome Resource from Strimzi, deployed by Flux
it doesn't look like it has annotations. |
Add an annotation to it and check if the operator copies it on pods and other generated objects, if it doesn't then #362 would fix this. |
@stefanprodan i've added annotation and with prune:false on responsible Kustomization it seem not to destroy the Kafka cluster anymore. Using Flux 0.14.2 |
@aholbreich you may want to test flux 0.15, it should work fine with pruning enabled due to #362 |
@stefanprodan Unfortunately not.
I'm not sure why it deletes resources that are not directly created by Flux.... like
another two being created by the operator, just for the sake of completeness:
|
By the way... this is strange... but are those resources bounded to KS? event when another should care about this place:
flux-system 'looks' to everything in path: ./eks_DevCluster/ but should commit ./eks_DevCluster/kafka-ressources/. |
Retested with new topics. Add remove, modify. Generally, the fix seems to be working! THX! |
A very positive side-effect of migration to annotations is the smooth migration from non-flux resources to flux managed resources!! |
You're applying the same thing twice and Flux will overwrite/delete all, please see how to organise your repos here: https://fluxcd.io/docs/guides/repository-structure/ PS. Move all things outside the clusters dir and create a Flux Kustomization inside clusters for each kustomize overlay. |
Is this really fixed? If I understand the code correctly, a selected resource (i.e. labels I see the same issue with cert-manager and |
I'm using Stash to backup my kubernetes applications. Stash is a k8s operator. I manage the configuration of stash with a kustomization, which applies
BackupConfiguration
s to the cluster. Stash will create a service account for thoseBackupConfiguration
s, therefore it copies the labels of theBackupConfiguration
, which includes thekustomize.toolkit.fluxcd.io/checksum
label.Because the service account is not managed by flux and has the
kustomize.toolkit.fluxcd.io/checksum
label and pruning is activated, flux garbage collects the service account. As a result, the backups with stash do not work. This is probably a problem which must be fixed in stash, so I created an issue there stashed/stash#1334.However, the garbage collection behavior of flux is inconsistent. I have four
BackupConfiguration
s each with its own service account, but flux only deletes two of them. The two remaining service accounts have thekustomize.toolkit.fluxcd.io/checksum
label, but are not garbage collected by flux.The text was updated successfully, but these errors were encountered: