Skip to content
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

not a valid Win32 application error on a Windows machine #630

Closed
jakubpawlowski opened this issue Aug 13, 2020 · 18 comments · Fixed by terraform-google-modules/terraform-google-gcloud#73 or #651
Assignees
Labels
bug Something isn't working P2 high priority issues triaged Scoped and ready for work

Comments

@jakubpawlowski
Copy link

I'm trying to run example from examples/safer_cluster folder and getting the following error:

Error: failed to execute ".terraform/modules/gke.gke.gcloud_delete_default_kube_dns_configmap/terraform-google-gcloud-1.4.1/scripts/check_env.sh": fork/exec .terraform/modules/gke.gke.gcloud_delete_default_kube_dns_configmap/terraform-google-gcloud-1.4.1/scripts/check_env.sh: %1 is not a valid Win32 application.

  on .terraform\modules\gke.gke.gcloud_delete_default_kube_dns_configmap\terraform-google-gcloud-1.4.1\main.tf line 70, in data "external" "env_override":
  70: data "external" "env_override" {



Error: failed to execute ".terraform/modules/gke.gke.gcloud_wait_for_cluster/terraform-google-gcloud-1.3.0/scripts/check_env.sh": fork/exec .terraform/modules/gke.gke.gcloud_wait_for_cluster/terraform-google-gcloud-1.3.0/scripts/check_env.sh: %1 is not a valid Win32 application.

  on .terraform\modules\gke.gke.gcloud_wait_for_cluster\terraform-google-gcloud-1.3.0\main.tf line 70, in data "external" "env_override":
  70: data "external" "env_override" {

This seems to be caused by this commit;
65172de Marshall Ford* 18/06/2020 03:18 fix: Use gcloud module for scripts, closes #401 (#404)

In particular going from local-exec provisioner:

provisioner "local-exec" {
    command = "${path.module}/scripts/kubectl_wrapper.sh https://${local.cluster_endpoint} ${data.google_client_config.default.access_token} ${local.cluster_ca_certificate} ${path.module}/scripts/delete-default-resource.sh kube-system configmap kube-dns"
  }

to using "terraform-google-modules/gcloud/google" (and now: "terraform-google-modules/gcloud/google//modules/kubectl-wrapper") which has this line:

data "external" "env_override" {
  program = ["${path.module}/scripts/check_env.sh"]

  query = {}
}

It runs even when I set skip_provisioners = true

This completely blocks usage of this module on Windows machines.

My terraform version (although it should not matter):

$ t version
Terraform v0.13.0
+ provider registry.terraform.io/hashicorp/external v1.2.0
+ provider registry.terraform.io/hashicorp/google v3.16.0
+ provider registry.terraform.io/hashicorp/google-beta v3.29.1
+ provider registry.terraform.io/hashicorp/kubernetes v1.12.0
+ provider registry.terraform.io/hashicorp/null v2.1.2
+ provider registry.terraform.io/hashicorp/random v2.3.0
@bharathkkb
Copy link
Member

I think this should be a fix in the gcloud module and we should be able to fix it by adding a conditional count in that external data resource which respects gcloud moduleenabled.

@bharathkkb
Copy link
Member

@morgante reopening this so we can track the migration for GKE module from current gcloud 1.3.0 to ~>2.0 with this fix.

@bharathkkb bharathkkb reopened this Aug 13, 2020
@CMorton737
Copy link

Would you mind providing some information around a timeline for when this fix will be integrated into this module? As mentioned by OP, this completely blocks usage of this module on windows.

@morgante
Copy link
Contributor

@CMorton737 If you exclude the stub_domains param this should be avoidable. Can you try that workaround?

@Loudsi
Copy link

Loudsi commented Sep 1, 2020

@morgante what do you mean by excluding stud_domains ?
I m trying to run the exemple on the welcome page and i m facing the same issue : https://registry.terraform.io/modules/terraform-google-modules/kubernetes-engine/google/11.0.0

@morgante
Copy link
Contributor

morgante commented Sep 1, 2020

@Loudsi Try setting skip_provisioners = true in your module config.

@bharathkkb
Copy link
Member

@morgante I think the problem was gcloud was not respecting enabled for the data resource so regardless of stub_domains or skip_provisioners this gets triggered. If we can release the patch version for gcloud I can try to upgrade this.

@Loudsi could you try with 10.0 version of this module as a short term workaround?

@Loudsi
Copy link

Loudsi commented Sep 2, 2020

@morgante @bharathkkb thanks for your support, indeed adding skip_provisioners = true in the module config do not work.
And unfortunatly i m using the 0.13.1 version of terraform which is not compatible with gke module version 10. On my side for now it's ok, i will wait for the new patch/release.

@bharathkkb
Copy link
Member

Hi @Loudsi
If you get a chance, can you check if the latest on main fixes issue with skip_provisioners = true ?

@wer-mathurin
Copy link

The version 11.1.0 still use terraform-google-modules/gcloud/google 1.4.1 for:

  • gke.gcloud_delete_default_kube_dns_configmap in .terraform\modules\gke.gcloud_delete_default_kube_dns_configmap\modules\kubectl-wrapper
  • gke.gcloud_delete_default_kube_dns_configmap.gcloud_kubectl in .terraform\modules\gke.gcloud_delete_default_kube_dns_configmap

AND
terraform-google-modules/gcloud/google 1.3.0 for gke.gcloud_wait_for_cluster...

  • gke.gcloud_wait_for_cluster in .terraform\modules\gke.gcloud_wait_for_cluster

@bharathkkb
Copy link
Member

Hi @wer-mathurin
Can you check if the latest on main fixes issue with skip_provisioners = true ? Version 11.1.0 does not have this fix but you can do something like

module "gke" {
  source = "github.com/terraform-google-modules/terraform-google-kubernetes-engine"
  .
  .
}

@jakubpawlowski
Copy link
Author

I got the latest version and tested by setting skip_provisioners = true in examples/safer-cluster.
I can see still see the error when using skip_provisioners = true.
It goes away when skip_provisioners = false.

That's because there is the following in the beta-private-cluster module:

module "gcloud_wait_for_cluster" {
  source  = "terraform-google-modules/gcloud/google"
  version = "~> 2.0.2"
  enabled = var.skip_provisioners

Definition of the flag:

Flag to skip all local-exec provisioners. It breaks stub_domains and upstream_nameservers variables functionality.

It does seem like an abuse of the flag intended for something else. What if someone needs to run this on windows and does want to skip all local-exec provisioners?

@bharathkkb
Copy link
Member

@jakubpawlowski
Indeed, I believe it should be enabled = ! var.skip_provisioners. Reopening this to track.

@bharathkkb bharathkkb reopened this Sep 10, 2020
@jakubpawlowski
Copy link
Author

Changing the condition indeed disables a lot of local-exec provisioners in gcloud/google module so that may be the right thing to do

@wer-mathurin
Copy link

skip_provisioners = true

On my side when not specifying the flag everything work as expected.

@bharathkkb
Copy link
Member

@jakubpawlowski fixed via #669

@jakubpawlowski
Copy link
Author

Thanks - it's working fine now with the flag set to true. Looking forward to having this fixed released now :)

@gojanpaolo
Copy link

Hello! We're getting a similar error on version 31.1 when use_existing_k8s_sa = true. Should I open a new issue?

module "foo" {
  source     = "terraform-google-modules/kubernetes-engine/google//modules/workload-identity"
  version    = "~> 31.1"
  project_id = var.project_id
  name       = "foo"
  use_existing_k8s_sa = true
}
│ Error: External Program Execution Failed
│
│   with module.foo.module.annotate-sa.module.gcloud_kubectl.data.external.env_override[0],
│   on .terraform\modules\...cert_manager_workload_identity.annotate-sa\main.tf line 74, in data "external" "env_override":
│   74:   program = ["${path.module}/scripts/check_env.sh"]
│
│ The data source received an unexpected error while attempting to execute the program.
│
│ The program was executed, however it returned no additional error messaging.
│
│ Program: .terraform/modules/....cert_manager_workload_identity.annotate-sa/scripts/check_env.sh
│ State: fork/exec .terraform/modules/....cert_manager_workload_identity.annotate-sa/scripts/check_env.sh: %1 is not a valid Win32 application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P2 high priority issues triaged Scoped and ready for work
Projects
None yet
7 participants