Closed dempo93 closed 1 month ago
@dempo93, great spot. Could you please try using the latest version of the provider and report back please.
required_providers {
flux = {
source = "fluxcd/flux"
version = "1.2.3"
}
}
The namespace is part of the Flux manifests and that's why TF deletes it. In the Flux CLI we have flux uninstall --keep-namespace
.
@stefanprodan understood, we are going to need to look at all state and see if their is a namespace there for flux-system
and if so set --keep-namespace
on the uninstall flow.
I would just add an option to the bootstrap resource for every CLI option, like --keep-namespace
and document it so users can just choose to do that. Otherwise you are going to get into some very sticky situations trying to interpret state and what should be done vs just pushing to the user to decide during configuration.
There are too many ways the namespace could be created and not trackable by the provider and flux to know what to do.
Sorry, didn't get to update flux and test on the latest version yet. However great you already tackled the issue. Thank you!
Describe the bug
Our deployment of flux looks like this
We recently got an incident because flux decided to delete a namespace it didn't create upon destruction. I think the culprit is here: https://github.com/fluxcd/terraform-provider-flux/blob/main/internal/provider/resource_bootstrap_git.go#L652C77-L652C88
The terraform provider should attempt to delete the namespace only if it created it, not if it was created externally.
flux uninstall
cli command provides an option to avoid this behavior:--keep-namespace
Steps to reproduce
As flux was stuck for a different reason those are the steps that I undertook. With the code above,
I believe the same could be reproduced by simply
Expected behavior
Namespace is not destroyed at any point
Screenshots and recordings
No response
Terraform and provider versions
Terraform provider configurations
flux_bootstrap_git resource
Flux version
0.23.0
Additional context
No response
Code of Conduct
Would you like to implement a fix?
None