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

improvement: update the wait_for_cluster_cmd logic to use curl if wget doesn't exist #1002

Merged
merged 1 commit into from
Oct 5, 2020
Merged

improvement: update the wait_for_cluster_cmd logic to use curl if wget doesn't exist #1002

merged 1 commit into from
Oct 5, 2020

Conversation

daroga0002
Copy link
Contributor

@daroga0002 daroga0002 commented Sep 7, 2020

PR o'clock

Description

This PR is addressing issue related to wait_for_cluster_cmd check which is defaulting to wget. This is brining error if you missing wget on local system where you execute Terraform apply. This can be customized via wait_for_cluster_cmd but usually people are not following this and meet issue. In past there was few issues opened for this:

#998
#829

This PR is changing default wait_for_cluster_cmd to contain conditional which is checking wget availability, if this is missing then switch to curl. This logic should remediate most of issues which users meet (as wget is available on most linux distrubution and containers, where curl is available out of box in Mac OS).

I have tested module on my Mac OS with wget available, then repeated test with unavailable wget and available curl:

Execution with wget available:

$ terraform apply
.......................
module.eks.aws_eks_cluster.this[0]: Still creating... [9m40s elapsed]
module.eks.aws_eks_cluster.this[0]: Creation complete after 9m44s [id=test-eks-irsa]
module.eks.null_resource.wait_for_cluster[0]: Creating...
module.eks.aws_iam_openid_connect_provider.oidc_provider[0]: Creating...
module.eks.aws_iam_role.workers[0]: Creating...
module.eks.data.template_file.userdata[0]: Refreshing state...
module.eks.null_resource.wait_for_cluster[0]: Provisioning with 'local-exec'...
module.iam_assumable_role_admin.data.aws_iam_policy_document.assume_role_with_oidc[0]: Refreshing state...
module.eks.null_resource.wait_for_cluster[0] (local-exec): Executing: ["/bin/sh" "-c" "for i in `seq 1 60`; do if `command -v wget > /dev/null`; then wget --no-check-certificate -O - -q $ENDPOINT/healthz >/dev/null && exit 0 || true; else curl -k -s $ENDPOINT/healthz >/dev/null && exit 0 || true;fi; sleep 5; done; echo TIMEOUT && exit 1"]
module.eks.local_file.kubeconfig[0]: Creating...
.......................
module.iam_assumable_role_admin.aws_iam_role_policy_attachment.custom[0]: Creation complete after 2s [id=cluster-autoscaler-2020090709290497280000000f]

Apply complete! Resources: 38 added, 0 changed, 0 destroyed.
.......................

Removed wget

$ command -v wget
$ command -v curl 
/usr/bin/curl
$ 

Execution with wget unavailable:

$ terraform apply
.......................
module.eks.aws_eks_cluster.this[0]: Still creating... [13m0s elapsed]
module.eks.aws_eks_cluster.this[0]: Creation complete after 13m5s [id=test-eks-irsa]
module.eks.null_resource.wait_for_cluster[0]: Creating...
module.iam_assumable_role_admin.data.aws_iam_policy_document.assume_role_with_oidc[0]: Refreshing state...
module.eks.aws_iam_openid_connect_provider.oidc_provider[0]: Creating...
module.eks.aws_iam_role.workers[0]: Creating...
module.eks.data.template_file.userdata[0]: Refreshing state...
module.eks.null_resource.wait_for_cluster[0]: Provisioning with 'local-exec'...
module.eks.null_resource.wait_for_cluster[0] (local-exec): Executing: ["/bin/sh" "-c" "for i in `seq 1 60`; do if `command -v wget > /dev/null`; then wget --no-check-certificate -O - -q $ENDPOINT/healthz >/dev/null && exit 0 || true; else curl -k -s $ENDPOINT/healthz >/dev/null && exit 0 || true;fi; sleep 5; done; echo TIMEOUT && exit 1"]
module.eks.local_file.kubeconfig[0]: Creating...
module.eks.local_file.kubeconfig[0]: Creation complete after 0s [id=73dcc2465e8a560fe68b82dfd8aa20d4160e6d73]
.......................
module.iam_assumable_role_admin.aws_iam_role_policy_attachment.custom[0]: Creation complete after 2s [id=cluster-autoscaler-2020090709555407010000000f]

Apply complete! Resources: 38 added, 0 changed, 0 destroyed.
.......................

Checklist

@random930
Copy link

Great idea! Looks good to me.

@barryib
Copy link
Member

barryib commented Oct 4, 2020

Thanks @daroga0002 for your contribution, can you please rebase your branch master to resolve conflict so I can merge your PR in ?

@barryib barryib changed the title improvement: update wait_for_cluster_cmd logic improvement: update wait_for_cluster_cmd logic to use curl if wget doesn't exist Oct 4, 2020
@barryib barryib changed the title improvement: update wait_for_cluster_cmd logic to use curl if wget doesn't exist improvement: update the wait_for_cluster_cmd logic to use curl if wget doesn't exist Oct 4, 2020
@barryib barryib self-assigned this Oct 4, 2020
@barryib barryib added this to the v13.0.0 milestone Oct 4, 2020
@barryib barryib merged commit d8ab5d4 into terraform-aws-modules:master Oct 5, 2020
@barryib
Copy link
Member

barryib commented Oct 5, 2020

Thanks @daroga0002 for your contribution.

@daroga0002 daroga0002 deleted the wait_for_cluster_failover branch October 5, 2020 13:06
barryib pushed a commit to Polyconseil/terraform-aws-eks that referenced this pull request Oct 25, 2020
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants