Skip to content

Commit

Permalink
Merge pull request #84 from archisgore/archis/add-timeouts
Browse files Browse the repository at this point in the history
Add AWS API call timeouts
  • Loading branch information
errordeveloper authored Jun 27, 2018
2 parents 35cb275 + 1b3e122 commit a71ba69
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
2 changes: 2 additions & 0 deletions cmd/eksctl/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ func createClusterCmd() *cobra.Command {
fs.BoolVar(&autoKubeconfigPath, "auto-kubeconfig", false, fmt.Sprintf("save kubconfig file by cluster name, e.g. %q", utils.ConfigPath(exampleClusterName)))
fs.StringVar(&kubeconfigPath, "kubeconfig", DEFAULT_KUBECONFIG_PATH, "path to write kubeconfig (incompatible with --auto-kubeconfig)")

fs.IntVar(&cfg.AWSOperationTimeoutSeconds, "aws-api-timeout", 300, "number of seconds after which to timeout AWS API operations")

return cmd
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/eksctl/version_release.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// +build release

package main

// this file was generated by version_generate.go
var builtAt = "" // will be set by goreleaser tool
var builtAt = "" // will be set by goreleaser tool
var gitCommit = "" // will be set by goreleaser tool
var gitTag = "0.1.0-alpha.20"
2 changes: 2 additions & 0 deletions pkg/eks/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ type ClusterConfig struct {
SSHPublicKeyPath string
SSHPublicKey []byte

AWSOperationTimeoutSeconds int

keyName string
clusterRoleARN string
securityGroup string
Expand Down
10 changes: 9 additions & 1 deletion pkg/eks/cfn.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,18 @@ func (c *ClusterProvider) CreateStack(name string, templateBody []byte, paramete
go func() {
ticker := time.NewTicker(20 * time.Second)
defer ticker.Stop()

timer := time.NewTimer(time.Duration(c.cfg.AWSOperationTimeoutSeconds) * time.Second)
defer timer.Stop()

defer close(errs)
for {
select {
// TODO: https://github.com/weaveworks/eksctl/issues/23
case <-timer.C:
errs <- fmt.Errorf("creating CloudFormation stack %q timed out after %d seconds", name, c.cfg.AWSOperationTimeoutSeconds)
logger.Debug("stack = %#v", s)
return

case <-ticker.C:
s, err := c.describeStack(&name)
if err != nil {
Expand Down
10 changes: 9 additions & 1 deletion pkg/eks/eks.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,19 @@ func (c *ClusterProvider) createControlPlane(errs chan error) error {
go func() {
ticker := time.NewTicker(20 * time.Second)
defer ticker.Stop()

timer := time.NewTimer(time.Duration(c.cfg.AWSOperationTimeoutSeconds) * time.Second)
defer timer.Stop()

defer close(taskErrs)
defer close(clusterChan)

for {
select {
// TODO: https://github.com/weaveworks/eksctl/issues/23
case <-timer.C:
taskErrs <- fmt.Errorf("timed out creating control plane %q after %d seconds", c.cfg.ClusterName, c.cfg.AWSOperationTimeoutSeconds)
return

case <-ticker.C:
cluster, err := c.DescribeControlPlane()
if err != nil {
Expand Down

0 comments on commit a71ba69

Please sign in to comment.