Possible race condition on creating IAM Service Accounts when eksctl creates the namespace
What happened? I feel there's a race condition when creating IAM Service Account and the namespace is created by eksctl. I run eksctl create cluster using a config file and we see sporadic errors about the namespace is already created.
What you expected to happen? I expected the following to happen:
- If the namespace does NOT exits, create the namespace, else continue
- Create the list of IAM service accounts from config
I feel this error is a moot point, because I don't see the issue if the namespace exist before I run eksctl. We see this error IF eksctl creates the namespace.
How to reproduce it? Hard because this might be a race condition and this issue is very sporadic and please see logs below. Sorry didn't capture it with debug set.
Anything else we need to know? Running in a docker container:
$ uname -a
Linux 3a2e2cd38b39 4.19.76-linuxkit #1 SMP Thu Oct 17 19:31:58 UTC 2019 x86_64 Linux
Versions Please paste in the output of these commands:
$ eksctl version
0.15.0
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.11", GitCommit:"d94a81c724ea8e1ccc9002d89b7fe81d58f89ede", GitTreeState:"clean", BuildDate:"2020-03-12T21:08:59Z", GoVersion:"go1.12.17", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"14+", GitVersion:"v1.14.9-eks-502bfb", GitCommit:"502bfb383169b124d87848f89e17a04b9fc1f6f0", GitTreeState:"clean", BuildDate:"2020-02-07T01:31:02Z", GoVersion:"go1.12.12", Compiler:"gc", Platform:"linux/amd64"}
Logs
2020/03/23 23:53:44 workdir: /workspace
2020/03/23 23:53:44 fetch the helper scripts [master]...
downloading git::https://git-ext.ecd.axway.com/cloud/eks.git//hack?ref=master
2020/03/23 23:53:46 success!
2020/03/23 23:53:46 fetch the eksctl templates [master]...
downloading git::https://git-ext.ecd.axway.com/cloud/eks.git//templates?ref=master
2020/03/23 23:53:47 success!
[ℹ] eksctl version 0.15.0
[ℹ] using region us-east-1
[✔] using existing VPC (vpc-071f4b1e65a795f34) and subnets (private:[subnet-03f20ce03b399ad82 subnet-02273ba83140801fe subnet-0552215211e0ee505] public:[subnet-063288b6bf5d5b24d subnet-02668bef8e029bf7e subnet-05ef50cefb9705a6c])
[!] custom VPC/subnets will be used; if resulting cluster doesn't function as expected, make sure to review the configuration of VPC/subnets
[ℹ] using Kubernetes version 1.14
[ℹ] creating EKS cluster "bq-sample-project" in "us-east-1" region with
[ℹ] will create a CloudFormation stack for cluster itself and 0 nodegroup stack(s)
[ℹ] will create a CloudFormation stack for cluster itself and 0 managed nodegroup stack(s)
[ℹ] if you encounter any issues, check CloudFormation console or try 'eksctl utils describe-stacks --region=us-east-1 --cluster=bq-sample-project'
[ℹ] CloudWatch logging will not be enabled for cluster "bq-sample-project" in "us-east-1"
[ℹ] you can enable it with 'eksctl utils update-cluster-logging --region=us-east-1 --cluster=bq-sample-project'
[ℹ] Kubernetes API endpoint access will use provided values {publicAccess=true, privateAccess=true} for cluster "bq-sample-project" in "us-east-1"
[ℹ] 2 sequential tasks: { create cluster control plane "bq-sample-project", 3 sequential sub-tasks: { associate IAM OIDC provider, 4 parallel sub-tasks: { 2 sequential sub-tasks: { create IAM role for serviceaccount "add-ons/aws-external-dns", create serviceaccount "add-ons/aws-external-dns" }, 2 sequential sub-tasks: { create IAM role for serviceaccount "add-ons/aws-cluster-autoscaler", create serviceaccount "add-ons/aws-cluster-autoscaler" }, 2 sequential sub-tasks: { create IAM role for serviceaccount "add-ons/cert-manager", create serviceaccount "add-ons/cert-manager" }, 2 sequential sub-tasks: { create IAM role for serviceaccount "add-ons/aws-velero", create serviceaccount "add-ons/aws-velero" } }, update cluster VPC endpoint access configuration } }
[ℹ] building cluster stack "eksctl-bq-sample-project-cluster"
[ℹ] deploying stack "eksctl-bq-sample-project-cluster"
[ℹ] building iamserviceaccount stack "eksctl-bq-sample-project-addon-iamserviceaccount-add-ons-aws-velero"
[ℹ] building iamserviceaccount stack "eksctl-bq-sample-project-addon-iamserviceaccount-add-ons-aws-cluster-autoscaler"
[ℹ] building iamserviceaccount stack "eksctl-bq-sample-project-addon-iamserviceaccount-add-ons-cert-manager"
[ℹ] building iamserviceaccount stack "eksctl-bq-sample-project-addon-iamserviceaccount-add-ons-aws-external-dns"
[ℹ] deploying stack "eksctl-bq-sample-project-addon-iamserviceaccount-add-ons-aws-external-dns"
[ℹ] deploying stack "eksctl-bq-sample-project-addon-iamserviceaccount-add-ons-cert-manager"
[ℹ] deploying stack "eksctl-bq-sample-project-addon-iamserviceaccount-add-ons-aws-velero"
[ℹ] deploying stack "eksctl-bq-sample-project-addon-iamserviceaccount-add-ons-aws-cluster-autoscaler"
[ℹ] created namespace "add-ons"
[ℹ] 1 error(s) occurred and cluster hasn't been created properly, you may wish to check CloudFormation console
[ℹ] to cleanup resources, run 'eksctl delete cluster --region=us-east-1 --name=bq-sample-project'
[✖] namespaces "add-ons" already exists
Error: failed to create cluster "bq-sample-project"
I confirm the race condition, I'm also experiencing it.
Here's some logs with debug enabled:
2020-03-24T14:36:54-07:00 [ℹ] deploying stack "eksctl-cluster-1-addon-iamserviceaccount-new-namespace-sa3"
2020-03-24T14:36:54-07:00 [▶] start waiting for CloudFormation stack "eksctl-cluster-1-addon-iamserviceaccount-new-namespace-sa3"
2020-03-24T14:36:54-07:00 [▶] waiting for CloudFormation stack "eksctl-cluster-1-addon-iamserviceaccount-new-namespace-sa3"
2020-03-24T14:36:54-07:00 [ℹ] deploying stack "eksctl-cluster-1-addon-iamserviceaccount-new-namespace-sa1"
2020-03-24T14:36:54-07:00 [▶] start waiting for CloudFormation stack "eksctl-cluster-1-addon-iamserviceaccount-new-namespace-sa1"
2020-03-24T14:36:54-07:00 [▶] waiting for CloudFormation stack "eksctl-cluster-1-addon-iamserviceaccount-new-namespace-sa1"
2020-03-24T14:36:54-07:00 [ℹ] deploying stack "eksctl-cluster-1-addon-iamserviceaccount-new-namespace-sa2"
2020-03-24T14:36:54-07:00 [▶] start waiting for CloudFormation stack "eksctl-cluster-1-addon-iamserviceaccount-new-namespace-sa2"
2020-03-24T14:36:54-07:00 [▶] waiting for CloudFormation stack "eksctl-cluster-1-addon-iamserviceaccount-new-namespace-sa2"
2020-03-24T14:37:09-07:00 [▶] waiting for CloudFormation stack "eksctl-cluster-1-addon-iamserviceaccount-new-namespace-sa2"
2020-03-24T14:37:10-07:00 [▶] waiting for CloudFormation stack "eksctl-cluster-1-addon-iamserviceaccount-new-namespace-sa1"
2020-03-24T14:37:11-07:00 [▶] waiting for CloudFormation stack "eksctl-cluster-1-addon-iamserviceaccount-new-namespace-sa3"
2020-03-24T14:37:26-07:00 [▶] waiting for CloudFormation stack "eksctl-cluster-1-addon-iamserviceaccount-new-namespace-sa1"
2020-03-24T14:37:26-07:00 [▶] done after 31.923226827s of waiting for CloudFormation stack "eksctl-cluster-1-addon-iamserviceaccount-new-namespace-sa1"
2020-03-24T14:37:26-07:00 [▶] completed task: create IAM role for serviceaccount "new-namespace/sa1"
2020-03-24T14:37:26-07:00 [▶] started task: create serviceaccount "new-namespace/sa1"
2020-03-24T14:37:28-07:00 [▶] waiting for CloudFormation stack "eksctl-cluster-1-addon-iamserviceaccount-new-namespace-sa2"
2020-03-24T14:37:28-07:00 [▶] done after 34.20655782s of waiting for CloudFormation stack "eksctl-cluster-1-addon-iamserviceaccount-new-namespace-sa2"
2020-03-24T14:37:28-07:00 [▶] completed task: create IAM role for serviceaccount "new-namespace/sa2"
2020-03-24T14:37:28-07:00 [▶] started task: create serviceaccount "new-namespace/sa2"
2020-03-24T14:37:31-07:00 [▶] waiting for CloudFormation stack "eksctl-cluster-1-addon-iamserviceaccount-new-namespace-sa3"
2020-03-24T14:37:31-07:00 [▶] done after 36.838727546s of waiting for CloudFormation stack "eksctl-cluster-1-addon-iamserviceaccount-new-namespace-sa3"
2020-03-24T14:37:31-07:00 [▶] completed task: create IAM role for serviceaccount "new-namespace/sa3"
2020-03-24T14:37:31-07:00 [▶] started task: create serviceaccount "new-namespace/sa3"
2020-03-24T14:37:42-07:00 [ℹ] created namespace "new-namespace"
2020-03-24T14:37:42-07:00 [▶] failed task: create serviceaccount "new-namespace/sa3" (will not run other sequential tasks)
2020-03-24T14:37:42-07:00 [▶] failed task: 2 sequential sub-tasks: { create IAM role for serviceaccount "new-namespace/sa3", create serviceaccount "new-namespace/sa3" } (will continue until other parallel tasks are completed)
2020-03-24T14:37:42-07:00 [▶] failed task: 3 parallel sub-tasks: { 2 sequential sub-tasks: { create IAM role for serviceaccount "new-namespace/sa1", create serviceaccount "new-namespace/sa1" }, 2 sequential sub-tasks: { create IAM role for serviceaccount "new-namespace/sa2", create serviceaccount "new-namespace/sa2" }, 2 sequential sub-tasks: { create IAM role for serviceaccount "new-namespace/sa3", create serviceaccount "new-namespace/sa3" } } (will not run other sequential tasks)
2020-03-24T14:37:42-07:00 [▶] failed task: 2 sequential sub-tasks: { associate IAM OIDC provider, 3 parallel sub-tasks: { 2 sequential sub-tasks: { create IAM role for serviceaccount "new-namespace/sa1", create serviceaccount "new-namespace/sa1" }, 2 sequential sub-tasks: { create IAM role for serviceaccount "new-namespace/sa2", create serviceaccount "new-namespace/sa2" }, 2 sequential sub-tasks: { create IAM role for serviceaccount "new-namespace/sa3", create serviceaccount "new-namespace/sa3" } } } (will not run other sequential tasks)
2020-03-24T14:37:42-07:00 [ℹ] 1 error(s) occurred and cluster hasn't been created properly, you may wish to check CloudFormation console
2020-03-24T14:37:42-07:00 [ℹ] to cleanup resources, run 'eksctl delete cluster --region=us-east-1 --name=cluster-1'
2020-03-24T14:37:42-07:00 [✖] namespaces "new-namespace" already exists
Error: failed to create cluster "cluster-1"
2020-03-24T14:37:42-07:00 [▶] failed task: create serviceaccount "new-namespace/sa1" (will not run other sequential tasks)
2020-03-24T14:37:42-07:00 [▶] failed task: 2 sequential sub-tasks: { create IAM role for serviceaccount "new-namespace/sa1", create serviceaccount "new-namespace/sa1" } (will continue until other parallel tasks are completed)
Also confirming, but additionally, it seems to be completing the work ok, just throwing up this error during the process. It does appear that the service accounts are being created ok.