Fix pod wait timeouts.
Previously, a timer had been reset on every message received through the pod channel.
This commit is contained in:
parent
83c8d6c419
commit
793defef72
|
|
@ -184,6 +184,7 @@ func (c *Cluster) getTeamMembers() ([]string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cluster) waitForPodLabel(podEvents chan spec.PodEvent, role *PostgresRole) error {
|
func (c *Cluster) waitForPodLabel(podEvents chan spec.PodEvent, role *PostgresRole) error {
|
||||||
|
timeout := time.After(c.OpConfig.PodLabelWaitTimeout)
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case podEvent := <-podEvents:
|
case podEvent := <-podEvents:
|
||||||
|
|
@ -196,20 +197,21 @@ func (c *Cluster) waitForPodLabel(podEvents chan spec.PodEvent, role *PostgresRo
|
||||||
} else if *role == podRole {
|
} else if *role == podRole {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
case <-time.After(c.OpConfig.PodLabelWaitTimeout):
|
case <-timeout:
|
||||||
return fmt.Errorf("pod label wait timeout")
|
return fmt.Errorf("pod label wait timeout")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cluster) waitForPodDeletion(podEvents chan spec.PodEvent) error {
|
func (c *Cluster) waitForPodDeletion(podEvents chan spec.PodEvent) error {
|
||||||
|
timeout := time.After(c.OpConfig.PodDeletionWaitTimeout)
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case podEvent := <-podEvents:
|
case podEvent := <-podEvents:
|
||||||
if podEvent.EventType == spec.EventDelete {
|
if podEvent.EventType == spec.EventDelete {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
case <-time.After(c.OpConfig.PodDeletionWaitTimeout):
|
case <-timeout:
|
||||||
return fmt.Errorf("pod deletion wait timeout")
|
return fmt.Errorf("pod deletion wait timeout")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue