Skip to content

Commit

Permalink
controllers,mysqlcluster: fix the backup Running bug#572 (radondb#574)
Browse files Browse the repository at this point in the history
  • Loading branch information
acekingke authored Jul 4, 2022
1 parent 1dee124 commit f3e7dcd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion controllers/backup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (r *BackupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr

// save the backup for later check for diff
savedBackup := backup.Unwrap().DeepCopy()

backup.ObjectMeta.Labels = labels.Set{"cluster": backup.Spec.ClusterName}
jobSyncer := backupSyncer.NewJobSyncer(r.Client, r.Scheme, backup)
if err := syncer.Sync(ctx, jobSyncer, r.Recorder); err != nil {
backup.UpdateStatusCondition(apiv1alpha1.BackupFailed, corev1.ConditionTrue, "CreateFailure", err.Error())
Expand Down
7 changes: 3 additions & 4 deletions mysqlcluster/syncer/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,18 +569,17 @@ func basicEventReason(objKindName string, err error) string {
// check the backup is exist and running
func (s *StatefulSetSyncer) backupIsRunning(ctx context.Context) (bool, error) {
backuplist := apiv1alpha1.BackupList{}
labelSet := labels.Set{"cluster": s.Name}
if err := s.cli.List(ctx,
&backuplist,
&client.ListOptions{
Namespace: s.sfs.Namespace,
Namespace: s.sfs.Namespace,
LabelSelector: labelSet.AsSelector(),
},
); err != nil {
return false, err
}
for _, bcp := range backuplist.Items {
if bcp.ClusterName != s.ClusterName {
continue
}
if !bcp.Status.Completed {
return true, nil
}
Expand Down

0 comments on commit f3e7dcd

Please sign in to comment.