Fix pod wait timeouts.

Previously, a timer had been reset on every message received through
the pod channel.
This commit is contained in:
Oleksii Kliukin 2017-10-11 14:52:47 +02:00
parent 83c8d6c419
commit 793defef72
1 changed files with 4 additions and 2 deletions

View File

@ -184,6 +184,7 @@ func (c *Cluster) getTeamMembers() ([]string, error) {
}
func (c *Cluster) waitForPodLabel(podEvents chan spec.PodEvent, role *PostgresRole) error {
timeout := time.After(c.OpConfig.PodLabelWaitTimeout)
for {
select {
case podEvent := <-podEvents:
@ -196,20 +197,21 @@ func (c *Cluster) waitForPodLabel(podEvents chan spec.PodEvent, role *PostgresRo
} else if *role == podRole {
return nil
}
case <-time.After(c.OpConfig.PodLabelWaitTimeout):
case <-timeout:
return fmt.Errorf("pod label wait timeout")
}
}
}
func (c *Cluster) waitForPodDeletion(podEvents chan spec.PodEvent) error {
timeout := time.After(c.OpConfig.PodDeletionWaitTimeout)
for {
select {
case podEvent := <-podEvents:
if podEvent.EventType == spec.EventDelete {
return nil
}
case <-time.After(c.OpConfig.PodDeletionWaitTimeout):
case <-timeout:
return fmt.Errorf("pod deletion wait timeout")
}
}