resolve another rebase conflict
This commit is contained in:
parent
9de46e07e9
commit
3302881969
|
|
@ -1517,13 +1517,16 @@ func (c *Cluster) Switchover(curMaster *v1.Pod, candidate spec.NamespacedName) e
|
|||
c.logger.Debugf("switching over from %q to %q", curMaster.Name, candidate)
|
||||
c.eventRecorder.Eventf(c.GetReference(), v1.EventTypeNormal, "Switchover", "Switching over from %q to %q", curMaster.Name, candidate)
|
||||
stopCh := make(chan struct{})
|
||||
ch := c.registerPodSubscriber(candidate)
|
||||
subscriber := c.registerPodSubscriber(candidate)
|
||||
defer func() {
|
||||
subscriber.stopEvent <- struct{}{}
|
||||
}()
|
||||
defer close(stopCh)
|
||||
|
||||
if err = c.patroni.Switchover(curMaster, candidate.Name); err == nil {
|
||||
c.logger.Debugf("successfully switched over from %q to %q", curMaster.Name, candidate)
|
||||
c.eventRecorder.Eventf(c.GetReference(), v1.EventTypeNormal, "Switchover", "Successfully switched over from %q to %q", curMaster.Name, candidate)
|
||||
_, err = c.waitForPodLabel(ch, stopCh, nil)
|
||||
_, err = c.waitForPodLabel(subscriber.podEvents, stopCh, nil)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("could not get master pod label: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,6 +137,9 @@ func (c *Cluster) deletePods() error {
|
|||
func (c *Cluster) deletePod(podName spec.NamespacedName) error {
|
||||
c.setProcessName("deleting pod %q", podName)
|
||||
subscriber := c.registerPodSubscriber(podName)
|
||||
defer func() {
|
||||
subscriber.stopEvent <- struct{}{}
|
||||
}()
|
||||
|
||||
if err := c.KubeClient.Pods(podName.Namespace).Delete(context.TODO(), podName.Name, c.deleteOptions); err != nil {
|
||||
return err
|
||||
|
|
@ -405,6 +408,9 @@ func (c *Cluster) getPatroniMemberData(pod *v1.Pod) (patroni.MemberData, error)
|
|||
func (c *Cluster) recreatePod(podName spec.NamespacedName) (*v1.Pod, error) {
|
||||
stopCh := make(chan struct{})
|
||||
subscriber := c.registerPodSubscriber(podName)
|
||||
defer func() {
|
||||
subscriber.stopEvent <- struct{}{}
|
||||
}()
|
||||
defer close(stopCh)
|
||||
|
||||
err := retryutil.Retry(1*time.Second, 5*time.Second,
|
||||
|
|
@ -425,7 +431,7 @@ func (c *Cluster) recreatePod(podName spec.NamespacedName) (*v1.Pod, error) {
|
|||
if err := c.waitForPodDeletion(subscriber.podEvents); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pod, err := c.waitForPodLabel(subscriber, stopCh, nil)
|
||||
pod, err := c.waitForPodLabel(subscriber.podEvents, stopCh, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -316,20 +316,18 @@ func (c *Cluster) annotationsSet(annotations map[string]string) map[string]strin
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *Cluster) waitForPodLabel(subscriber PodSubscriber, stopCh chan struct{}, role *PostgresRole) (*v1.Pod, error) {
|
||||
func (c *Cluster) waitForPodLabel(podEvents chan PodEvent, stopCh chan struct{}, role *PostgresRole) (*v1.Pod, error) {
|
||||
timeout := time.After(c.OpConfig.PodLabelWaitTimeout)
|
||||
for {
|
||||
select {
|
||||
case podEvent := <-subscriber.podEvents:
|
||||
case podEvent := <-podEvents:
|
||||
podRole := PostgresRole(podEvent.CurPod.Labels[c.OpConfig.PodRoleLabel])
|
||||
|
||||
if role == nil {
|
||||
if podRole == Master || podRole == Replica {
|
||||
subscriber.stopEvent <- struct{}{}
|
||||
return podEvent.CurPod, nil
|
||||
}
|
||||
} else if *role == podRole {
|
||||
subscriber.stopEvent <- struct{}{}
|
||||
return podEvent.CurPod, nil
|
||||
}
|
||||
case <-timeout:
|
||||
|
|
|
|||
Loading…
Reference in New Issue