Closed Jonesus closed 4 months ago
You can't bootstrap with semver, tags are immutable.
I'm not sure I understand, if I'm supposed to be able to configure Flux to reconcile based on git tags ranked with semver (https://fluxcd.io/flux/components/source/gitrepositories/#semver-example) and the file that configures the reconciliation based on branch, semver etc. is generated with flux_bootstrap_git
, is our desired configuration something that forces us to not use the terraform provider at all?
I also don't understand what tag immutability has to do with the GitRepository
configuration, as it should just read all the tags from the repo and choose the newest one based on semantic versioning.
Bootstrap can only be run for a branch and can only be run once per cluster. You run bootstrap for a dedicated repo, then in there you can add GitRepo/Kustomizations for other repos where your apps are, there you can use semver.
All right, seems that my approach of having a monorepo both for the bootstrap target and the apps to be deployed wasn't really an intended use case, thanks for the explanation :+1:
The failure mode was still somewhat obscure and unexpected, I wonder if the intended way could be clarified somewhat in the docs of if the provider could notice and alert the user when detecting such usage? This might also be offtopic now so if you deem the problem irrelevant the issue can be closed.
It should error out after the default timeout expires, did you waited 5 minutes?
Yeah I did, but the error message that produces –
with flux_bootstrap_git.this,
│ on main.tf line 12, in resource "flux_bootstrap_git" "this":
│ 12: resource "flux_bootstrap_git" "this" {
│
│ bootstrap failed with 2 health check failure(s): [error while waiting for GitRepository to be ready: 'context canceled', error while waiting for Kustomization to be ready:
│ 'client rate limiter Wait returned an error: context canceled']
– Doesn't really point towards the configuration not being intended, especially when the changes actually do get reflected in the target repository even though the Terraform command hangs and times out.
The provider doesn't allow setting anything else but a Git branch. To catch this misconfiguration, we would need to parse the Kustomize patch YAMLs...
Yeah, detecting what the user has configured on the fly probably isn't worth it, thus it's probably better to ensure that users don't try to configure the bootstrapping as I did.
On the error message side, I wonder why does the Terraform provider time out even though the changes do seem to get applied properly?
On the documentation side, a scenario of a user's thought process when setting up a configuration (based on personal experiences):
GitRepository
file has a warning that it shouldn't be edited, so the user digs through the docs to find that the generated file can be augmented with kustomization_override
(https://fluxcd.io/flux/installation/configuration/boostrap-customization/)GitRepository
points to a tag instead of a branchGitRepository
and Kustomization
faced errors when waiting to be readyflux get all -A
and sees that Flux reports the resources ready anywayFurther, reading through the Ways of structuring your repositories, I find it difficult to infer that even when talking about a monorepo approach, the monorepo in this context only means a monorepo of infrastructure and that the Flux bootstrap is supposed to be pointed to the infra repo, instead of an application monorepo.
@Jonesus previously I have had multiple repos for different parts of my overall GitOps setup (for better or for worse).
See the example here. I know @stefanprodan has reservations about this approach due to this file existing there.
However, it worked for me very well and may be useful for you in the future.
@Jonesus you happy for me to close this issue?
Yes, the original issue wasn't really a bug so this issue can be closed.
I still think that the error message or documentation for this use case (even if an unintended one) could be more clear, though.
Yes, the original issue wasn't really a bug so this issue can be closed.
I still think that the error message or documentation for this use case (even if an unintended one) could be more clear, though.
Feel free to submit a PR for the doc changes would be happy to review and get it merged for the next release.
Describe the bug
When trying to use
terraform-provider-flux
withflux_bootstrap_git
, if one tries to change the generatedGitRepository
source ingotk-sync.yaml
to use some other.spec.ref
thanbranch
(for example,semver
) by usingkustomization_override
,terraform apply
hangs until timeout and exits withDespite this, the changes have been properly applied and
flux get all -A --status-selector ready=false
shows nothing, and no logs indicate any problems.If the
kustomization_override
patch doesn't change theGitRepository
then everything works and exits with a success;kustomization_override
can be used to change other configs, likeimage-reflector-controller
for example.Steps to reproduce
flux_bootstrap_git
kustomization_override
to changeGitRepository
to have a.spec.ref
with something else thanbranch
terraform apply
Expected behavior
Running
terraform apply
should exit with a success instead of timing outScreenshots and recordings
No response
Terraform and provider versions
Terraform provider configurations
Relevant Terraform config:
flux_bootstrap_git resource
Contents of
github-sync-patch.yaml
:Flux version
v2.3.0
Additional context
The behavior can be observed in this repository containing reproducing configuration: https://github.com/Jonesus/flux-terraform-repro
The folder
github-with-customizations
was based on https://github.com/fluxcd/terraform-provider-flux/tree/main/examples/github-with-customizations, with the only change being the addition ofpatches[0]
inresources/flux-kustomization-patch.yaml
Code of Conduct
Would you like to implement a fix?
None