github.com/thomasobenaus/nomad@v0.11.1/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 // MinQuorum sets the minimum number of servers required in a cluster 107 // before autopilot can prune dead servers. 108 MinQuorum uint 109 110 // (Enterprise-only) EnableRedundancyZones specifies whether to enable redundancy zones. 111 EnableRedundancyZones bool 112 113 // (Enterprise-only) DisableUpgradeMigration will disable Autopilot's upgrade migration 114 // strategy of waiting until enough newer-versioned servers have been added to the 115 // cluster before promoting them to voters. 116 DisableUpgradeMigration bool 117 118 // (Enterprise-only) EnableCustomUpgrades specifies whether to enable using custom 119 // upgrade versions when performing migrations. 120 EnableCustomUpgrades bool 121 122 // CreateIndex/ModifyIndex store the create/modify indexes of this configuration. 123 CreateIndex uint64 124 ModifyIndex uint64 125 } 126 127 // SchedulerConfiguration is the config for controlling scheduler behavior 128 type SchedulerConfiguration struct { 129 // PreemptionConfig specifies whether to enable eviction of lower 130 // priority jobs to place higher priority jobs. 131 PreemptionConfig PreemptionConfig `hcl:"preemption_config"` 132 133 // CreateIndex/ModifyIndex store the create/modify indexes of this configuration. 134 CreateIndex uint64 135 ModifyIndex uint64 136 } 137 138 // SchedulerConfigurationResponse is the response object that wraps SchedulerConfiguration 139 type SchedulerConfigurationResponse struct { 140 // SchedulerConfig contains scheduler config options 141 SchedulerConfig *SchedulerConfiguration 142 143 QueryMeta 144 } 145 146 // SchedulerSetConfigurationResponse is the response object used 147 // when updating scheduler configuration 148 type SchedulerSetConfigurationResponse struct { 149 // Updated returns whether the config was actually updated 150 // Only set when the request uses CAS 151 Updated bool 152 153 WriteMeta 154 } 155 156 // PreemptionConfig specifies whether preemption is enabled based on scheduler type 157 type PreemptionConfig struct { 158 // SystemSchedulerEnabled specifies if preemption is enabled for system jobs 159 SystemSchedulerEnabled bool `hcl:"system_scheduler_enabled"` 160 161 // BatchSchedulerEnabled specifies if preemption is enabled for batch jobs 162 BatchSchedulerEnabled bool `hcl:"batch_scheduler_enabled"` 163 164 // ServiceSchedulerEnabled specifies if preemption is enabled for service jobs 165 ServiceSchedulerEnabled bool `hcl:"service_scheduler_enabled"` 166 } 167 168 // SchedulerSetConfigRequest is used by the Operator endpoint to update the 169 // current Scheduler configuration of the cluster. 170 type SchedulerSetConfigRequest struct { 171 // Config is the new Scheduler configuration to use. 172 Config SchedulerConfiguration 173 174 // CAS controls whether to use check-and-set semantics for this request. 175 CAS bool 176 177 // WriteRequest holds the ACL token to go along with this request. 178 WriteRequest 179 }