fluxcd / terraform-provider-flux

Terraform and OpenTofu provider for bootstrapping Flux
https://registry.terraform.io/providers/fluxcd/flux/latest
Apache License 2.0
368 stars 86 forks source link

[Bug]: v2.3.0 breaks support for Windows OS #693

Closed philip-harvey closed 6 months ago

philip-harvey commented 6 months ago

Describe the bug

Since the release of v2.3.0 https://github.com/fluxcd/terraform-provider-flux/pull/689 Flux no longer works on Windows OS.

Steps to reproduce

terraform plan or apply

Expected behavior

Flux works on Windows OS, as it did previously.

Screenshots and recordings

Error: Getting expected repository files │ │ with module.flux-transitions-gke.flux_bootstrap_git.flux, │ on ....\modules\flux-gke\main.tf line 24, in resource "flux_bootstrap_git" "flux": │ 24: resource "flux_bootstrap_git" "flux" { │ │ could not generate install manifests: CreateFile \gotk-components.yaml: The specified path is invalid.

Rolling back to v2.2.3 resolved the issue.

Terraform and provider versions

Terraform v1.8.3 on windows_amd64

Terraform provider configurations

provider "flux" { alias = "transitions" kubernetes = { host = "https://${google_dns_record_set.transitions_gke_master.rrdatas.0}" cluster_ca_certificate = base64decode(module.transitions-cluster.ca_certificate) token = data.google_client_config.provider.access_token } git = { url = module.flux-transitions-github.url ssh = { username = "git" private_key = module.flux-transitions-github.ssh_private_key } } }

flux_bootstrap_git resource

resource "flux_bootstrap_git" "flux" { path = var.target_path kustomization_override = local.kustomize_file namespace = var.namespace cluster_domain = var.cluster_domain }

locals { kustomize_file = templatefile("${path.module}/templates/kustomization.yaml.tmpl", { gcp_service_account = resource.google_service_account.flux_sops.email, nodepool = var.nodepool, namespace = var.namespace }) k8s_kustomize_sa_gcp_derived_name = "serviceAccount:${var.project_id}.svc.id.goog[${var.namespace}/kustomize-controller]" }

Flux version

2.3.0

Additional context

No response

Code of Conduct

Would you like to implement a fix?

None

swade1987 commented 6 months ago

@philip-harvey did you just upgrade from version 2.2.3 to 2.3.0 with no changes and terraform apply failed?

philip-harvey commented 6 months ago

@philip-harvey did you just upgrade from version 2.2.3 to 2.3.0 with no changes and terraform apply failed?

Yes, the exact same terraform fails the plan/apply as soon as the provider is upgraded to 2.3.0 and works again as soon as the provider is downgraded to 2.2.3 again, so it's definitely a provider issue.

stefanprodan commented 6 months ago

Verifying if this issue is specific to Windows will help us narrow down the problem.

The error message is quite telling, the path is for Windows \gotk-components.yaml Unix uses /

philip-harvey commented 6 months ago

Verifying if this issue is specific to Windows will help us narrow down the problem.

The error message is quite telling, the path is for Windows \gotk-components.yaml Unix uses /

Yes, the issue is specific to Windows and is new in 2.3.0. 2.3.0 works on Linux OS but not on Windows OS.

swade1987 commented 6 months ago

I think what @stefanprodan showed above is spot on; it's the \ versus / issue.

philip-harvey commented 6 months ago

I think what @stefanprodan showed above is spot on; it's the \ versus / issue.

Understood, but I can't see what in the 2.3.0 release is breaking the path on Windows, it was working correctly in prior versions.

swade1987 commented 6 months ago

We have changed from

installManifests, err := install.Generate(installOpts, "")

To the following ...

manifestsBase := ""
if data.EmbeddedManifests.ValueBool() {
  manifestsBase = EmbeddedManifests
}

installManifests, err := install.Generate(installOpts, manifestsBase)

This was for the work to allow air-gapped installations.

@philip-harvey please try adding embedded_manifests = true to our flux_bootstrap_git resource and see if that helps please. As your setup is similar to this example.

philip-harvey commented 6 months ago

We have changed from

installManifests, err := install.Generate(installOpts, "")

To the following ...

manifestsBase := ""
if data.EmbeddedManifests.ValueBool() {
  manifestsBase = EmbeddedManifests
}

installManifests, err := install.Generate(installOpts, manifestsBase)

This was for the work to allow air-gapped installations.

@philip-harvey please try adding embedded_manifests = true to our flux_bootstrap_git resource and see if that helps please. As your setup is similar to this example.

Setting embedded_manifests = true seems to work around the issue, thanks for the suggestion

brokenjacobs commented 6 months ago

are there any future issues with embedded_manifests not being in sync with github?

stefanprodan commented 6 months ago

are there any future issues with embedded_manifests not being in sync with github?

There are no issues, this is how the Flux CLI works by default. Every time we release Flux, we also release a new provider version that embeds the latest manifests. It is recommend to enable embedded_manifests and drive the upgrade by bumping the provider version.