Merge pull request #53206 from aleksandra-malinowska/autoscaling-test-fix-9
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>. In cluster autoscaling tests, improve error logging on enable autoscaling failure This adds logging command and request output in addition to error.
This commit is contained in:
commit
e51752239c
@ -153,7 +153,7 @@ var _ = SIGDescribe("Cluster size autoscaling [Slow]", func() {
|
|||||||
defer framework.DeleteRCAndPods(f.ClientSet, f.InternalClientset, f.Namespace.Name, "memory-reservation")
|
defer framework.DeleteRCAndPods(f.ClientSet, f.InternalClientset, f.Namespace.Name, "memory-reservation")
|
||||||
|
|
||||||
By("Waiting for scale up hoping it won't happen")
|
By("Waiting for scale up hoping it won't happen")
|
||||||
// Verfiy, that the appropreate event was generated.
|
// Verify that the appropriate event was generated
|
||||||
eventFound := false
|
eventFound := false
|
||||||
EventsLoop:
|
EventsLoop:
|
||||||
for start := time.Now(); time.Since(start) < scaleUpTimeout; time.Sleep(20 * time.Second) {
|
for start := time.Now(); time.Since(start) < scaleUpTimeout; time.Sleep(20 * time.Second) {
|
||||||
@ -793,7 +793,6 @@ func isAutoscalerEnabled(expectedMinNodeCountInTargetPool int) (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func enableAutoscaler(nodePool string, minCount, maxCount int) error {
|
func enableAutoscaler(nodePool string, minCount, maxCount int) error {
|
||||||
|
|
||||||
if nodePool == "default-pool" {
|
if nodePool == "default-pool" {
|
||||||
glog.Infof("Using gcloud to enable autoscaling for pool %s", nodePool)
|
glog.Infof("Using gcloud to enable autoscaling for pool %s", nodePool)
|
||||||
|
|
||||||
@ -803,13 +802,13 @@ func enableAutoscaler(nodePool string, minCount, maxCount int) error {
|
|||||||
"--max-nodes="+strconv.Itoa(maxCount),
|
"--max-nodes="+strconv.Itoa(maxCount),
|
||||||
"--node-pool="+nodePool,
|
"--node-pool="+nodePool,
|
||||||
"--project="+framework.TestContext.CloudConfig.ProjectID,
|
"--project="+framework.TestContext.CloudConfig.ProjectID,
|
||||||
"--zone="+framework.TestContext.CloudConfig.Zone).Output()
|
"--zone="+framework.TestContext.CloudConfig.Zone).CombinedOutput()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
glog.Errorf("Failed config update result: %s", output)
|
||||||
return fmt.Errorf("Failed to enable autoscaling: %v", err)
|
return fmt.Errorf("Failed to enable autoscaling: %v", err)
|
||||||
}
|
}
|
||||||
glog.Infof("Config update result: %s", output)
|
glog.Infof("Config update result: %s", output)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
glog.Infof("Using direct api access to enable autoscaling for pool %s", nodePool)
|
glog.Infof("Using direct api access to enable autoscaling for pool %s", nodePool)
|
||||||
updateRequest := "{" +
|
updateRequest := "{" +
|
||||||
@ -852,10 +851,11 @@ func disableAutoscaler(nodePool string, minCount, maxCount int) error {
|
|||||||
"--no-enable-autoscaling",
|
"--no-enable-autoscaling",
|
||||||
"--node-pool="+nodePool,
|
"--node-pool="+nodePool,
|
||||||
"--project="+framework.TestContext.CloudConfig.ProjectID,
|
"--project="+framework.TestContext.CloudConfig.ProjectID,
|
||||||
"--zone="+framework.TestContext.CloudConfig.Zone).Output()
|
"--zone="+framework.TestContext.CloudConfig.Zone).CombinedOutput()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Failed to enable autoscaling: %v", err)
|
glog.Errorf("Failed config update result: %s", output)
|
||||||
|
return fmt.Errorf("Failed to disable autoscaling: %v", err)
|
||||||
}
|
}
|
||||||
glog.Infof("Config update result: %s", output)
|
glog.Infof("Config update result: %s", output)
|
||||||
|
|
||||||
@ -923,6 +923,9 @@ func getPoolNodes(f *framework.Framework, poolName string) []*v1.Node {
|
|||||||
|
|
||||||
func doPut(url, content string) (string, error) {
|
func doPut(url, content string) (string, error) {
|
||||||
req, err := http.NewRequest("PUT", url, bytes.NewBuffer([]byte(content)))
|
req, err := http.NewRequest("PUT", url, bytes.NewBuffer([]byte(content)))
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
req.Header.Set("Content-Type", "application/json")
|
req.Header.Set("Content-Type", "application/json")
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
|
Loading…
Reference in New Issue
Block a user