Debian Codegraph @

api/v1/lib/master/master.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.master;
21
22 import "github.com/mesos/mesos-go/api/v1/lib/mesos.proto";
23 import "github.com/mesos/mesos-go/api/v1/lib/allocator/allocator.proto";
24 import "github.com/mesos/mesos-go/api/v1/lib/maintenance/maintenance.proto";
25 import "github.com/mesos/mesos-go/api/v1/lib/quota/quota.proto";
26 import "github.com/gogo/protobuf/gogoproto/gogo.proto";
27
28 option go_package = "master";
29 option (gogoproto.benchgen_all) = true;
30 option (gogoproto.enum_stringer_all) = true;
31 option (gogoproto.equal_all) = true;
32 option (gogoproto.goproto_enum_prefix_all) = false;
33 option (gogoproto.goproto_enum_stringer_all) = false;
34 option (gogoproto.goproto_stringer_all) = false;
35 option (gogoproto.goproto_unrecognized_all) = false;
36 option (gogoproto.gostring_all) = true;
37 option (gogoproto.marshaler_all) = true;
38 option (gogoproto.populate_all) = true;
39 option (gogoproto.protosizer_all) = true;
40 option (gogoproto.stringer_all) = true;
41 option (gogoproto.testgen_all) = true;
42 option (gogoproto.unmarshaler_all) = true;
43 option (gogoproto.verbose_equal_all) = true;
44
45 /**
46 * Calls that can be sent to the v1 master API.
47 *
48 * A call is described using the standard protocol buffer "union"
49 * trick, see
50 * https://developers.google.com/protocol-buffers/docs/techniques#union.
51 */
52 message Call {
53 enum Type {
54 // If a call of type `Call::FOO` requires additional parameters they can be
55 // included in the corresponding `Call::Foo` message. Similarly, if a call
56 // receives a synchronous response it will be returned as a `Response`
57 // message of type `Response::FOO`. Currently all calls except
58 // `Call::SUBSCRIBE` receive synchronous responses; `Call::SUBSCRIBE` returns
59 // a streaming response of `Event`.
60 UNKNOWN = 0;
61
62 GET_HEALTH = 1; // Retrieves the master's health status.
63 GET_FLAGS = 2; // Retrieves the master's flag configuration.
64 GET_VERSION = 3; // Retrieves the master's version information.
65 GET_METRICS = 4; // See 'GetMetrics' below.
66
67 GET_LOGGING_LEVEL = 5; // Retrieves the master's logging level.
68 SET_LOGGING_LEVEL = 6; // See 'SetLoggingLevel' below.
69
70 LIST_FILES = 7;
71 READ_FILE = 8; // See 'ReadFile' below.
72
73 GET_STATE = 9;
74
75 GET_AGENTS = 10;
76 GET_FRAMEWORKS = 11;
77 GET_EXECUTORS = 12; // Retrieves the information about all executors.
78 GET_TASKS = 13; // Retrieves the information about all known tasks.
79 GET_ROLES = 14; // Retrieves the information about roles.
80
81 GET_WEIGHTS = 15; // Retrieves the information about role weights.
82 UPDATE_WEIGHTS = 16;
83
84 GET_MASTER = 17; // Retrieves the master's information.
85
86 SUBSCRIBE = 18; // Subscribes the master to receive events.
87
88 RESERVE_RESOURCES = 19;
89 UNRESERVE_RESOURCES = 20;
90
91 CREATE_VOLUMES = 21; // See 'CreateVolumes' below.
92 DESTROY_VOLUMES = 22; // See 'DestroyVolumes' below.
93
94 // Retrieves the cluster's maintenance status.
95 GET_MAINTENANCE_STATUS = 23;
96 // Retrieves the cluster's maintenance schedule.
97 GET_MAINTENANCE_SCHEDULE = 24;
98 UPDATE_MAINTENANCE_SCHEDULE = 25; // See 'UpdateMaintenanceSchedule' below.
99 START_MAINTENANCE = 26; // See 'StartMaintenance' below.
100 STOP_MAINTENANCE = 27; // See 'StopMaintenance' below.
101
102 GET_QUOTA = 28;
103 SET_QUOTA = 29; // See 'SetQuota' below.
104 REMOVE_QUOTA = 30; // See 'RemoveQuota' below.
105
106 option (gogoproto.goproto_enum_prefix) = true;
107 }
108
109 // Provides a snapshot of the current metrics tracked by the master.
110 message GetMetrics {
111 // If set, `timeout` would be used to determines the maximum amount of time
112 // the API will take to respond. If the timeout is exceeded, some metrics
113 // may not be included in the response.
114 optional DurationInfo timeout = 1;
115 }
116
117 // Sets the logging verbosity level for a specified duration. Mesos uses
118 // [glog](https://github.com/google/glog) for logging. The library only uses
119 // verbose logging which means nothing will be output unless the verbosity
120 // level is set (by default it's 0, libprocess uses levels 1, 2, and 3).
121 message SetLoggingLevel {
122 // The verbosity level.
123 required uint32 level = 1 [(gogoproto.nullable) = false];
124 // The duration to keep verbosity level toggled. After this duration, the
125 // verbosity level of log would revert to the original level.
126 required DurationInfo duration = 2 [(gogoproto.nullable) = false];
127 }
128
129 // Provides the file listing for a directory.
130 message ListFiles {
131 required string path = 1 [(gogoproto.nullable) = false];
132 }
133
134 // Reads data from a file.
135 message ReadFile {
136 // The path of file.
137 required string path = 1 [(gogoproto.nullable) = false];
138
139 // Initial offset in file to start reading from.
140 required uint64 offset = 2 [(gogoproto.nullable) = false];
141
142 // The maximum number of bytes to read. The read length is capped at 16
143 // memory pages.
144 optional uint64 length = 3;
145 }
146
147 message UpdateWeights {
148 repeated WeightInfo weight_infos = 1 [(gogoproto.nullable) = false];
149 }
150
151 // Reserve resources dynamically on a specific agent.
152 message ReserveResources {
153 required AgentID agent_id = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "AgentID"];
154 repeated Resource resources = 2 [(gogoproto.nullable) = false];
155 }
156
157 // Unreserve resources dynamically on a specific agent.
158 message UnreserveResources {
159 required AgentID agent_id = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "AgentID"];
160 repeated Resource resources = 2 [(gogoproto.nullable) = false];
161 }
162
163 // Create persistent volumes on reserved resources. The request is forwarded
164 // asynchronously to the Mesos agent where the reserved resources are located.
165 // That asynchronous message may not be delivered or creating the volumes at
166 // the agent might fail. Volume creation can be verified by sending a
167 // `GET_VOLUMES` call.
168 message CreateVolumes {
169 required AgentID agent_id = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "AgentID"];
170 repeated Resource volumes = 2 [(gogoproto.nullable) = false];
171 }
172
173 // Destroy persistent volumes. The request is forwarded asynchronously to the
174 // Mesos agent where the reserved resources are located. That asynchronous
175 // message may not be delivered or destroying the volumes at the agent might
176 // fail. Volume deletion can be verified by sending a `GET_VOLUMES` call.
177 message DestroyVolumes {
178 required AgentID agent_id = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "AgentID"];
179 repeated Resource volumes = 2 [(gogoproto.nullable) = false];
180 }
181
182 // Updates the cluster's maintenance schedule.
183 message UpdateMaintenanceSchedule {
184 required maintenance.Schedule schedule = 1 [(gogoproto.nullable) = false];
185 }
186
187 // Starts the maintenance of the cluster, this would bring a set of machines
188 // down.
189 message StartMaintenance {
190 repeated MachineID machines = 1 [(gogoproto.nullable) = false];
191 }
192
193 // Stops the maintenance of the cluster, this would bring a set of machines
194 // back up.
195 message StopMaintenance {
196 repeated MachineID machines = 1 [(gogoproto.nullable) = false];
197 }
198
199 // Sets the quota for resources to be used by a particular role.
200 message SetQuota {
201 required quota.QuotaRequest quota_request = 1 [(gogoproto.nullable) = false];
202 }
203
204 message RemoveQuota {
205 required string role = 1 [(gogoproto.nullable) = false];
206 }
207
208 optional Type type = 1 [(gogoproto.nullable) = false];
209
210 optional GetMetrics get_metrics = 2;
211 optional SetLoggingLevel set_logging_level = 3;
212 optional ListFiles list_files = 4;
213 optional ReadFile read_file = 5;
214 optional UpdateWeights update_weights = 6;
215 optional ReserveResources reserve_resources = 7;
216 optional UnreserveResources unreserve_resources = 8;
217 optional CreateVolumes create_volumes = 9;
218 optional DestroyVolumes destroy_volumes = 10;
219 optional UpdateMaintenanceSchedule update_maintenance_schedule = 11;
220 optional StartMaintenance start_maintenance = 12;
221 optional StopMaintenance stop_maintenance = 13;
222 optional SetQuota set_quota = 14;
223 optional RemoveQuota remove_quota = 15;
224 }
225
226
227 /**
228 * Synchronous responses for all calls (except Call::SUBSCRIBE) made to
229 * the v1 master API.
230 */
231 message Response {
232 // Each of the responses of type `FOO` corresponds to `Foo` message below.
233 enum Type {
234 UNKNOWN = 0;
235
236 GET_HEALTH = 1; // See 'GetHealth' below.
237 GET_FLAGS = 2; // See 'GetFlags' below.
238 GET_VERSION = 3; // See 'GetVersion' below.
239 GET_METRICS = 4; // See 'GetMetrics' below.
240
241 GET_LOGGING_LEVEL = 5; // See 'GetLoggingLevel' below.
242
243 LIST_FILES = 6;
244 READ_FILE = 7; // See 'ReadFile' below.
245
246 GET_STATE = 8;
247
248 GET_AGENTS = 9;
249 GET_FRAMEWORKS = 10;
250 GET_EXECUTORS = 11; // See 'GetExecutors' below.
251 GET_TASKS = 12; // See 'GetTasks' below.
252 GET_ROLES = 13; // See 'GetRoles' below.
253
254 GET_WEIGHTS = 14; // See 'GetWeights' below.
255
256 GET_MASTER = 15; // See 'GetMaster' below.
257
258 GET_MAINTENANCE_STATUS = 16; // See 'GetMaintenanceStatus' below.
259 GET_MAINTENANCE_SCHEDULE = 17; // See 'GetMaintenanceSchedule' below.
260
261 GET_QUOTA = 18;
262
263 option (gogoproto.goproto_enum_prefix) = true;
264 }
265
266 // `healthy` would be true if the master is healthy. Delayed responses are
267 // also indicative of the poor health of the master.
268 message GetHealth {
269 required bool healthy = 1 [(gogoproto.nullable) = false];
270 }
271
272 // Contains the flag configuration of the master.
273 message GetFlags {
274 repeated Flag flags = 1 [(gogoproto.nullable) = false];
275 }
276
277 // Contains the version information of the master.
278 message GetVersion {
279 required VersionInfo version_info = 1 [(gogoproto.nullable) = false];
280 }
281
282 // Contains a snapshot of the current metrics.
283 message GetMetrics {
284 repeated Metric metrics = 1 [(gogoproto.nullable) = false];
285 }
286
287 // Contains the logging level of the master.
288 message GetLoggingLevel {
289 required uint32 level = 1 [(gogoproto.nullable) = false];
290 }
291
292 // Contains the file listing(similar to `ls -l`) for a directory.
293 message ListFiles {
294 repeated FileInfo file_infos = 1 [(gogoproto.nullable) = false];
295 }
296
297 // Contains the file data.
298 message ReadFile {
299 // The size of file (in bytes).
300 required uint64 size = 1 [(gogoproto.nullable) = false];
301
302 required bytes data = 2;
303 }
304
305 // Contains full state of the master i.e. information about the tasks,
306 // agents, frameworks and executors running in the cluster.
307 message GetState {
308 optional GetTasks get_tasks = 1;
309 optional GetExecutors get_executors = 2;
310 optional GetFrameworks get_frameworks = 3;
311 optional GetAgents get_agents = 4;
312 }
313
314 message GetAgents {
315 message Agent {
316 required AgentInfo agent_info = 1 [(gogoproto.nullable) = false];
317 required bool active = 2 [(gogoproto.nullable) = false];
318 required string version = 3 [(gogoproto.nullable) = false];
319
320 optional string pid = 4 [(gogoproto.customname) = "PID"];
321 optional TimeInfo registered_time = 5;
322 optional TimeInfo reregistered_time = 6;
323
324 // Total resources (including oversubscribed resources) the agent
325 // provides.
326 repeated Resource total_resources = 7 [(gogoproto.nullable) = false];
327
328 repeated Resource allocated_resources = 8 [(gogoproto.nullable) = false];
329 repeated Resource offered_resources = 9 [(gogoproto.nullable) = false];
330
331 repeated AgentInfo.Capability capabilities = 10 [(gogoproto.nullable) = false];
332 }
333
334 // Registered agents.
335 repeated Agent agents = 1 [(gogoproto.nullable) = false];
336
337 // Agents which are recovered from registry but not reregistered yet.
338 repeated AgentInfo recovered_agents = 2 [(gogoproto.nullable) = false];
339 }
340
341 // Information about all the frameworks known to the master at the current
342 // time. Note that there might be frameworks unknown to the master running
343 // on partitioned or unsubscribed agents.
344 message GetFrameworks {
345 message Framework {
346 required FrameworkInfo framework_info = 1 [(gogoproto.nullable) = false];
347 required bool active = 2 [(gogoproto.nullable) = false];
348 required bool connected = 3 [(gogoproto.nullable) = false];
349
350 // If true, this framework was previously subscribed but hasn't
351 // yet re-subscribed after a master failover. Recovered frameworks
352 // are only reported if one or more agents running a task or
353 // executor for the framework have re-registered after master
354 // failover.
355 required bool recovered = 11 [(gogoproto.nullable) = false];
356
357 optional TimeInfo registered_time = 4;
358 optional TimeInfo reregistered_time = 5;
359 optional TimeInfo unregistered_time = 6;
360
361 repeated Offer offers = 7 [(gogoproto.nullable) = false];
362 repeated InverseOffer inverse_offers = 8 [(gogoproto.nullable) = false];
363
364 repeated Resource allocated_resources = 9 [(gogoproto.nullable) = false];
365 repeated Resource offered_resources = 10 [(gogoproto.nullable) = false];
366 }
367
368 // Frameworks that have subscribed with the master. Note that this includes
369 // frameworks that are disconnected and in the process of re-subscribing.
370 repeated Framework frameworks = 1 [(gogoproto.nullable) = false];
371
372 // Frameworks that have been teared down.
373 repeated Framework completed_frameworks = 2 [(gogoproto.nullable) = false];
374
375 // This field previously contained frameworks that previously
376 // subscribed but haven't yet re-subscribed after a master failover.
377 // As of Mesos 1.2, this field will always be empty; recovered
378 // frameworks are now reported in the `frameworks` list with the
379 // `recovered` field set to true.
380 //
381 // TODO(neilc): Remove this field in Mesos 2.0.
382 repeated FrameworkInfo recovered_frameworks = 3 [(gogoproto.nullable) = false];
383 }
384
385 // Lists information about all the executors known to the master at the
386 // current time. Note that there might be executors unknown to the master
387 // running on partitioned or unsubscribed agents.
388 message GetExecutors {
389 message Executor {
390 required ExecutorInfo executor_info = 1 [(gogoproto.nullable) = false];
391 required AgentID agent_id = 2 [(gogoproto.nullable) = false, (gogoproto.customname) = "AgentID"];
392 }
393
394 repeated Executor executors = 1 [(gogoproto.nullable) = false];
395
396 // As of Mesos 1.3.0, this field is deprecated and will always be empty.
397 //
398 // TODO(neilc): Remove this field in Mesos 2.0.
399 repeated Executor orphan_executors = 2 [(gogoproto.nullable) = false];
400 }
401
402 // Lists information about all the tasks known to the master at the current
403 // time. Note that there might be tasks unknown to the master running on
404 // partitioned or unsubscribed agents.
405 message GetTasks {
406 // Tasks that are enqueued on the master waiting (e.g., authorizing)
407 // to be launched.
408 repeated Task pending_tasks = 1 [(gogoproto.nullable) = false];
409
410 // Tasks that have been forwarded to the agent for launch. This
411 // includes tasks that are staging or running; it also includes
412 // tasks that have reached a terminal state but the terminal status
413 // update has not yet been acknowledged by the scheduler.
414 repeated Task tasks = 2 [(gogoproto.nullable) = false];
415
416 // Tasks that were running on agents that have become partitioned
417 // from the master. If/when the agent is no longer partitioned,
418 // tasks running on that agent will no longer be unreachable (they
419 // will either be running or completed). Note that the master only
420 // stores a limited number of unreachable tasks; information about
421 // unreachable tasks is also not preserved across master failover.
422 repeated Task unreachable_tasks = 5 [(gogoproto.nullable) = false];
423
424 // Tasks that have reached terminal state and have all their updates
425 // acknowledged by the scheduler.
426 repeated Task completed_tasks = 3 [(gogoproto.nullable) = false];
427
428 // As of Mesos 1.3.0, this field is deprecated and will always be empty.
429 //
430 // TODO(neilc): Remove this field in Mesos 2.0.
431 repeated Task orphan_tasks = 4 [(gogoproto.nullable) = false];
432 }
433
434 // Provides information about every role that is on the role whitelist (if
435 // enabled), has one or more registered frameworks or has a non-default weight
436 // or quota.
437 message GetRoles {
438 repeated Role roles = 1 [(gogoproto.nullable) = false];
439 }
440
441 // Provides the weight information about every role.
442 message GetWeights {
443 repeated WeightInfo weight_infos = 1 [(gogoproto.nullable) = false];
444 }
445
446 // Contains the master's information.
447 message GetMaster {
448 optional MasterInfo master_info = 1;
449 }
450
451 // Contains the cluster's maintenance status.
452 message GetMaintenanceStatus {
453 required maintenance.ClusterStatus status = 1 [(gogoproto.nullable) = false];
454 }
455
456 // Contains the cluster's maintenance schedule.
457 message GetMaintenanceSchedule {
458 required maintenance.Schedule schedule = 1 [(gogoproto.nullable) = false];
459 }
460
461 // Contains the cluster's configured quotas.
462 message GetQuota {
463 required quota.QuotaStatus status = 1 [(gogoproto.nullable) = false];
464 }
465
466 optional Type type = 1 [(gogoproto.nullable) = false];
467
468 optional GetHealth get_health = 2;
469 optional GetFlags get_flags = 3;
470 optional GetVersion get_version = 4;
471 optional GetMetrics get_metrics = 5;
472 optional GetLoggingLevel get_logging_level = 6;
473 optional ListFiles list_files = 7;
474 optional ReadFile read_file = 8;
475 optional GetState get_state = 9;
476 optional GetAgents get_agents = 10;
477 optional GetFrameworks get_frameworks = 11;
478 optional GetExecutors get_executors = 12;
479 optional GetTasks get_tasks = 13;
480 optional GetRoles get_roles = 14;
481 optional GetWeights get_weights = 15;
482 optional GetMaster get_master = 16;
483 optional GetMaintenanceStatus get_maintenance_status = 17;
484 optional GetMaintenanceSchedule get_maintenance_schedule = 18;
485 optional GetQuota get_quota = 19;
486 }
487
488
489 /**
490 * Streaming response to `Call::SUBSCRIBE` made to the master.
491 */
492 message Event {
493 enum Type {
494 UNKNOWN = 0;
495 SUBSCRIBED = 1; // See `Subscribed` below.
496 TASK_ADDED = 2; // See `TaskAdded` below.
497 TASK_UPDATED = 3; // See `TaskUpdated` below.
498 AGENT_ADDED = 4; // See `AgentAdded` below.
499 AGENT_REMOVED = 5; // See `AgentRemoved` below.
500 FRAMEWORK_ADDED = 6; // See `FrameworkAdded` below.
501 FRAMEWORK_UPDATED = 7; // See `FrameworkUpdated` below.
502 FRAMEWORK_REMOVED = 8; // See `FrameworkRemoved` below.
503
504 // TODO(vinod): Fill in more events.
505
506 option (gogoproto.goproto_enum_prefix) = true;
507 }
508
509 // First event received when a client subscribes.
510 message Subscribed {
511 // Snapshot of the entire cluster state. Further updates to the
512 // cluster state are sent as separate events on the stream.
513 optional Response.GetState get_state = 1;
514 }
515
516 // Forwarded by the master when a task becomes known to it. This can happen
517 // when a new task is launched by the scheduler or when the task becomes
518 // known to the master upon an agent (re-)registration after a failover.
519 message TaskAdded {
520 required Task task = 1 [(gogoproto.nullable) = false];
521 }
522
523 // Forwarded by the master when an existing task transitions to a new state.
524 message TaskUpdated {
525 required FrameworkID framework_id = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "FrameworkID"];
526
527 // This is the status of the task corresponding to the last
528 // status update acknowledged by the scheduler.
529 required TaskStatus status = 2 [(gogoproto.nullable) = false];
530
531 // This is the latest state of the task according to the agent.
532 required TaskState state = 3;
533 }
534
535
536 // Forwarded by the master when a framework becomes known to it.
537 // This can happen when a new framework registers with the master.
538 message FrameworkAdded {
539 required Response.GetFrameworks.Framework framework = 1 [(gogoproto.nullable) = false];
540 }
541
542 // Forwarded by the master when a framework re-registers with the master
543 // upon a disconnection (network error) or upon a master failover.
544 message FrameworkUpdated {
545 required Response.GetFrameworks.Framework framework = 1 [(gogoproto.nullable) = false];
546 }
547
548 // Forwarded by the master when a framework is removed. This can happen when
549 // a framework is explicitly teardown by the operator or if it fails to
550 // re-register with the master within the failover timeout.
551 message FrameworkRemoved {
552 required FrameworkInfo framework_info = 1 [(gogoproto.nullable) = false];
553 }
554
555 // Forwarded by the master when an agent becomes known to it.
556 // This can happen when an agent registered for the first
557 // time, or reregistered after a master failover.
558 message AgentAdded {
559 required Response.GetAgents.Agent agent = 1 [(gogoproto.nullable) = false];
560 }
561
562 // Forwarded by the master when an agent is removed. This
563 // can happen when the agent is scheduled for maintenance.
564 //
565 // NOTE: It's possible that an agent might become
566 // active once it has been removed, i.e. if the master
567 // has gc'ed its list of known "dead" agents.
568 // See MESOS-5965 for context.
569 message AgentRemoved {
570 required AgentID agent_id = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "AgentID"];
571 }
572
573 optional Type type = 1 [(gogoproto.nullable) = false];
574
575 optional Subscribed subscribed = 2;
576 optional TaskAdded task_added = 3;
577 optional TaskUpdated task_updated = 4;
578 optional AgentAdded agent_added = 5;
579 optional AgentRemoved agent_removed = 6;
580 optional FrameworkAdded framework_added = 7;
581 optional FrameworkUpdated framework_updated = 8;
582 optional FrameworkRemoved framework_removed = 9;
583 }