fluxcd/terraform-provider-flux

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

philip-harvey opened this issue · 10 comments

Describe the bug

Since the release of v2.3.0 #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

  • I agree to follow this project's Code of Conduct

Would you like to implement a fix?

None

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

@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.

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 /

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.

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

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.

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.

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

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

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.