mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #53792 from aleksandra-malinowska/autoscaling-test-fix-12
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>. Use gcloud for enabling/disabling autoscaling in e2e tests This removes temporary solution added in #28011 as it's no longer necessary. Should reduce flakes caused by not waiting for master restart after disabling autoscaling.
This commit is contained in:
commit
c6b73933d6
@ -812,43 +812,21 @@ func isAutoscalerEnabled(expectedMaxNodeCountInTargetPool int) (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func enableAutoscaler(nodePool string, minCount, maxCount int) error {
|
func enableAutoscaler(nodePool string, minCount, maxCount int) error {
|
||||||
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)
|
|
||||||
|
|
||||||
output, err := execCmd("gcloud", "alpha", "container", "clusters", "update", framework.TestContext.CloudConfig.Cluster,
|
output, err := execCmd("gcloud", "container", "clusters", "update", framework.TestContext.CloudConfig.Cluster,
|
||||||
"--enable-autoscaling",
|
"--enable-autoscaling",
|
||||||
"--min-nodes="+strconv.Itoa(minCount),
|
"--min-nodes="+strconv.Itoa(minCount),
|
||||||
"--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).CombinedOutput()
|
"--zone="+framework.TestContext.CloudConfig.Zone).CombinedOutput()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Failed config update result: %s", output)
|
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)
|
|
||||||
} else {
|
|
||||||
glog.Infof("Using direct api access to enable autoscaling for pool %s", nodePool)
|
|
||||||
updateRequest := "{" +
|
|
||||||
" \"update\": {" +
|
|
||||||
" \"desiredNodePoolId\": \"" + nodePool + "\"," +
|
|
||||||
" \"desiredNodePoolAutoscaling\": {" +
|
|
||||||
" \"enabled\": \"true\"," +
|
|
||||||
" \"minNodeCount\": \"" + strconv.Itoa(minCount) + "\"," +
|
|
||||||
" \"maxNodeCount\": \"" + strconv.Itoa(maxCount) + "\"" +
|
|
||||||
" }" +
|
|
||||||
" }" +
|
|
||||||
"}"
|
|
||||||
|
|
||||||
url := getGKEClusterURL()
|
|
||||||
glog.Infof("Using gke api url %s", url)
|
|
||||||
putResult, err := doPut(url, updateRequest)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("Failed to put %s: %v", url, err)
|
|
||||||
}
|
|
||||||
glog.Infof("Config update result: %s", putResult)
|
|
||||||
}
|
}
|
||||||
|
glog.Infof("Config update result: %s", output)
|
||||||
|
|
||||||
var finalErr error
|
var finalErr error
|
||||||
for startTime := time.Now(); startTime.Add(gkeUpdateTimeout).After(time.Now()); time.Sleep(30 * time.Second) {
|
for startTime := time.Now(); startTime.Add(gkeUpdateTimeout).After(time.Now()); time.Sleep(30 * time.Second) {
|
||||||
@ -862,41 +840,19 @@ func enableAutoscaler(nodePool string, minCount, maxCount int) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func disableAutoscaler(nodePool string, minCount, maxCount int) error {
|
func disableAutoscaler(nodePool string, minCount, maxCount int) error {
|
||||||
|
glog.Infof("Using gcloud to disable autoscaling for pool %s", nodePool)
|
||||||
|
|
||||||
if nodePool == "default-pool" {
|
output, err := execCmd("gcloud", "container", "clusters", "update", framework.TestContext.CloudConfig.Cluster,
|
||||||
glog.Infof("Using gcloud to disable autoscaling for pool %s", nodePool)
|
"--no-enable-autoscaling",
|
||||||
|
"--node-pool="+nodePool,
|
||||||
|
"--project="+framework.TestContext.CloudConfig.ProjectID,
|
||||||
|
"--zone="+framework.TestContext.CloudConfig.Zone).CombinedOutput()
|
||||||
|
|
||||||
output, err := execCmd("gcloud", "alpha", "container", "clusters", "update", framework.TestContext.CloudConfig.Cluster,
|
if err != nil {
|
||||||
"--no-enable-autoscaling",
|
glog.Errorf("Failed config update result: %s", output)
|
||||||
"--node-pool="+nodePool,
|
return fmt.Errorf("Failed to disable autoscaling: %v", err)
|
||||||
"--project="+framework.TestContext.CloudConfig.ProjectID,
|
|
||||||
"--zone="+framework.TestContext.CloudConfig.Zone).CombinedOutput()
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
glog.Errorf("Failed config update result: %s", output)
|
|
||||||
return fmt.Errorf("Failed to disable autoscaling: %v", err)
|
|
||||||
}
|
|
||||||
glog.Infof("Config update result: %s", output)
|
|
||||||
|
|
||||||
} else {
|
|
||||||
glog.Infof("Using direct api access to disable autoscaling for pool %s", nodePool)
|
|
||||||
updateRequest := "{" +
|
|
||||||
" \"update\": {" +
|
|
||||||
" \"desiredNodePoolId\": \"" + nodePool + "\"," +
|
|
||||||
" \"desiredNodePoolAutoscaling\": {" +
|
|
||||||
" \"enabled\": \"false\"," +
|
|
||||||
" }" +
|
|
||||||
" }" +
|
|
||||||
"}"
|
|
||||||
|
|
||||||
url := getGKEClusterURL()
|
|
||||||
glog.Infof("Using gke api url %s", url)
|
|
||||||
putResult, err := doPut(url, updateRequest)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("Failed to put %s: %v", url, err)
|
|
||||||
}
|
|
||||||
glog.Infof("Config update result: %s", putResult)
|
|
||||||
}
|
}
|
||||||
|
glog.Infof("Config update result: %s", output)
|
||||||
|
|
||||||
var finalErr error
|
var finalErr error
|
||||||
for startTime := time.Now(); startTime.Add(gkeUpdateTimeout).After(time.Now()); time.Sleep(30 * time.Second) {
|
for startTime := time.Now(); startTime.Add(gkeUpdateTimeout).After(time.Now()); time.Sleep(30 * time.Second) {
|
||||||
|
Loading…
Reference in New Issue
Block a user