Merge pull request https://github.com/kubernetes/contrib/pull/913 from mwielgus/fix_zone_op

Cluster autoscaler: Fix zone for operation
This commit is contained in:
Marcin Wielgus 2016-05-06 13:46:45 +02:00
commit c998f90c49
2 changed files with 7 additions and 5 deletions

View File

@ -181,7 +181,7 @@ func main() {
glog.Errorf("Failed to get MIG size: %v", err) glog.Errorf("Failed to get MIG size: %v", err)
continue continue
} }
if err := gceManager.SetMigSize(bestOption.migConfig, currentSize+int64(estimate)); err == nil { if err := gceManager.SetMigSize(bestOption.migConfig, currentSize+int64(estimate)); err != nil {
glog.Errorf("Failed to set MIG size: %v", err) glog.Errorf("Failed to set MIG size: %v", err)
} }
} }

View File

@ -79,15 +79,17 @@ func (m *GceManager) SetMigSize(migConf *config.MigConfig, size int64) error {
if err != nil { if err != nil {
return err return err
} }
if err := m.waitForOp(op, migConf.Project); err != nil { if err := m.waitForOp(op, migConf.Project, migConf.Zone); err != nil {
return err return err
} }
return nil return nil
} }
func (m *GceManager) waitForOp(operation *gce.Operation, project string) error { func (m *GceManager) waitForOp(operation *gce.Operation, project string, zone string) error {
for start := time.Now(); time.Since(start) < operationWaitTimeout; time.Sleep(operationPollInterval) { for start := time.Now(); time.Since(start) < operationWaitTimeout; time.Sleep(operationPollInterval) {
if op, err := m.service.ZoneOperations.Get(project, operation.Zone, operation.Name).Do(); err == nil { glog.V(4).Infof("Waiting for operation %s %s %s", project, zone, operation.Name)
if op, err := m.service.ZoneOperations.Get(project, zone, operation.Name).Do(); err == nil {
glog.V(4).Infof("Operation %s %s %s status: %s", project, zone, operation.Name, op.Status)
if op.Status == "DONE" { if op.Status == "DONE" {
return nil return nil
} }
@ -128,7 +130,7 @@ func (m *GceManager) DeleteInstances(instances []*config.InstanceConfig) error {
if err != nil { if err != nil {
return err return err
} }
if err := m.waitForOp(op, commonMig.Project); err != nil { if err := m.waitForOp(op, commonMig.Project, commonMig.Zone); err != nil {
return err return err
} }
return nil return nil