Force the minion to leave the swarm

    force
        Will force the minion/worker/manager to leave the swarm

    CLI Example:

    .. code-block:: bash

        salt '*' swarm.leave_swarm force=False
550710
def leave_swarm(force=bool):
    '''
    
    '''
    salt_return = {}
    __context__['client'].swarm.leave(force=force)
    output = __context__['server_name'] + ' has left the swarm'
    salt_return.update({'Comment': output})
    return salt_return
391269
def _broker_exit(self):
        
        for _, (side, _) in self.poller.readers + self.poller.writers:
            LOG.debug('_broker_main() force disconnecting %r', side)
            side.stream.on_disconnect(self)

        self.poller.close()
565283
def close(self):
        
        self.closed = True
        signal = _allocate_lock()
        signal.acquire()
        self.queue.add(CommandItem(COMMIT, None, signal, None, None))
        signal.acquire()
        self.worker.please_stop.go()
        return
262028
def delete_group(self, group_id, force=False):
        
        params = {'force': force}
        response = self._do_request(
            'DELETE', '/v2/groups/{group_id}'.format(group_id=group_id), params=params)
        return response.json()
1179555
def run(self):
        '''
        
        '''
        args = [[],
                self.opts['fun'],
                self.opts['arg'],
                self.opts['timeout'],
                'list',
                ]
        bnum = self.get_bnum()
        # No targets to run
        if not self.minions:
            return
        to_run = copy.deepcopy(self.minions)
        active = []
        ret = {}
        iters = []
        # wait the specified time before decide a job is actually done
        bwait = self.opts.get('batch_wait', 0)
        wait = []

        if self.options:
            show_jid = self.options.show_jid
            show_verbose = self.options.verbose
        else:
            show_jid = False
            show_verbose = False

        # the minion tracker keeps track of responses and iterators
        # - it removes finished iterators from iters[]
        # - if a previously detected minion does not respond, its
        #   added with an empty answer to ret{} once the timeout is reached
        # - unresponsive minions are removed from active[] to make
        #   sure that the main while loop finishes even with unresp minions
        minion_tracker = {}

        if not self.quiet:
            # We already know some minions didn't respond to the ping, so inform
            # the user we won't be attempting to run a job on them
            for down_minion in self.down_minions:
                salt.utils.stringutils.print_cli('Minion {0} did not respond. No job will be sent.'.format(down_minion))

        # Iterate while we still have things to execute
        while len(ret) < len(self.minions):
            next_ = []
            if bwait and wait:
                self.__update_wait(wait)
            if len(to_run) <= bnum - len(wait) and not active:
                # last bit of them, add them all to next iterator
                while to_run:
                    next_.append(to_run.pop())
            else:
                for i in range(bnum - len(active) - len(wait)):
                    if to_run:
                        minion_id = to_run.pop()
                        if isinstance(minion_id, dict):
                            next_.append(minion_id.keys()[0])
                        else:
                            next_.append(minion_id)

            active += next_
            args[0] = next_

            if next_:
                if not self.quiet:
                    salt.utils.stringutils.print_cli('\nExecuting run on {0}\n'.format(sorted(next_)))
                # create a new iterator for this batch of minions
                new_iter = self.local.cmd_iter_no_block(
                                *args,
                                raw=self.opts.get('raw', False),
                                ret=self.opts.get('return', ''),
                                show_jid=show_jid,
                                verbose=show_verbose,
                                gather_job_timeout=self.opts['gather_job_timeout'],
                                **self.eauth)
                # add it to our iterators and to the minion_tracker
                iters.append(new_iter)
                minion_tracker[new_iter] = {}
                # every iterator added is 'active' and has its set of minions
                minion_tracker[new_iter]['minions'] = next_
                minion_tracker[new_iter]['active'] = True

            else:
                time.sleep(0.02)
            parts = {}

            # see if we found more minions
            for ping_ret in self.ping_gen:
                if ping_ret is None:
                    break
                m = next(six.iterkeys(ping_ret))
                if m not in self.minions:
                    self.minions.append(m)
                    to_run.append(m)

            for queue in iters:
                try:
                    # Gather returns until we get to the bottom
                    ncnt = 0
                    while True:
                        part = next(queue)
                        if part is None:
                            time.sleep(0.01)
                            ncnt += 1
                            if ncnt > 5:
                                break
                            continue
                        if self.opts.get('raw'):
                            parts.update({part['data']['id']: part})
                            if part['data']['id'] in minion_tracker[queue]['minions']:
                                minion_tracker[queue]['minions'].remove(part['data']['id'])
                            else:
                                salt.utils.stringutils.print_cli('minion {0} was already deleted from tracker, probably a duplicate key'.format(part['id']))
                        else:
                            parts.update(part)
                            for id in part:
                                if id in minion_tracker[queue]['minions']:
                                    minion_tracker[queue]['minions'].remove(id)
                                else:
                                    salt.utils.stringutils.print_cli('minion {0} was already deleted from tracker, probably a duplicate key'.format(id))
                except StopIteration:
                    # if a iterator is done:
                    # - set it to inactive
                    # - add minions that have not responded to parts{}

                    # check if the tracker contains the iterator
                    if queue in minion_tracker:
                        minion_tracker[queue]['active'] = False

                        # add all minions that belong to this iterator and
                        # that have not responded to parts{} with an empty response
                        for minion in minion_tracker[queue]['minions']:
                            if minion not in parts:
                                parts[minion] = {}
                                parts[minion]['ret'] = {}

            for minion, data in six.iteritems(parts):
                if minion in active:
                    active.remove(minion)
                    if bwait:
                        wait.append(datetime.now() + timedelta(seconds=bwait))
                # Munge retcode into return data
                failhard = False
                if 'retcode' in data and isinstance(data['ret'], dict) and 'retcode' not in data['ret']:
                    data['ret']['retcode'] = data['retcode']
                    if self.opts.get('failhard') and data['ret']['retcode'] > 0:
                        failhard = True

                if self.opts.get('raw'):
                    ret[minion] = data
                    yield data
                else:
                    ret[minion] = data['ret']
                    yield {minion: data['ret']}
                if not self.quiet:
                    ret[minion] = data['ret']
                    data[minion] = data.pop('ret')
                    if 'out' in data:
                        out = data.pop('out')
                    else:
                        out = None
                    salt.output.display_output(
                            data,
                            out,
                            self.opts)
                if failhard:
                    log.error(
                        'Minion %s returned with non-zero exit code. '
                        'Batch run stopped due to failhard', minion
                    )
                    raise StopIteration

            # remove inactive iterators from the iters list
            for queue in minion_tracker:
                # only remove inactive queues
                if not minion_tracker[queue]['active'] and queue in iters:
                    iters.remove(queue)
                    # also remove the iterator's minions from the active list
                    for minion in minion_tracker[queue]['minions']:
                        if minion in active:
                            active.remove(minion)
                            if bwait:
                                wait.append(datetime.now() + timedelta(seconds=bwait))
1098582
def delete!(force = false)
      if local?
        @lib.branch(@name, :force => force, :delete => true)
      else
        @lib.push(Process.server_name, nil, nil, :delete => @name)
      end
    end
804594
def request_stop(self, message='', exit_code=0):
        
        # Only a master arbiter can stop the daemons
        if self.is_master:
            # Stop the daemons
            self.daemons_stop(timeout=self.conf.daemons_stop_timeout)

        # Request the daemon stop
        super(Arbiter, self).request_stop(message, exit_code)
1248594
private void leave(CompletableFuture<Void> future) {
    // Set a timer to retry the attempt to leave the cluster.
    leaveTimeout = raft.getThreadContext().schedule(raft.getElectionTimeout(), () -> {
      leave(future);
    });

    // Attempt to leave the cluster by submitting a LeaveRequest directly to the server state.
    // Non-leader states should forward the request to the leader if there is one. Leader states
    // will log, replicate, and commit the reconfiguration.
    raft.getRaftRole().onLeave(LeaveRequest.builder()
        .withMember(getMember())
        .build()).whenComplete((response, error) -> {
          // Cancel the leave timer.
          cancelLeaveTimer();

          if (error == null && response.status() == RaftResponse.Status.OK) {
            Configuration configuration = new Configuration(response.index(), response.term(), response.timestamp(), response.members());

            // Configure the cluster and commit the configuration as we know the successful response
            // indicates commitment.
            configure(configuration).commit();
            future.complete(null);
          } else {
            // Reset the leave timer.
            leaveTimeout = raft.getThreadContext().schedule(raft.getElectionTimeout(), () -> {
              leave(future);
            });
          }
        });
  }
555037
def destroy(force=false)
      unless exists?
        raise ContainerError, "Container does not exist."
      end

      if running?
        if force == true
          stop
        else
          raise ContainerError, "Container is running. Stop it first or use force=true"
        end  
      end

      run("destroy")

      !exists?
    end
1072287
def cleanup(self, force=False, delete=False):
        
        # TODO: this method could be part of API, like:
        try:
            self.stop()
        except subprocess.CalledProcessError as stop:
            logger.debug("unable to stop container via stop", stop)
            if not force:
                raise stop
            try:
                self.kill()
            except subprocess.CalledProcessError as kill:
                logger.debug("unable to stop container via kill", kill)
                pass
        if delete:
            self.delete(force=force)
705677
def kill(self, exit_code: Any = None):
        
        self._force_kill.set()
        if exit_code is not None:
            self._exit_code = exit_code
        logger.info("Killing behavior {0} with exit code: {1}".format(self, exit_code))
1130286
def force_delete(self):
        
        self._force_deleting = True

        self.delete()

        self._force_deleting = False
1318552
def project_leave(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/leave' % object_id, input_params, always_retry=always_retry, **kwargs)
1209387
def logout(self):
        """"""
        logger.debug('Logout')
        method = self._anaconda_client_api.remove_authentication
        return self._create_worker(method)
679267
def do_exit(self, arg):
        """"""

        if self.current:
            self.current.close()
        self.resource_manager.close()
        del self.resource_manager
        return True
1233818
private boolean forceQuitActiveAction(final Long actionId) {
        if (actionId != null) {
            try {
                deploymentManagement.forceQuitAction(actionId);
                return true;
            } catch (final CancelActionNotAllowedException e) {
                LOG.info("Force Cancel action not allowed exception :{}", e);
                return false;
            }
        }
        return false;
    }
310098
def destroy(self):
        

        # if this unit didn't come from fleet, we can't destroy it
        if not self._is_live():
            raise RuntimeError('A unit must be submitted to fleet before it can destroyed.')

        return self._client.destroy_unit(self.name)