github.com/emate/nomad@v0.8.2-wo-binpacking/nomad/structs/operator.go (about)

     1  package structs
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/hashicorp/raft"
     7  )
     8  
     9  // RaftServer has information about a server in the Raft configuration.
    10  type RaftServer struct {
    11  	// ID is the unique ID for the server. These are currently the same
    12  	// as the address, but they will be changed to a real GUID in a future
    13  	// release of Nomad.
    14  	ID raft.ServerID
    15  
    16  	// Node is the node name of the server, as known by Nomad, or this
    17  	// will be set to "(unknown)" otherwise.
    18  	Node string
    19  
    20  	// Address is the IP:port of the server, used for Raft communications.
    21  	Address raft.ServerAddress
    22  
    23  	// Leader is true if this server is the current cluster leader.
    24  	Leader bool
    25  
    26  	// Voter is true if this server has a vote in the cluster. This might
    27  	// be false if the server is staging and still coming online, or if
    28  	// it's a non-voting server, which will be added in a future release of
    29  	// Nomad.
    30  	Voter bool
    31  
    32  	// RaftProtocol is the version of the Raft protocol spoken by this server.
    33  	RaftProtocol string
    34  }
    35  
    36  // RaftConfigurationResponse is returned when querying for the current Raft
    37  // configuration.
    38  type RaftConfigurationResponse struct {
    39  	// Servers has the list of servers in the Raft configuration.
    40  	Servers []*RaftServer
    41  
    42  	// Index has the Raft index of this configuration.
    43  	Index uint64
    44  }
    45  
    46  // RaftPeerByAddressRequest is used by the Operator endpoint to apply a Raft
    47  // operation on a specific Raft peer by address in the form of "IP:port".
    48  type RaftPeerByAddressRequest struct {
    49  	// Address is the peer to remove, in the form "IP:port".
    50  	Address raft.ServerAddress
    51  
    52  	// WriteRequest holds the Region for this request.
    53  	WriteRequest
    54  }
    55  
    56  // RaftPeerByIDRequest is used by the Operator endpoint to apply a Raft
    57  // operation on a specific Raft peer by ID.
    58  type RaftPeerByIDRequest struct {
    59  	// ID is the peer ID to remove.
    60  	ID raft.ServerID
    61  
    62  	// WriteRequest holds the Region for this request.
    63  	WriteRequest
    64  }
    65  
    66  // AutopilotSetConfigRequest is used by the Operator endpoint to update the
    67  // current Autopilot configuration of the cluster.
    68  type AutopilotSetConfigRequest struct {
    69  	// Datacenter is the target this request is intended for.
    70  	Datacenter string
    71  
    72  	// Config is the new Autopilot configuration to use.
    73  	Config AutopilotConfig
    74  
    75  	// CAS controls whether to use check-and-set semantics for this request.
    76  	CAS bool
    77  
    78  	// WriteRequest holds the ACL token to go along with this request.
    79  	WriteRequest
    80  }
    81  
    82  // RequestDatacenter returns the datacenter for a given request.
    83  func (op *AutopilotSetConfigRequest) RequestDatacenter() string {
    84  	return op.Datacenter
    85  }
    86  
    87  // AutopilotConfig is the internal config for the Autopilot mechanism.
    88  type AutopilotConfig struct {
    89  	// CleanupDeadServers controls whether to remove dead servers when a new
    90  	// server is added to the Raft peers.
    91  	CleanupDeadServers bool
    92  
    93  	// ServerStabilizationTime is the minimum amount of time a server must be
    94  	// in a stable, healthy state before it can be added to the cluster. Only
    95  	// applicable with Raft protocol version 3 or higher.
    96  	ServerStabilizationTime time.Duration
    97  
    98  	// LastContactThreshold is the limit on the amount of time a server can go
    99  	// without leader contact before being considered unhealthy.
   100  	LastContactThreshold time.Duration
   101  
   102  	// MaxTrailingLogs is the amount of entries in the Raft Log that a server can
   103  	// be behind before being considered unhealthy.
   104  	MaxTrailingLogs uint64
   105  
   106  	// (Enterprise-only) EnableRedundancyZones specifies whether to enable redundancy zones.
   107  	EnableRedundancyZones bool
   108  
   109  	// (Enterprise-only) DisableUpgradeMigration will disable Autopilot's upgrade migration
   110  	// strategy of waiting until enough newer-versioned servers have been added to the
   111  	// cluster before promoting them to voters.
   112  	DisableUpgradeMigration bool
   113  
   114  	// (Enterprise-only) EnableCustomUpgrades specifies whether to enable using custom
   115  	// upgrade versions when performing migrations.
   116  	EnableCustomUpgrades bool
   117  
   118  	// CreateIndex/ModifyIndex store the create/modify indexes of this configuration.
   119  	CreateIndex uint64
   120  	ModifyIndex uint64
   121  }