Skip to content

Commit

Permalink
feat: backup support multi k8s cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
ldming committed Apr 25, 2024
1 parent 5b2c44d commit eca64ae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
9 changes: 5 additions & 4 deletions cmd/dataprotection/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,11 @@ func main() {
}

if err = (&dpcontrollers.BackupReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Recorder: mgr.GetEventRecorderFor("backup-controller"),
RestConfig: mgr.GetConfig(),
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Recorder: mgr.GetEventRecorderFor("backup-controller"),
RestConfig: mgr.GetConfig(),
MultiClusterMgr: multiClusterMgr,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "Backup")
os.Exit(1)
Expand Down
12 changes: 7 additions & 5 deletions controllers/dataprotection/backup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
dpv1alpha1 "github.com/apecloud/kubeblocks/apis/dataprotection/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/constant"
"github.com/apecloud/kubeblocks/pkg/controller/multicluster"
intctrlutil "github.com/apecloud/kubeblocks/pkg/controllerutil"
"github.com/apecloud/kubeblocks/pkg/dataprotection/action"
dpbackup "github.com/apecloud/kubeblocks/pkg/dataprotection/backup"
Expand All @@ -61,10 +62,11 @@ import (
// BackupReconciler reconciles a Backup object
type BackupReconciler struct {
client.Client
Scheme *k8sruntime.Scheme
Recorder record.EventRecorder
RestConfig *rest.Config
clock clock.RealClock
Scheme *k8sruntime.Scheme
Recorder record.EventRecorder
RestConfig *rest.Config
clock clock.RealClock
MultiClusterMgr multicluster.Manager
}

// +kubebuilder:rbac:groups=dataprotection.kubeblocks.io,resources=backups,verbs=get;list;watch;create;update;patch;delete
Expand Down Expand Up @@ -149,7 +151,7 @@ func (r *BackupReconciler) SetupWithManager(mgr ctrl.Manager) error {
return b.Complete(r)
}

func (r *BackupReconciler) filterBackupPods(ctx context.Context, obj client.Object) []reconcile.Request {
func (r *BackupReconciler) filterBackupPods(_ context.Context, obj client.Object) []reconcile.Request {
var requests []reconcile.Request
labels := obj.GetLabels()
if v, ok := labels[constant.AppManagedByLabelKey]; !ok || v != constant.AppName {
Expand Down

0 comments on commit eca64ae

Please sign in to comment.