diff --git a/pkg/controller/perconaservermongodbbackup/backup.go b/pkg/controller/perconaservermongodbbackup/backup.go index 5bf3ebf928..6f02f99a42 100644 --- a/pkg/controller/perconaservermongodbbackup/backup.go +++ b/pkg/controller/perconaservermongodbbackup/backup.go @@ -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) @@ -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 } diff --git a/pkg/controller/perconaservermongodbbackup/perconaservermongodbbackup_controller.go b/pkg/controller/perconaservermongodbbackup/perconaservermongodbbackup_controller.go index c5a92a3011..853aaf9865 100644 --- a/pkg/controller/perconaservermongodbbackup/perconaservermongodbbackup_controller.go +++ b/pkg/controller/perconaservermongodbbackup/perconaservermongodbbackup_controller.go @@ -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) {