func (n *Node) Deregister(args *structs.NodeDeregisterRequest, reply *structs.NodeUpdateResponse) error {
	if done, err := n.srv.forward("Node.Deregister", args, args, reply); done {
		return err
	}
	defer metrics.MeasureSince([]string{"nomad", "client", "deregister"}, time.Now())

	// Verify the arguments
	if args.NodeID == "" {
		return fmt.Errorf("missing node ID for client deregistration")
	}

	// Commit this update via Raft
	_, index, err := n.srv.raftApply(structs.NodeDeregisterRequestType, args)
	if err != nil {
		n.srv.logger.Printf("[ERR] nomad.client: Deregister failed: %v", err)
		return err
	}

	// Clear the heartbeat timer if any
	n.srv.clearHeartbeatTimer(args.NodeID)

	// Create the evaluations for this node
	evalIDs, evalIndex, err := n.createNodeEvals(args.NodeID, index)
	if err != nil {
		n.srv.logger.Printf("[ERR] nomad.client: eval creation failed: %v", err)
		return err
	}

	// Determine if there are any Vault accessors on the node
	ws := memdb.NewWatchSet()
	accessors, err := n.srv.State().VaultAccessorsByNode(ws, args.NodeID)
	if err != nil {
		n.srv.logger.Printf("[ERR] nomad.client: looking up accessors for node %q failed: %v", args.NodeID, err)
		return err
	}

	if l := len(accessors); l != 0 {
		n.srv.logger.Printf("[DEBUG] nomad.client: revoking %d accessors on node %q due to deregister", l, args.NodeID)
		if err := n.srv.vault.RevokeTokens(context.Background(), accessors, true); err != nil {
			n.srv.logger.Printf("[ERR] nomad.client: revoking accessors for node %q failed: %v", args.NodeID, err)
			return err
		}
	}

	// Setup the reply
	reply.EvalIDs = evalIDs
	reply.EvalCreateIndex = evalIndex
	reply.NodeModifyIndex = index
	reply.Index = index
	return nil
}
// Deregister is used to remove a client from the cluster. If a client should
// just be made unavailable for scheduling, a status update is preferred.
Deregister is used to remove a client from the cluster. If a client should
just be made unavailable for scheduling, a status update is preferred.
// Deregister is used to remove a client from the cluster . If a client should // just be made unavailable for scheduling a status update is preferred .
func (n *Node) Deregister(args *structs.NodeDeregisterRequest, reply *structs.NodeUpdateResponse) error {
	if done, err := n.srv.forward("Node.Deregister", args, args, reply); done {
		return err
	}
	defer metrics.MeasureSince([]string{"nomad", "client", "deregister"}, time.Now())
	if args.NodeID == "" {
		return fmt.Errorf("missing node ID for client deregistration")
	}
	_, index, err := n.srv.raftApply(structs.NodeDeregisterRequestType, args)
	if err != nil {
		n.srv.logger.Printf("[ERR] nomad.client: Deregister failed: %v", err)
		return err
	}
	n.srv.clearHeartbeatTimer(args.NodeID)
	evalIDs, evalIndex, err := n.createNodeEvals(args.NodeID, index)
	if err != nil {
		n.srv.logger.Printf("[ERR] nomad.client: eval creation failed: %v", err)
		return err
	}
	ws := memdb.NewWatchSet()
	accessors, err := n.srv.State().VaultAccessorsByNode(ws, args.NodeID)
	if err != nil {
		n.srv.logger.Printf("[ERR] nomad.client: looking up accessors for node %q failed: %v", args.NodeID, err)
		return err
	}
	if l := len(accessors); l != 0 {
		n.srv.logger.Printf("[DEBUG] nomad.client: revoking %d accessors on node %q due to deregister", l, args.NodeID)
		if err := n.srv.vault.RevokeTokens(context.Background(), accessors, true); err != nil {
			n.srv.logger.Printf("[ERR] nomad.client: revoking accessors for node %q failed: %v", args.NodeID, err)
			return err
		}
	}
	reply.EvalIDs = evalIDs
	reply.EvalCreateIndex = evalIndex
	reply.NodeModifyIndex = index
	reply.Index = index
	return nil
}
func ( n * Node ) Deregister ( args * structs . NodeDeregisterRequest , reply * structs . NodeUpdateResponse ) error { if done , err := n . srv . forward ( " " , args , args , reply ) ; done { return err } defer metrics . MeasureSince ( [ ] string { " " , " " , " " } , time . Now ( ) ) if args . NodeID == " " { return fmt . Errorf ( " " ) } _ , index , err := n . srv . raftApply ( structs . NodeDeregisterRequestType , args ) if err != nil { n . srv . logger . Printf ( " " , err ) return err } n . srv . clearHeartbeatTimer ( args . NodeID ) evalIDs , evalIndex , err := n . createNodeEvals ( args . NodeID , index ) if err != nil { n . srv . logger . Printf ( " " , err ) return err } ws := memdb . NewWatchSet ( ) accessors , err := n . srv . State ( ) . VaultAccessorsByNode ( ws , args . NodeID ) if err != nil { n . srv . logger . Printf ( " " , args . NodeID , err ) return err } if l := len ( accessors ) ; l != 0 { n . srv . logger . Printf ( " " , l , args . NodeID ) if err := n . srv . vault . RevokeTokens ( context . Background ( ) , accessors , true ) ; err != nil { n . srv . logger . Printf ( " " , args . NodeID , err ) return err } } reply . EvalIDs = evalIDs reply . EvalCreateIndex = evalIndex reply . NodeModifyIndex = index reply . Index = index return nil }
Deregister is used to remove a client from the cluster.
Deregister is used to remove a client from the cluster .
// Verify the arguments // Commit this update via Raft // Clear the heartbeat timer if any // Create the evaluations for this node // Determine if there are any Vault accessors on the node // Setup the reply