Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pooknull committed Sep 6, 2023
1 parent 6555465 commit cc87917
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/controller/perconaservermongodb/balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ func (r *ReconcilePerconaServerMongoDB) enableBalancerIfNeeded(ctx context.Conte
return nil
}

func (r *ReconcilePerconaServerMongoDB) disableBalancerIfNeeded(ctx context.Context, cr *api.PerconaServerMongoDB) error {
if s := cr.Spec.Sharding; !s.Enabled || s.Mongos.Size == 0 || cr.Spec.Unmanaged || s.Balancer.Enabled == nil || *s.Balancer.Enabled {
return nil
}
return r.disableBalancer(ctx, cr)
}

func (r *ReconcilePerconaServerMongoDB) disableBalancer(ctx context.Context, cr *api.PerconaServerMongoDB) error {
log := logf.FromContext(ctx)

Expand Down
4 changes: 4 additions & 0 deletions pkg/controller/perconaservermongodb/psmdb_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,10 @@ func (r *ReconcilePerconaServerMongoDB) Reconcile(ctx context.Context, request r
return reconcile.Result{}, errors.Wrap(err, "failed to start balancer")
}

if err := r.disableBalancerIfNeeded(ctx, cr); err != nil {
return reconcile.Result{}, errors.Wrap(err, "failed to disable balancer")
}

if err := r.upgradeFCVIfNeeded(ctx, cr, *repls[0], cr.Status.MongoVersion); err != nil {
return reconcile.Result{}, errors.Wrap(err, "failed to set FCV")
}
Expand Down

0 comments on commit cc87917

Please sign in to comment.