github.com/bigcommerce/nomad@v0.9.3-bc/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 } 122 123 // SchedulerConfiguration is the config for controlling scheduler behavior 124 type SchedulerConfiguration struct { 125 // PreemptionConfig specifies whether to enable eviction of lower 126 // priority jobs to place higher priority jobs. 127 PreemptionConfig PreemptionConfig 128 129 // CreateIndex/ModifyIndex store the create/modify indexes of this configuration. 130 CreateIndex uint64 131 ModifyIndex uint64 132 } 133 134 // SchedulerConfigurationResponse is the response object that wraps SchedulerConfiguration 135 type SchedulerConfigurationResponse struct { 136 // SchedulerConfig contains scheduler config options 137 SchedulerConfig *SchedulerConfiguration 138 139 QueryMeta 140 } 141 142 // SchedulerSetConfigurationResponse is the response object used 143 // when updating scheduler configuration 144 type SchedulerSetConfigurationResponse struct { 145 // Updated returns whether the config was actually updated 146 // Only set when the request uses CAS 147 Updated bool 148 149 WriteMeta 150 } 151 152 // PreemptionConfig specifies whether preemption is enabled based on scheduler type 153 type PreemptionConfig struct { 154 // SystemSchedulerEnabled specifies if preemption is enabled for system jobs 155 SystemSchedulerEnabled bool 156 157 // BatchSchedulerEnabled specifies if preemption is enabled for batch jobs 158 BatchSchedulerEnabled bool 159 160 // ServiceSchedulerEnabled specifies if preemption is enabled for service jobs 161 ServiceSchedulerEnabled bool 162 } 163 164 // SchedulerSetConfigRequest is used by the Operator endpoint to update the 165 // current Scheduler configuration of the cluster. 166 type SchedulerSetConfigRequest struct { 167 // Config is the new Scheduler configuration to use. 168 Config SchedulerConfiguration 169 170 // CAS controls whether to use check-and-set semantics for this request. 171 CAS bool 172 173 // WriteRequest holds the ACL token to go along with this request. 174 WriteRequest 175 }