Merge pull request #60132 from bskiba/fix-e2e-ca

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Make sure node pool is deleted in autoscaler e2e tests.

Currently, if node pool creation succeeds, but we fail to get initial pool size, the node pool does not get deleted.

**Release note**:
```
NONE
```
This commit is contained in:
Kubernetes Submit Queue 2018-02-21 05:21:54 -08:00 committed by GitHub
commit 7a50f4a12f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -248,8 +248,9 @@ var _ = SIGDescribe("Cluster size autoscaling [Slow]", func() {
By("Creating new node-pool with n1-standard-4 machines")
const extraPoolName = "extra-pool"
extraNodes := addNodePool(extraPoolName, "n1-standard-4", 1)
addNodePool(extraPoolName, "n1-standard-4", 1)
defer deleteNodePool(extraPoolName)
extraNodes := getPoolInitialSize(extraPoolName)
framework.ExpectNoError(framework.WaitForReadyNodes(c, nodeCount+extraNodes, resizeTimeout))
glog.Infof("Not enabling cluster autoscaler for the node pool (on purpose).")
@ -278,8 +279,9 @@ var _ = SIGDescribe("Cluster size autoscaling [Slow]", func() {
By("Creating new node-pool with n1-standard-4 machines")
const extraPoolName = "extra-pool"
extraNodes := addNodePool(extraPoolName, "n1-standard-4", 1)
addNodePool(extraPoolName, "n1-standard-4", 1)
defer deleteNodePool(extraPoolName)
extraNodes := getPoolInitialSize(extraPoolName)
framework.ExpectNoError(framework.WaitForReadyNodes(c, nodeCount+extraNodes, resizeTimeout))
framework.ExpectNoError(enableAutoscaler(extraPoolName, 1, 2))
framework.ExpectNoError(disableAutoscaler(extraPoolName, 1, 2))
@ -512,8 +514,9 @@ var _ = SIGDescribe("Cluster size autoscaling [Slow]", func() {
By("Creating new node-pool with n1-standard-4 machines")
const extraPoolName = "extra-pool"
extraNodes := addNodePool(extraPoolName, "n1-standard-4", 1)
addNodePool(extraPoolName, "n1-standard-4", 1)
defer deleteNodePool(extraPoolName)
extraNodes := getPoolInitialSize(extraPoolName)
framework.ExpectNoError(framework.WaitForReadyNodes(c, nodeCount+extraNodes, resizeTimeout))
framework.ExpectNoError(enableAutoscaler(extraPoolName, 1, 2))
defer disableAutoscaler(extraPoolName, 1, 2)
@ -566,8 +569,9 @@ var _ = SIGDescribe("Cluster size autoscaling [Slow]", func() {
increasedSize := manuallyIncreaseClusterSize(f, originalSizes)
const extraPoolName = "extra-pool"
extraNodes := addNodePool(extraPoolName, "n1-standard-1", 3)
addNodePool(extraPoolName, "n1-standard-1", 3)
defer deleteNodePool(extraPoolName)
extraNodes := getPoolInitialSize(extraPoolName)
framework.ExpectNoError(WaitForClusterSizeFunc(f.ClientSet,
func(size int) bool { return size >= increasedSize+extraNodes }, scaleUpTimeout))
@ -681,8 +685,9 @@ var _ = SIGDescribe("Cluster size autoscaling [Slow]", func() {
// GKE-specific setup
By("Add a new node pool with size 1 and min size 0")
const extraPoolName = "extra-pool"
extraNodes := addNodePool(extraPoolName, "n1-standard-4", 1)
addNodePool(extraPoolName, "n1-standard-4", 1)
defer deleteNodePool(extraPoolName)
extraNodes := getPoolInitialSize(extraPoolName)
framework.ExpectNoError(framework.WaitForReadyNodes(c, nodeCount+extraNodes, resizeTimeout))
framework.ExpectNoError(enableAutoscaler(extraPoolName, 0, 1))
defer disableAutoscaler(extraPoolName, 0, 1)
@ -1286,15 +1291,14 @@ func waitTillAllNAPNodePoolsAreRemoved() error {
}
// Returns size of the newly added node pool
func addNodePool(name string, machineType string, numNodes int) int {
func addNodePool(name string, machineType string, numNodes int) {
args := []string{"container", "node-pools", "create", name, "--quiet",
"--machine-type=" + machineType,
"--num-nodes=" + strconv.Itoa(numNodes),
"--cluster=" + framework.TestContext.CloudConfig.Cluster}
output, err := execCmd(getGcloudCommand(args)...).CombinedOutput()
glog.Infof("Creating node-pool %s: %s", name, output)
framework.ExpectNoError(err)
return getPoolInitialSize(name)
framework.ExpectNoError(err, output)
}
func deleteNodePool(name string) {