anchor.diff:                                    %% Only start one bucket at a time to avoid
                                     %% overloading things
                                     ThisEjected = ordsets:intersection(lists:sort(proplists:get_value(servers, BucketConfig, [])),
  -                                                                     lists:sort(EjectNodesAll)),
  +                                                                     lists:sort(EjectNodes)),
                                     ThisLiveNodes = KeepKVNodes ++ ThisEjected,
                                     ns_bucket:set_servers(BucketName, ThisLiveNodes),
                                     execute_and_be_stop_aware(
  
positive.code:                        ns_cluster_membership:activate(KeepNodes),
  
                         rebalance(KeepNodes, EjectNodes, FailedNodes,
                                   BucketConfigs, DeltaRecoveryBucketTuples)
                 end
         end, []]).
  
  
negative.code:           BucketConfigs, DeltaRecoveryBuckets) ->
      do_pre_rebalance_config_sync(KeepNodes),
  
      ok = activate_services(KeepNodes),
      StartTS = os:timestamp(),
  
      %% Eject failed nodes first so they don't cause trouble
      FailedNodes = FailedNodesAll -- [node()],
      eject_nodes(FailedNodes),
  
      rebalance_kv(KeepNodes, EjectNodesAll, BucketConfigs, DeltaRecoveryBuckets),
  
      ns_config:sync_announcements(),
      ns_config_rep:push(),
      ok = ns_config_rep:synchronize_remote(KeepNodes),
  
      %% don't eject ourselves at all here; this will be handled by ns_orchestrator
      EjectNodes = EjectNodesAll -- [node()],
  
      maybe_delay_eject_nodes(StartTS, EjectNodesAll),
      eject_nodes(EjectNodes).
  
  rebalance_kv(KeepNodes, EjectNodes, BucketConfigs, DeltaRecoveryBuckets) ->
      %% wait when all bucket shutdowns are done on nodes we're
      %% adding (or maybe adding)
      do_wait_buckets_shutdown(KeepNodes),
  
      NumBuckets = length(BucketConfigs),
      ?rebalance_debug("BucketConfigs = ~p", [sanitize(BucketConfigs)]),
  
      KeepKVNodes = ns_cluster_membership:service_nodes(KeepNodes, kv),
      LiveKVNodes = ns_cluster_membership:service_nodes(KeepNodes ++ EjectNodes, kv),
  
      case maybe_cleanup_old_buckets(KeepNodes) of
          ok ->
  