Change isBackupRunning signature
@@ -166,10 +166,15 @@ func (r *ReconcilePerconaXtraDBCluster) smartUpdate(sfs api.StatefulApp, cr *api
log.Info("statefullSet was changed, run smart update")
- if err := r.isBackupRunning(cr); err != nil {
+ running, err := r.isBackupRunning(cr)
+ if err != nil {
log.Error(err, "can't start 'SmartUpdate'")
return nil
}
+ if running {
+ log.Info("can't start/continue 'SmartUpdate': backup is running")
+ return nil
+ }
if sfs.StatefulSet().Status.ReadyReplicas < sfs.StatefulSet().Status.Replicas {
log.Info("can't start/continue 'SmartUpdate': waiting for all replicas are ready")
@@ -421,22 +426,22 @@ func isPXC(sfs api.StatefulApp) bool {
return sfs.Labels()["app.kubernetes.io/component"] == "pxc"
}
-func (r *ReconcilePerconaXtraDBCluster) isBackupRunning(cr *api.PerconaXtraDBCluster) error {
+func (r *ReconcilePerconaXtraDBCluster) isBackupRunning(cr *api.PerconaXtraDBCluster) (bool, error) {
bcpList := api.PerconaXtraDBClusterBackupList{}
if err := r.client.List(context.TODO(), &bcpList, &client.ListOptions{Namespace: cr.Namespace}); err != nil {
if k8serrors.IsNotFound(err) {
- return nil
+ return false, nil
}
- return fmt.Errorf("failed to get backup object: %v", err)
+ return false, fmt.Errorf("failed to get backup object: %v", err)
}
for _, bcp := range bcpList.Items {
if bcp.Status.State == api.BackupRunning || bcp.Status.State == api.BackupStarting {
- return fmt.Errorf("backup %s is running", bcp.Name)
+ return true, nil
}
}
- return nil
+ return false, nil
}
func (r *ReconcilePerconaXtraDBCluster) getConfigHash(cr *api.PerconaXtraDBCluster, sfs api.StatefulApp) string {
