Debian Codegraph @

api/v0/mesosproto/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
19 package mesosproto.scheduler;
20
21 import "github.com/mesos/mesos-go/mesosproto/mesos.proto";
22 import "github.com/gogo/protobuf/gogoproto/gogo.proto";
23
24 option go_package = "scheduler";
25 option (gogoproto.gostring_all) = true;
26 option (gogoproto.equal_all) = true;
27 option (gogoproto.verbose_equal_all) = true;
28 option (gogoproto.goproto_stringer_all) = false;
29 option (gogoproto.stringer_all) = true;
30 option (gogoproto.populate_all) = true;
31 option (gogoproto.testgen_all) = true;
32 option (gogoproto.benchgen_all) = true;
33 option (gogoproto.marshaler_all) = true;
34 option (gogoproto.sizer_all) = true;
35 option (gogoproto.unmarshaler_all) = true;
36
37 /**
38 * Scheduler event API.
39 *
40 * An event is described using the standard protocol buffer "union"
41 * trick, see:
42 * https://developers.google.com/protocol-buffers/docs/techniques#union.
43 */
44 message Event {
45 // Possible event types, followed by message definitions if
46 // applicable.
47 enum Type {
48 SUBSCRIBED = 1; // See 'Subscribed' below.
49 OFFERS = 2; // See 'Offers' below.
50 RESCIND = 3; // See 'Rescind' below.
51 UPDATE = 4; // See 'Update' below.
52 MESSAGE = 5; // See 'Message' below.
53 FAILURE = 6; // See 'Failure' below.
54 ERROR = 7; // See 'Error' below.
55
56 // Periodic message sent by the Mesos master according to
57 // 'Subscribed.heartbeat_interval_seconds'. If the scheduler does
58 // not receive any events (including heartbeats) for an extended
59 // period of time (e.g., 5 x heartbeat_interval_seconds), there is
60 // likely a network partition. In such a case the scheduler should
61 // close the existing subscription connection and resubscribe
62 // using a backoff strategy.
63 HEARTBEAT = 8;
64 }
65
66 // First event received when the scheduler subscribes.
67 message Subscribed {
68 required FrameworkID framework_id = 1;
69
70 // This value will be set if the master is sending heartbeats. See
71 // the comment above on 'HEARTBEAT' for more details.
72 optional double heartbeat_interval_seconds = 2;
73 }
74
75 // Received whenever there are new resources that are offered to the
76 // scheduler or resources requested back from the scheduler. Each
77 // offer corresponds to a set of resources on a slave. Until the
78 // scheduler accepts or declines an offer the resources are
79 // considered allocated to the scheduler. Accepting or Declining an
80 // inverse offer informs the allocator of the scheduler's ability to
81 // release the resources without violating an SLA.
82 message Offers {
83 repeated Offer offers = 1;
84 repeated InverseOffer inverse_offers = 2;
85 }
86
87 // Received when a particular offer is no longer valid (e.g., the
88 // slave corresponding to the offer has been removed) and hence
89 // needs to be rescinded. Any future calls ('Accept' / 'Decline') made
90 // by the scheduler regarding this offer will be invalid.
91 message Rescind {
92 required OfferID offer_id = 1;
93 }
94
95 // Received whenever there is a status update that is generated by
96 // the executor or slave or master. Status updates should be used by
97 // executors to reliably communicate the status of the tasks that
98 // they manage. It is crucial that a terminal update (see TaskState
99 // in mesos.proto) is sent by the executor as soon as the task
100 // terminates, in order for Mesos to release the resources allocated
101 // to the task. It is also the responsibility of the scheduler to
102 // explicitly acknowledge the receipt of a status update. See
103 // 'Acknowledge' in the 'Call' section below for the semantics.
104 message Update {
105 required TaskStatus status = 1;
106 }
107
108 // Received when a custom message generated by the executor is
109 // forwarded by the master. Note that this message is not
110 // interpreted by Mesos and is only forwarded (without reliability
111 // guarantees) to the scheduler. It is up to the executor to retry
112 // if the message is dropped for any reason.
113 message Message {
114 required SlaveID slave_id = 1;
115 required ExecutorID executor_id = 2;
116 required bytes data = 3;
117 }
118
119 // Received when a slave is removed from the cluster (e.g., failed
120 // health checks) or when an executor is terminated. Note that, this
121 // event coincides with receipt of terminal UPDATE events for any
122 // active tasks belonging to the slave or executor and receipt of
123 // 'Rescind' events for any outstanding offers belonging to the
124 // slave. Note that there is no guaranteed order between the
125 // 'Failure', 'Update' and 'Rescind' events when a slave or executor
126 // is removed.
127 // TODO(vinod): Consider splitting the lost slave and terminated
128 // executor into separate events and ensure it's reliably generated.
129 message Failure {
130 optional SlaveID slave_id = 1;
131
132 // If this was just a failure of an executor on a slave then
133 // 'executor_id' will be set and possibly 'status' (if we were
134 // able to determine the exit status).
135 optional ExecutorID executor_id = 2;
136 optional int32 status = 3;
137 }
138
139 // Received when an invalid framework (e.g., unauthenticated,
140 // unauthorized) attempts to subscribe with the master. Error can
141 // also be received if scheduler sends invalid Calls (e.g., not
142 // properly initialized).
143 // TODO(vinod): Remove this once the old scheduler driver is no
144 // longer supported. With HTTP API all errors will be signaled via
145 // HTTP response codes.
146 message Error {
147 required string message = 1;
148 }
149
150 // Type of the event, indicates which optional field below should be
151 // present if that type has a nested message definition.
152 required Type type = 1;
153
154 optional Subscribed subscribed = 2;
155 optional Offers offers = 3;
156 optional Rescind rescind = 4;
157 optional Update update = 5;
158 optional Message message = 6;
159 optional Failure failure = 7;
160 optional Error error = 8;
161 }
162
163
164 /**
165 * Scheduler call API.
166 *
167 * Like Event, a Call is described using the standard protocol buffer
168 * "union" trick (see above).
169 */
170 message Call {
171 // Possible call types, followed by message definitions if
172 // applicable.
173 enum Type {
174 SUBSCRIBE = 1; // See 'Subscribe' below.
175 TEARDOWN = 2; // Shuts down all tasks/executors and removes framework.
176 ACCEPT = 3; // See 'Accept' below.
177 DECLINE = 4; // See 'Decline' below.
178 REVIVE = 5; // Removes any previous filters set via ACCEPT or DECLINE.
179 KILL = 6; // See 'Kill' below.
180 SHUTDOWN = 7; // See 'Shutdown' below.
181 ACKNOWLEDGE = 8; // See 'Acknowledge' below.
182 RECONCILE = 9; // See 'Reconcile' below.
183 MESSAGE = 10; // See 'Message' below.
184 REQUEST = 11; // See 'Request' below.
185 SUPPRESS = 12; // Inform master to stop sending offers to the framework.
186
187 // TODO(benh): Consider adding an 'ACTIVATE' and 'DEACTIVATE' for
188 // already subscribed frameworks as a way of stopping offers from
189 // being generated and other events from being sent by the master.
190 // Note that this functionality existed originally to support
191 // SchedulerDriver::abort which was only necessary to handle
192 // exceptions getting thrown from within Scheduler callbacks,
193 // something that is not an issue with the Event/Call API.
194 }
195
196 // Subscribes the scheduler with the master to receive events. A
197 // scheduler must send other calls only after it has received the
198 // SUBCRIBED event.
199 message Subscribe {
200 // See the comments below on 'framework_id' on the semantics for
201 // 'framework_info.id'.
202 required FrameworkInfo framework_info = 1;
203
204 // 'force' field is only relevant when 'framework_info.id' is set.
205 // It tells the master what to do in case an instance of the
206 // scheduler attempts to subscribe when another instance of it is
207 // already connected (e.g., split brain due to network partition).
208 // If 'force' is true, this scheduler instance is allowed and the
209 // old connected scheduler instance is disconnected. If false,
210 // this scheduler instance is disallowed subscription in favor of
211 // the already connected scheduler instance.
212 //
213 // It is recommended to set this to true only when a newly elected
214 // scheduler instance is attempting to subscribe but not when a
215 // scheduler is retrying subscription (e.g., disconnection or
216 // master failover; see sched/sched.cpp for an example).
217 optional bool force = 2;
218 }
219
220 // Accepts an offer, performing the specified operations
221 // in a sequential manner.
222 //
223 // E.g. Launch a task with a newly reserved persistent volume:
224 //
225 // Accept {
226 // offer_ids: [ ... ]
227 // operations: [
228 // { type: RESERVE,
229 // reserve: { resources: [ disk(role):2 ] } }
230 // { type: CREATE,
231 // create: { volumes: [ disk(role):1+persistence ] } }
232 // { type: LAUNCH,
233 // launch: { task_infos ... disk(role):1;disk(role):1+persistence } }
234 // ]
235 // }
236 //
237 // Note that any of the offer’s resources not used in the 'Accept'
238 // call (e.g., to launch a task) are considered unused and might be
239 // reoffered to other frameworks. In other words, the same OfferID
240 // cannot be used in more than one 'Accept' call.
241 message Accept {
242 repeated OfferID offer_ids = 1;
243 repeated Offer.Operation operations = 2;
244 optional Filters filters = 3;
245 }
246
247 // Declines an offer, signaling the master to potentially reoffer
248 // the resources to a different framework. Note that this is same
249 // as sending an Accept call with no operations. See comments on
250 // top of 'Accept' for semantics.
251 message Decline {
252 repeated OfferID offer_ids = 1;
253 optional Filters filters = 2;
254 }
255
256 // Kills a specific task. If the scheduler has a custom executor,
257 // the kill is forwarded to the executor and it is up to the
258 // executor to kill the task and send a TASK_KILLED (or TASK_FAILED)
259 // update. Note that Mesos releases the resources for a task once it
260 // receives a terminal update (See TaskState in mesos.proto) for it.
261 // If the task is unknown to the master, a TASK_LOST update is
262 // generated.
263 message Kill {
264 required TaskID task_id = 1;
265 optional SlaveID slave_id = 2;
266 }
267
268 // Shuts down a custom executor. When the executor gets a shutdown
269 // event, it is expected to kill all its tasks (and send TASK_KILLED
270 // updates) and terminate. If the executor doesn’t terminate within
271 // a certain timeout (configurable via
272 // '--executor_shutdown_grace_period' slave flag), the slave will
273 // forcefully destroy the container (executor and its tasks) and
274 // transition its active tasks to TASK_LOST.
275 message Shutdown {
276 required ExecutorID executor_id = 1;
277 required SlaveID slave_id = 2;
278 }
279
280 // Acknowledges the receipt of status update. Schedulers are
281 // responsible for explicitly acknowledging the receipt of status
282 // updates that have 'Update.status().uuid()' field set. Such status
283 // updates are retried by the slave until they are acknowledged by
284 // the scheduler.
285 message Acknowledge {
286 required SlaveID slave_id = 1;
287 required TaskID task_id = 2;
288 required bytes uuid = 3;
289 }
290
291 // Allows the scheduler to query the status for non-terminal tasks.
292 // This causes the master to send back the latest task status for
293 // each task in 'tasks', if possible. Tasks that are no longer known
294 // will result in a TASK_LOST update. If 'statuses' is empty, then
295 // the master will send the latest status for each task currently
296 // known.
297 message Reconcile {
298 // TODO(vinod): Support arbitrary queries than just state of tasks.
299 message Task {
300 required TaskID task_id = 1;
301 optional SlaveID slave_id = 2;
302 }
303
304 repeated Task tasks = 1;
305 }
306
307 // Sends arbitrary binary data to the executor. Note that Mesos
308 // neither interprets this data nor makes any guarantees about the
309 // delivery of this message to the executor.
310 message Message {
311 required SlaveID slave_id = 1;
312 required ExecutorID executor_id = 2;
313 required bytes data = 3;
314 }
315
316 // Requests a specific set of resources from Mesos's allocator. If
317 // the allocator has support for this, corresponding offers will be
318 // sent asynchronously via the OFFERS event(s).
319 //
320 // NOTE: The built-in hierarchical allocator doesn't have support
321 // for this call and hence simply ignores it.
322 message Request {
323 repeated mesosproto.Request requests = 1;
324 }
325
326 // Identifies who generated this call. Master assigns a framework id
327 // when a new scheduler subscribes for the first time. Once assigned,
328 // the scheduler must set the 'framework_id' here and within its
329 // FrameworkInfo (in any further 'Subscribe' calls). This allows the
330 // master to identify a scheduler correctly across disconnections,
331 // failovers, etc.
332 optional FrameworkID framework_id = 1;
333
334 // Type of the call, indicates which optional field below should be
335 // present if that type has a nested message definition.
336 required Type type = 2;
337
338 optional Subscribe subscribe = 3;
339 optional Accept accept = 4;
340 optional Decline decline = 5;
341 optional Kill kill = 6;
342 optional Shutdown shutdown = 7;
343 optional Acknowledge acknowledge = 8;
344 optional Reconcile reconcile = 9;
345 optional Message message = 10;
346 optional Request request = 11;
347 }