-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Fix zsh-specific syntax in retry loop within null_resource.update_config_map_aws_auth #245
Fix zsh-specific syntax in retry loop within null_resource.update_config_map_aws_auth #245
Conversation
@@ -8,7 +8,7 @@ resource "null_resource" "update_config_map_aws_auth" { | |||
depends_on = ["aws_eks_cluster.this"] | |||
|
|||
provisioner "local-exec" { | |||
command = "for i in {1..5}; do kubectl apply -f ${var.config_output_path}config-map-aws-auth_${var.cluster_name}.yaml --kubeconfig ${var.config_output_path}kubeconfig_${var.cluster_name} && break || sleep 10; done" | |||
command = "for i in `seq 1 10`; do kubectl apply -f ${var.config_output_path}config-map-aws-auth_${var.cluster_name}.yaml --kubeconfig ${var.config_output_path}kubeconfig_${var.cluster_name} && exit 0 || sleep 10; done; exit 1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, I don't know if the {1..5}
syntax is zsh-specific as it appears to work on the Mac version of bash:
erik:terraform erik.lattimore$ for i in {1..5}; do echo $i; done
1
2
3
4
5
erik:terraform erik.lattimore$ echo $SHELL
/bin/bash
erik:terraform erik.lattimore$ /bin/bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18)
Copyright (C) 2007 Free Software Foundation, Inc.
But agree it isn't POSIX compliant so your change seems better. Most important though is the exit handling though if we reach the end of the loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the sake of curiosity, I tested that statement on a few more envs...
Alpine Linux: {1..5}
fail, seq 1 5
pass
Ubuntu 18:04: {1..5}
pass, seq 1 5
pass
Debian: {1..5}
pass, seq 1 5
pass
Centos: {1..5}
pass, seq 1 5
pass
Ouch, it seems to be (yet another) one of those Alpine quirks. As a matter of fact, we run Terraform via a docker image based on Alpine, which explains why I noticed the "bug".
Considering Alpine use is widespread I still think it's a worthwhile change though.
I agree with you the more important issue is the exit code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK great, thanks for testing those other OSs.
Hi @max-rocket-internet is there a chance we could see this fixed in e.g. 1.8.1 ? I am able to offer help if there's anything I can do. |
You mean you just want a new release? e.g. |
Yes, a new release. I was thinking about 1.8.1 because in 2.0.0 there are breaking changes, but I guess we can bear upgrading to a 2.0.1 and adjust our codebase accordingly. |
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. |
PR o'clock
Description
This is a fix for #238
Fixes two problems:
Checklist
terraform fmt
andterraform validate
both work from the root andexamples/eks_test_fixture
directories (look in CI for an example)Tests
Not sure how to add automated testing to this.
I did test my code changes manually against module version 1.8.0, and noticed it took
kubectl
4 times before succeeding.I therefore thought it would be safer to increase the number of retries to 10