Skip to content

Commit

Permalink
Merge pull request kubernetes#52480 from aleksandra-malinowska/test-f…
Browse files Browse the repository at this point in the history
…ix-gke-small

Automatic merge from submit-queue

Fix failing autoscaling test in GKE

This should fix `[sig-autoscaling] Cluster size autoscaling [Slow] should increase cluster size if pending pods are small and there is another node pool that is not autoscaled [Feature:ClusterSizeAutoscalingScaleUp]` by getting a list of nodes from GKE nodepool in a different way (filtering nodes by labels.) Currently, gcloud command used for it is failing, as we only have GKE node pool name in the test and not the actual MIG name.
  • Loading branch information
Kubernetes Submit Queue authored Sep 15, 2017
2 parents 5d995e3 + 158ffdb commit 471b0be
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions test/e2e/autoscaling/cluster_size_autoscaling.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,9 @@ var _ = SIGDescribe("Cluster size autoscaling [Slow]", func() {
glog.Infof("Not enabling cluster autoscaler for the node pool (on purpose).")

By("Get memory available on new node, so we can account for it when creating RC")
nodes, err := framework.GetGroupNodes(extraPoolName)
framework.ExpectNoError(err)
nodes := getPoolNodes(f, extraPoolName)
Expect(len(nodes)).Should(Equal(1))
node, err := f.ClientSet.Core().Nodes().Get(nodes[0], metav1.GetOptions{})
extraMem := node.Status.Capacity[v1.ResourceMemory]
extraMem := nodes[0].Status.Capacity[v1.ResourceMemory]
extraMemMb := int((&extraMem).Value() / 1024 / 1024)

ReserveMemory(f, "memory-reservation", 100, nodeCount*memCapacityMb+extraMemMb, false, defaultTimeout)
Expand Down Expand Up @@ -890,6 +888,17 @@ func deleteNodePool(name string) {
glog.Infof("Node-pool deletion output: %s", output)
}

func getPoolNodes(f *framework.Framework, poolName string) []*v1.Node {
nodes := make([]*v1.Node, 0, 1)
nodeList := framework.GetReadySchedulableNodesOrDie(f.ClientSet)
for _, node := range nodeList.Items {
if poolLabel := node.Labels["cloud.google.com/gke-nodepool"]; poolLabel == poolName {
nodes = append(nodes, &node)
}
}
return nodes
}

func doPut(url, content string) (string, error) {
req, err := http.NewRequest("PUT", url, bytes.NewBuffer([]byte(content)))
req.Header.Set("Content-Type", "application/json")
Expand Down

0 comments on commit 471b0be

Please sign in to comment.