mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-19 02:48:39 +02:00
Fix pod wait timeouts.
Previously, a timer had been reset on every message received through the pod channel.
This commit is contained in:
+4
-2
@@ -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")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user