Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
inelpandzic committed Apr 8, 2024
1 parent 86a0c12 commit 29d3d12
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 6 additions & 2 deletions pkg/controller/perconaservermongodbbackup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (b *Backup) Start(ctx context.Context, k8sclient client.Client, cluster *ap
}

// Status return backup status
func (b *Backup) Status(ctx context.Context, cr *api.PerconaServerMongoDBBackup, rsNames []string) (api.PerconaServerMongoDBBackupStatus, error) {
func (b *Backup) Status(ctx context.Context, cr *api.PerconaServerMongoDBBackup) (api.PerconaServerMongoDBBackupStatus, error) {
status := cr.Status

meta, err := b.pbm.GetBackupMeta(ctx, cr.Status.PBMname)
Expand Down Expand Up @@ -191,7 +191,11 @@ func (b *Backup) Status(ctx context.Context, cr *api.PerconaServerMongoDBBackup,
func backupPods(replsets []pbmBackup.BackupReplset) map[string]string {
pods := make(map[string]string)
for _, rs := range replsets {
pods[rs.Name] = strings.Split(rs.Node, ".")[0]
spl := strings.Split(rs.Node, ".")
if len(spl) == 0 {
continue
}
pods[rs.Name] = spl[0]
}
return pods
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,8 @@ func (r *ReconcilePerconaServerMongoDBBackup) reconcile(
return bcp.Start(ctx, r.client, cluster, cr)
}

rsNames := make([]string, 0, len(cluster.Spec.Replsets))
for _, rs := range cluster.Spec.Replsets {
rsNames = append(rsNames, rs.Name)
}

time.Sleep(5 * time.Second)
return bcp.Status(ctx, cr, rsNames)
return bcp.Status(ctx, cr)
}

func (r *ReconcilePerconaServerMongoDBBackup) getPBMStorage(ctx context.Context, cr *psmdbv1.PerconaServerMongoDBBackup) (storage.Storage, error) {
Expand Down

0 comments on commit 29d3d12

Please sign in to comment.