Retry on error in density

pull/6/head
Wojciech Tyczynski 2015-04-15 15:31:00 +02:00
parent 2823576194
commit 7eee9c5e95
1 changed files with 13 additions and 2 deletions

View File

@ -60,8 +60,19 @@ func DeleteRC(c *client.Client, ns, name string) error {
return fmt.Errorf("Failed to resize replication controller %s to zero: %v", name, err) return fmt.Errorf("Failed to resize replication controller %s to zero: %v", name, err)
} }
if err := wait.Poll(time.Second, time.Minute*20, client.ControllerHasDesiredReplicas(c, rc)); err != nil { // Wait up to 20 minutes until all replicas are killed.
return fmt.Errorf("Error waiting for replication controller %s replicas to reach 0: %v", name, err) endTime := time.Now().Add(time.Minute * 20)
for {
if time.Now().After(endTime) {
return fmt.Errorf("Timeout while waiting for replication controller %s replicas to 0", name)
}
remainingTime := endTime.Sub(time.Now())
err := wait.Poll(time.Second, remainingTime, client.ControllerHasDesiredReplicas(c, rc))
if err != nil {
glog.Errorf("Error while waiting for replication controller %s replicas to read 0: %v", name, err)
} else {
break
}
} }
// Delete the replication controller. // Delete the replication controller.