prooper new replica pod info message
@@ -185,14 +185,11 @@ func (r *ReconcilePerconaXtraDBCluster) reconcileReplication(cr *api.PerconaXtra
}
// if primary pod is not a replica, we need to make it as replica, and stop replication on other pods
- _, ok := primaryPod.Labels[replicationPodLabel]
- if !ok {
for _, pod := range podList {
if pod.Name == primaryPod.Name {
continue
}
if _, ok := pod.Labels[replicationPodLabel]; ok {
- r.logger(cr.Name, cr.Namespace).Info("Replication pod has changed", "new replication pod", pod.Name)
db, err := queries.New(r.client, cr.Namespace, internalPrefix+cr.Name, user, pod.Name+"."+cr.Name+"-pxc."+cr.Namespace, port)
if err != nil {
return errors.Wrapf(err, "failed to connect to pod %s", pod.Name)
@@ -209,11 +206,14 @@ func (r *ReconcilePerconaXtraDBCluster) reconcileReplication(cr *api.PerconaXtra
}
}
}
+
+ if _, ok := primaryPod.Labels[replicationPodLabel]; !ok {
primaryPod.Labels[replicationPodLabel] = "true"
err = r.client.Update(context.TODO(), primaryPod)
if err != nil {
return errors.Wrap(err, "add label to main replica pod")
}
+ r.logger(cr.Name, cr.Namespace).Info("Replication pod has changed", "new replication pod", primaryPod.Name)
}
sysUsersSecretObj := corev1.Secret{}
