Debian Codegraph @

api/v1/lib/scheduler/scheduler.proto

raw
1 //
2 // Licensed to the Apache Software Foundation (ASF) under one
3 // or more contributor license agreements. See the NOTICE file
4 // distributed with this work for additional information
5 // regarding copyright ownership. The ASF licenses this file
6 // to you under the Apache License, Version 2.0 (the
7 // "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 //
10 // http://www.apache.org/licenses/LICENSE-2.0
11 //
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
17
18 syntax = "proto2";
19
20 package mesos.scheduler;
21
22 import "github.com/mesos/mesos-go/api/v1/lib/mesos.proto";
23 import "github.com/gogo/protobuf/gogoproto/gogo.proto";
24
25 option go_package = "scheduler";
26 option (gogoproto.benchgen_all) = true;
27 option (gogoproto.enum_stringer_all) = true;
28 option (gogoproto.equal_all) = true;
29 option (gogoproto.goproto_enum_prefix_all) = false;
30 option (gogoproto.goproto_enum_stringer_all) = false;
31 option (gogoproto.goproto_stringer_all) = false;
32 option (gogoproto.goproto_unrecognized_all) = false;
33 option (gogoproto.gostring_all) = true;
34 option (gogoproto.marshaler_all) = true;
35 option (gogoproto.populate_all) = true;
36 option (gogoproto.protosizer_all) = true;
37 option (gogoproto.stringer_all) = true;
38 option (gogoproto.testgen_all) = true;
39 option (gogoproto.unmarshaler_all) = true;
40 option (gogoproto.verbose_equal_all) = true;
41
42 /**
43 * Scheduler event API.
44 *
45 * An event is described using the standard protocol buffer "union"
46 * trick, see:
47 * https://developers.google.com/protocol-buffers/docs/techniques#union.
48 */
49 message Event {
50 // Possible event types, followed by message definitions if
51 // applicable.
52 enum Type {
53 // This must be the first enum value in this list, to
54 // ensure that if 'type' is not set, the default value
55 // is UNKNOWN. This enables enum values to be added
56 // in a backwards-compatible way. See: MESOS-4997.
57 UNKNOWN = 0;
58
59 SUBSCRIBED = 1; // See 'Subscribed' below.
60 OFFERS = 2; // See 'Offers' below.
61 INVERSE_OFFERS = 9; // See 'InverseOffers' below.
62 RESCIND = 3; // See 'Rescind' below.
63 RESCIND_INVERSE_OFFER = 10; // See 'RescindInverseOffer' below.
64 UPDATE = 4; // See 'Update' below.
65 MESSAGE = 5; // See 'Message' below.
66 FAILURE = 6; // See 'Failure' below.
67 ERROR = 7; // See 'Error' below.
68
69 // Periodic message sent by the Mesos master according to
70 // 'Subscribed.heartbeat_interval_seconds'. If the scheduler does
71 // not receive any events (including heartbeats) for an extended
72 // period of time (e.g., 5 x heartbeat_interval_seconds), there is
73 // likely a network partition. In such a case the scheduler should
74 // close the existing subscription connection and resubscribe
75 // using a backoff strategy.
76 HEARTBEAT = 8;
77
78 option (gogoproto.goproto_enum_prefix) = true;
79 }
80
81 // First event received when the scheduler subscribes.
82 message Subscribed {
83 required FrameworkID framework_id = 1 [(gogoproto.customname) = "FrameworkID"];
84
85 // This value will be set if the master is sending heartbeats. See
86 // the comment above on 'HEARTBEAT' for more details.
87 optional double heartbeat_interval_seconds = 2;
88
89 // Since Mesos 1.1.
90 optional MasterInfo master_info = 3;
91 }
92
93 // Received whenever there are new resources that are offered to the
94 // scheduler. Each offer corresponds to a set of resources on an
95 // agent. Until the scheduler accepts or declines an offer the
96 // resources are considered allocated to the scheduler.
97 message Offers {
98 repeated Offer offers = 1 [(gogoproto.nullable) = false];
99 }
100
101 // Received whenever there are resources requested back from the
102 // scheduler. Each inverse offer specifies the agent, and
103 // optionally specific resources. Accepting or Declining an inverse
104 // offer informs the allocator of the scheduler's ability to release
105 // the specified resources without violating an SLA. If no resources
106 // are specified then all resources on the agent are requested to be
107 // released.
108 message InverseOffers {
109 repeated InverseOffer inverse_offers = 1 [(gogoproto.nullable) = false];
110 }
111
112 // Received when a particular offer is no longer valid (e.g., the
113 // agent corresponding to the offer has been removed) and hence
114 // needs to be rescinded. Any future calls ('Accept' / 'Decline') made
115 // by the scheduler regarding this offer will be invalid.
116 message Rescind {
117 required OfferID offer_id = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "OfferID"];
118 }
119
120 // Received when a particular inverse offer is no longer valid
121 // (e.g., the agent corresponding to the offer has been removed)
122 // and hence needs to be rescinded. Any future calls ('Accept' /
123 // 'Decline') made by the scheduler regarding this inverse offer
124 // will be invalid.
125 message RescindInverseOffer {
126 required OfferID inverse_offer_id = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "InverseOfferID"];
127 }
128
129 // Received whenever there is a status update that is generated by
130 // the executor or agent or master. Status updates should be used by
131 // executors to reliably communicate the status of the tasks that
132 // they manage. It is crucial that a terminal update (see TaskState
133 // in v1/mesos.proto) is sent by the executor as soon as the task
134 // terminates, in order for Mesos to release the resources allocated
135 // to the task. It is also the responsibility of the scheduler to
136 // explicitly acknowledge the receipt of a status update. See
137 // 'Acknowledge' in the 'Call' section below for the semantics.
138 //
139 // A task status update may be used for guaranteed delivery of some
140 // task-related information, e.g., task's health update. Such
141 // information may be shadowed by subsequent task status updates, that
142 // do not preserve fields of the previously sent message.
143 message Update {
144 required TaskStatus status = 1 [(gogoproto.nullable) = false];
145 }
146
147 // Received when a custom message generated by the executor is
148 // forwarded by the master. Note that this message is not
149 // interpreted by Mesos and is only forwarded (without reliability
150 // guarantees) to the scheduler. It is up to the executor to retry
151 // if the message is dropped for any reason.
152 message Message {
153 required AgentID agent_id = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "AgentID"];
154 required ExecutorID executor_id = 2 [(gogoproto.nullable) = false, (gogoproto.customname) = "ExecutorID"];
155 required bytes data = 3;
156 }
157
158 // Received when an agent is removed from the cluster (e.g., failed
159 // health checks) or when an executor is terminated. Note that, this
160 // event coincides with receipt of terminal UPDATE events for any
161 // active tasks belonging to the agent or executor and receipt of
162 // 'Rescind' events for any outstanding offers belonging to the
163 // agent. Note that there is no guaranteed order between the
164 // 'Failure', 'Update' and 'Rescind' events when an agent or executor
165 // is removed.
166 // TODO(vinod): Consider splitting the lost agent and terminated
167 // executor into separate events and ensure it's reliably generated.
168 message Failure {
169 optional AgentID agent_id = 1 [(gogoproto.customname) = "AgentID"];
170
171 // If this was just a failure of an executor on an agent then
172 // 'executor_id' will be set and possibly 'status' (if we were
173 // able to determine the exit status).
174 optional ExecutorID executor_id = 2 [(gogoproto.customname) = "ExecutorID"];
175
176 // On Posix, `status` corresponds to termination information in the
177 // `stat_loc` area returned from a `waitpid` call. On Windows, `status`
178 // is obtained via calling the `GetExitCodeProcess()` function. For
179 // messages coming from Posix agents, schedulers need to apply
180 // `WEXITSTATUS` family macros or equivalent transformations to obtain
181 // exit codes.
182 //
183 // TODO(alexr): Consider unifying Windows and Posix behavior by returning
184 // exit code here, see MESOS-7241.
185 optional int32 status = 3;
186 }
187
188 // Received when there is an unrecoverable error in the scheduler (e.g.,
189 // scheduler failed over, rate limiting, authorization errors etc.). The
190 // scheduler should abort on receiving this event.
191 message Error {
192 required string message = 1 [(gogoproto.nullable) = false];
193 }
194
195 // Type of the event, indicates which optional field below should be
196 // present if that type has a nested message definition.
197 // Enum fields should be optional, see: MESOS-4997.
198 optional Type type = 1 [(gogoproto.nullable) = false];
199
200 optional Subscribed subscribed = 2;
201 optional Offers offers = 3;
202 optional InverseOffers inverse_offers = 9;
203 optional Rescind rescind = 4;
204 optional RescindInverseOffer rescind_inverse_offer = 10;
205 optional Update update = 5;
206 optional Message message = 6;
207 optional Failure failure = 7;
208 optional Error error = 8;
209 }
210
211
212 /**
213 * Scheduler call API.
214 *
215 * Like Event, a Call is described using the standard protocol buffer
216 * "union" trick (see above).
217 */
218 message Call {
219 // Possible call types, followed by message definitions if
220 // applicable.
221 enum Type {
222 // See comments above on `Event::Type` for more details on this enum value.
223 UNKNOWN = 0;
224
225 SUBSCRIBE = 1; // See 'Subscribe' below.
226 TEARDOWN = 2; // Shuts down all tasks/executors and removes framework.
227 ACCEPT = 3; // See 'Accept' below.
228 DECLINE = 4; // See 'Decline' below.
229 ACCEPT_INVERSE_OFFERS = 13; // See 'AcceptInverseOffers' below.
230 DECLINE_INVERSE_OFFERS = 14; // See 'DeclineInverseOffers' below.
231 REVIVE = 5; // Removes any previous filters set via ACCEPT or DECLINE.
232 KILL = 6; // See 'Kill' below.
233 SHUTDOWN = 7; // See 'Shutdown' below.
234 ACKNOWLEDGE = 8; // See 'Acknowledge' below.
235 RECONCILE = 9; // See 'Reconcile' below.
236 MESSAGE = 10; // See 'Message' below.
237 REQUEST = 11; // See 'Request' below.
238 SUPPRESS = 12; // Inform master to stop sending offers to the framework.
239
240 // TODO(benh): Consider adding an 'ACTIVATE' and 'DEACTIVATE' for
241 // already subscribed frameworks as a way of stopping offers from
242 // being generated and other events from being sent by the master.
243 // Note that this functionality existed originally to support
244 // SchedulerDriver::abort which was only necessary to handle
245 // exceptions getting thrown from within Scheduler callbacks,
246 // something that is not an issue with the Event/Call API.
247 option (gogoproto.goproto_enum_prefix) = true;
248 }
249
250 // Subscribes the scheduler with the master to receive events. A
251 // scheduler must send other calls only after it has received the
252 // SUBCRIBED event.
253 message Subscribe {
254 // See the comments below on 'framework_id' on the semantics for
255 // 'framework_info.id'.
256 required FrameworkInfo framework_info = 1;
257
258 // List of suppressed roles for which the framework does not wish to be
259 // offered resources. The framework can decide to suppress all or a subset
260 // of roles the framework (re)registers as.
261 repeated string suppressed_roles = 2;
262 }
263
264 // Accepts an offer, performing the specified operations
265 // in a sequential manner.
266 //
267 // E.g. Launch a task with a newly reserved persistent volume:
268 //
269 // Accept {
270 // offer_ids: [ ... ]
271 // operations: [
272 // { type: RESERVE,
273 // reserve: { resources: [ disk(role):2 ] } }
274 // { type: CREATE,
275 // create: { volumes: [ disk(role):1+persistence ] } }
276 // { type: LAUNCH,
277 // launch: { task_infos ... disk(role):1;disk(role):1+persistence } }
278 // ]
279 // }
280 //
281 // Note that any of the offer’s resources not used in the 'Accept'
282 // call (e.g., to launch a task) are considered unused and might be
283 // reoffered to other frameworks. In other words, the same OfferID
284 // cannot be used in more than one 'Accept' call.
285 message Accept {
286 repeated OfferID offer_ids = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "OfferIDs"];
287 repeated Offer.Operation operations = 2 [(gogoproto.nullable) = false];
288 optional Filters filters = 3;
289 }
290
291 // Declines an offer, signaling the master to potentially reoffer
292 // the resources to a different framework. Note that this is same
293 // as sending an Accept call with no operations. See comments on
294 // top of 'Accept' for semantics.
295 message Decline {
296 repeated OfferID offer_ids = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "OfferIDs"];
297 optional Filters filters = 2;
298 }
299
300 // Accepts an inverse offer. Inverse offers should only be accepted
301 // if the resources in the offer can be safely evacuated before the
302 // provided unavailability.
303 message AcceptInverseOffers {
304 repeated OfferID inverse_offer_ids = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "InverseOfferIDs"];
305 optional Filters filters = 2;
306 }
307
308 // Declines an inverse offer. Inverse offers should be declined if
309 // the resources in the offer might not be safely evacuated before
310 // the provided unavailability.
311 message DeclineInverseOffers {
312 repeated OfferID inverse_offer_ids = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "InverseOfferIDs"];
313 optional Filters filters = 2;
314 }
315
316 // Revive offers for the specified roles. If `roles` is empty,
317 // the `REVIVE` call will revive offers for all of the roles
318 // the framework is currently subscribed to.
319 message Revive {
320 repeated string roles = 1;
321 }
322
323 // Kills a specific task. If the scheduler has a custom executor,
324 // the kill is forwarded to the executor and it is up to the
325 // executor to kill the task and send a TASK_KILLED (or TASK_FAILED)
326 // update. Note that Mesos releases the resources for a task once it
327 // receives a terminal update (See TaskState in v1/mesos.proto) for
328 // it. If the task is unknown to the master, a TASK_LOST update is
329 // generated.
330 //
331 // If a task within a task group is killed before the group is
332 // delivered to the executor, all tasks in the task group are
333 // killed. When a task group has been delivered to the executor,
334 // it is up to the executor to decide how to deal with the kill.
335 // Note The default Mesos executor will currently kill all the
336 // tasks in the task group if it gets a kill for any task.
337 message Kill {
338 required TaskID task_id = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "TaskID"];
339 optional AgentID agent_id = 2 [(gogoproto.customname) = "AgentID"];
340
341 // If set, overrides any previously specified kill policy for this task.
342 // This includes 'TaskInfo.kill_policy' and 'Executor.kill.kill_policy'.
343 // Can be used to forcefully kill a task which is already being killed.
344 optional KillPolicy kill_policy = 3;
345 }
346
347 // Shuts down a custom executor. When the executor gets a shutdown
348 // event, it is expected to kill all its tasks (and send TASK_KILLED
349 // updates) and terminate. If the executor doesn’t terminate within
350 // a certain timeout (configurable via
351 // '--executor_shutdown_grace_period' agent flag), the agent will
352 // forcefully destroy the container (executor and its tasks) and
353 // transition its active tasks to TASK_LOST.
354 message Shutdown {
355 required ExecutorID executor_id = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "ExecutorID"];
356 required AgentID agent_id = 2 [(gogoproto.nullable) = false, (gogoproto.customname) = "AgentID"];
357 }
358
359 // Acknowledges the receipt of status update. Schedulers are
360 // responsible for explicitly acknowledging the receipt of status
361 // updates that have 'Update.status().uuid()' field set. Such status
362 // updates are retried by the agent until they are acknowledged by
363 // the scheduler.
364 message Acknowledge {
365 required AgentID agent_id = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "AgentID"];
366 required TaskID task_id = 2 [(gogoproto.nullable) = false, (gogoproto.customname) = "TaskID"];
367 required bytes uuid = 3 [(gogoproto.customname) = "UUID"];
368 }
369
370 // Allows the scheduler to query the status for non-terminal tasks.
371 // This causes the master to send back the latest task status for
372 // each task in 'tasks', if possible. Tasks that are no longer known
373 // will result in a TASK_LOST, TASK_UNKNOWN, or TASK_UNREACHABLE update.
374 // If 'tasks' is empty, then the master will send the latest status
375 // for each task currently known.
376 message Reconcile {
377 // TODO(vinod): Support arbitrary queries than just state of tasks.
378 message Task {
379 required TaskID task_id = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "TaskID"];
380 optional AgentID agent_id = 2 [(gogoproto.customname) = "AgentID"];
381 }
382
383 repeated Task tasks = 1 [(gogoproto.nullable) = false];
384 }
385
386 // Sends arbitrary binary data to the executor. Note that Mesos
387 // neither interprets this data nor makes any guarantees about the
388 // delivery of this message to the executor.
389 message Message {
390 required AgentID agent_id = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "AgentID"];
391 required ExecutorID executor_id = 2 [(gogoproto.nullable) = false, (gogoproto.customname) = "ExecutorID"];
392 required bytes data = 3;
393 }
394
395 // Requests a specific set of resources from Mesos's allocator. If
396 // the allocator has support for this, corresponding offers will be
397 // sent asynchronously via the OFFERS event(s).
398 //
399 // NOTE: The built-in hierarchical allocator doesn't have support
400 // for this call and hence simply ignores it.
401 message Request {
402 repeated mesos.Request requests = 1 [(gogoproto.nullable) = false];
403 }
404
405 // Suppress offers for the specified roles. If `roles` is empty,
406 // the `SUPPRESS` call will suppress offers for all of the roles
407 // the framework is currently subscribed to.
408 message Suppress {
409 repeated string roles = 1;
410 }
411
412 // Identifies who generated this call. Master assigns a framework id
413 // when a new scheduler subscribes for the first time. Once assigned,
414 // the scheduler must set the 'framework_id' here and within its
415 // FrameworkInfo (in any further 'Subscribe' calls). This allows the
416 // master to identify a scheduler correctly across disconnections,
417 // failovers, etc.
418 optional FrameworkID framework_id = 1 [(gogoproto.customname) = "FrameworkID"];
419
420 // Type of the call, indicates which optional field below should be
421 // present if that type has a nested message definition.
422 // See comments on `Event::Type` above on the reasoning behind this field being optional.
423 optional Type type = 2 [(gogoproto.nullable) = false];
424
425 optional Subscribe subscribe = 3;
426 optional Accept accept = 4;
427 optional Decline decline = 5;
428 optional AcceptInverseOffers accept_inverse_offers = 13;
429 optional DeclineInverseOffers decline_inverse_offers = 14;
430 optional Revive revive = 15;
431 optional Kill kill = 6;
432 optional Shutdown shutdown = 7;
433 optional Acknowledge acknowledge = 8;
434 optional Reconcile reconcile = 9;
435 optional Message message = 10;
436 optional Request request = 11;
437 optional Suppress suppress = 16;
438 }