@@ -99,17 +99,17 @@ func (r *BackupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
9999 }
100100
101101 // Clear the backup, Just keep historyLimit len
102- if err = r .clearHistoryJob (ctx , req , * backup .Spec .HistoryLimit ); err != nil {
102+ if err = r .clearHistoryJob (ctx , req , * backup .Spec .HistoryLimit , backup . Spec . ClusterName ); err != nil {
103103 return reconcile.Result {}, err
104104 }
105105 return ctrl.Result {}, nil
106106}
107107
108108// Clear the History finished Jobs over HistoryLimit.
109- func (r * BackupReconciler ) clearHistoryJob (ctx context.Context , req ctrl.Request , historyLimit int32 ) error {
109+ func (r * BackupReconciler ) clearHistoryJob (ctx context.Context , req ctrl.Request , historyLimit int32 , clusterName string ) error {
110110 log := log .Log .WithName ("controllers" ).WithName ("Backup" )
111111 backupJobs := batchv1.JobList {}
112- labelSet := labels.Set {"Type" : utils .BackupJobTypeName }
112+ labelSet := labels.Set {"Type" : utils .BackupJobTypeName , "Cluster" : clusterName }
113113 if err := r .List (context .TODO (), & backupJobs , & client.ListOptions {
114114 Namespace : req .Namespace , LabelSelector : labelSet .AsSelector (),
115115 }); err != nil {
@@ -137,7 +137,7 @@ func (r *BackupReconciler) clearHistoryJob(ctx context.Context, req ctrl.Request
137137 // at first check backup status completed.
138138 backup := backup .New (& apiv1alpha1.Backup {})
139139 namespacedName := types.NamespacedName {
140- Name : strings .TrimSuffix (job .Name , "-backup " ),
140+ Name : strings .TrimSuffix (job .Name , "-bak " ),
141141 Namespace : job .Namespace ,
142142 }
143143 if err := r .Get (context .TODO (), namespacedName , backup .Unwrap ()); err != nil {
0 commit comments