Merge pull request #52480 from aleksandra-malinowska/test-fix-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.
This commit is contained in:
Kubernetes Submit Queue 2017-09-14 18:48:26 -07:00 committed by GitHub
commit 471b0beb2e

View File

@ -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)
@ -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")