Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Readded the ability to delete a cluster before it's finished creating
A previous PR (#1010) made it a prerequisite that an EKS cluster must be in an ACTIVE state before `eksctl delete cluster` would be able to delete the cluster. This was done to find all the ELBs that were created due to services in the cluster. However, if a cluster isn't created, there can be no ELBs created for the cluster, so this PR removes that restriction and adds some integration tests for this use case.
- Loading branch information
Showing
4 changed files
with
109 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// +build integration | ||
|
||
package integration_test | ||
|
||
import ( | ||
"fmt" | ||
|
||
awseks "github.com/aws/aws-sdk-go/service/eks" | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
"github.com/weaveworks/eksctl/pkg/ctl/cmdutils" | ||
"github.com/weaveworks/eksctl/pkg/testutils/aws" | ||
. "github.com/weaveworks/eksctl/pkg/testutils/matchers" | ||
) | ||
|
||
var _ = Describe("(Integration) Create & Delete before Active", func() { | ||
const ( | ||
initNG = "ng-0" | ||
testNG = "ng-1" | ||
) | ||
|
||
Describe("when creating a cluster with 1 node", func() { | ||
var clName string | ||
Context("for deleting a creating cluster", func() { | ||
It("should run eksctl and not wait for it to finish", func() { | ||
|
||
fmt.Fprintf(GinkgoWriter, "Using kubeconfig: %s\n", kubeconfigPath) | ||
|
||
if clName == "" { | ||
clName = cmdutils.ClusterName("", "") + "-delb4active" | ||
} | ||
|
||
eksctlStart("create", "cluster", | ||
"--verbose", "4", | ||
"--name", clName, | ||
"--tags", "alpha.eksctl.io/description=eksctl delete before active test", | ||
"--nodegroup-name", initNG, | ||
"--node-labels", "ng-name="+initNG, | ||
"--node-type", "t2.medium", | ||
"--nodes", "1", | ||
"--region", region, | ||
"--version", version, | ||
) | ||
}) | ||
}) | ||
|
||
Context("when deleting the (creating) cluster", func() { | ||
|
||
It("should not return an error", func() { | ||
|
||
eksctlSuccess("delete", "cluster", | ||
"--verbose", "4", | ||
"--name", clName, | ||
"--region", region, | ||
"--wait", | ||
) | ||
}) | ||
|
||
It("and should have deleted the EKS cluster and both CloudFormation stacks", func() { | ||
|
||
awsSession := aws.NewSession(region) | ||
|
||
Expect(awsSession).ToNot(HaveExistingCluster(clName, awseks.ClusterStatusActive, version)) | ||
|
||
Expect(awsSession).ToNot(HaveExistingStack(fmt.Sprintf("eksctl-%s-cluster", clName))) | ||
Expect(awsSession).ToNot(HaveExistingStack(fmt.Sprintf("eksctl-%s-nodegroup-ng-%d", clName, 0))) | ||
}) | ||
}) | ||
|
||
Context("when trying to delete the cluster again", func() { | ||
|
||
It("should return an a non-zero exit code", func() { | ||
|
||
eksctlFail("delete", "cluster", | ||
"--verbose", "4", | ||
"--name", clName, | ||
"--region", region, | ||
) | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters