Apache Mesos
constants.hpp
Go to the documentation of this file.
1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements. See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership. The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License. You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 
17 #ifndef __MASTER_CONSTANTS_HPP__
18 #define __MASTER_CONSTANTS_HPP__
19 
20 #include <stdint.h>
21 
22 #include <mesos/mesos.hpp>
23 #include <mesos/quota/quota.hpp>
24 
25 #include <stout/bytes.hpp>
26 #include <stout/duration.hpp>
27 #include <stout/version.hpp>
28 
29 namespace mesos {
30 namespace internal {
31 namespace master {
32 
33 // TODO(benh): Add units after constants.
34 // TODO(benh): Also make configuration options be constants.
35 
36 // TODO(vinod): Move constants that are only used in flags to
37 // 'master/flags.hpp'.
38 
39 // TODO(jieyu): Use static functions for all the constants. See more
40 // details in MESOS-1023.
41 
42 // Maximum number of slot offers to have outstanding for each framework.
43 constexpr int MAX_OFFERS_PER_FRAMEWORK = 50;
44 
45 // Minimum number of cpus per offer.
46 constexpr double MIN_CPUS = 0.01;
47 
48 // Minimum amount of memory per offer.
49 constexpr Bytes MIN_MEM = Megabytes(32);
50 
51 // Default timeout for v0 framework and agent authentication
52 // before the master cancels an in-progress authentication.
53 //
54 // TODO(bmahler): Ideally, we remove this v0-style authentication
55 // in favor of just using HTTP authentication at the libprocess
56 // layer.
58 
59 // Default interval the master uses to send heartbeats to an HTTP
60 // scheduler.
62 
63 // Amount of time within which a slave PING should be received.
64 // NOTE: The slave uses these PING constants to determine when
65 // the master has stopped sending pings. If these are made
66 // configurable, then we'll need to rely on upper/lower bounds
67 // to ensure that the slave is not unnecessarily triggering
68 // re-registrations.
70 
71 // Maximum number of ping timeouts until slave is considered failed.
72 constexpr size_t DEFAULT_MAX_AGENT_PING_TIMEOUTS = 5;
73 
74 // The minimum timeout that can be used by a newly elected leader to
75 // allow re-registration of slaves. Any slaves that do not reregister
76 // within this timeout will be marked unreachable; if/when the agent
77 // reregisters, non-partition-aware tasks running on the agent will
78 // be terminated.
80 
81 // Default limit on the percentage of slaves that will be removed
82 // after recovering if no re-registration attempts were made.
83 // TODO(bmahler): There's no value here that works for all setups.
84 // Currently the default is 100% which is favorable to those running
85 // small clusters or experimenting with Mesos. However, it's important
86 // that we also prevent the catastrophic 100% removal case for
87 // production clusters. This TODO is to provide a --production flag
88 // which would allow flag defaults that are more appropriate for
89 // production use-cases.
90 constexpr double RECOVERY_AGENT_REMOVAL_PERCENT_LIMIT = 1.0; // 100%.
91 
92 // Maximum number of removed slaves to store in the cache.
93 constexpr size_t MAX_REMOVED_SLAVES = 100000;
94 
95 // Default maximum number of subscribers to the master's event stream
96 // to keep active at any time.
98 
99 // Default maximum number of completed frameworks to store in the cache.
100 constexpr size_t DEFAULT_MAX_COMPLETED_FRAMEWORKS = 50;
101 
102 // Default maximum number of completed tasks per framework
103 // to store in the cache.
105 
106 // Default maximum number of unreachable tasks per framework
107 // to store in the cache.
109 
110 // The minimum amount of time the master waits for a framework to reregister
111 // before the master adopts any operations originating from that
112 // framework. This applies to any framework not explicitly marked "completed"
113 // in the master's memory.
114 // Adopted operations will be acknowledged by the master.
116 
117 // Time interval to check for updated watchers list.
119 
120 // Default number of tasks (limit) for /master/tasks endpoint.
121 constexpr size_t TASK_LIMIT = 100;
122 
124 
126 
127 constexpr size_t DEFAULT_REGISTRY_MAX_AGENT_COUNT = 100 * 1024;
128 
134 constexpr char MASTER_INFO_LABEL[] = "info";
135 
141 constexpr char MASTER_INFO_JSON_LABEL[] = "json.info";
142 
143 // Timeout used for ZooKeeper related operations.
144 // TODO(vinod): Master detector/contender should use this timeout.
146 
147 // Name of the default, CRAM-MD5 authenticator.
148 constexpr char DEFAULT_AUTHENTICATOR[] = "crammd5";
149 
150 // Name of the default hierarchical allocator.
151 constexpr char DEFAULT_ALLOCATOR[] = "hierarchical";
152 
153 // The default interval between allocations.
155 
156 // Name of the default, local authorizer.
157 constexpr char DEFAULT_AUTHORIZER[] = "local";
158 
159 // Name of the master HTTP authentication realm for read-only endpoints.
161  "mesos-master-readonly";
162 
163 // Name of the master HTTP authentication realm for read-write endpoints.
165  "mesos-master-readwrite";
166 
167 // Name of the default authentication realm for HTTP frameworks.
169  "mesos-master-scheduler";
170 
171 // Agents older than this version are not allowed to register.
173 
174 std::vector<MasterInfo::Capability> MASTER_CAPABILITIES();
175 
176 // A role's default quota: no guarantees and no limits.
178 
179 // Default weight for a role.
180 constexpr double DEFAULT_WEIGHT = 1.0;
181 
182 // Default values for the `max_mem` option and the limit on `RE2::ProgramSize()`
183 // of RE2 regualr expressions used in offer constraints.
184 //
185 // As an example, for a regexp
186 // "192.168.(1[0-9]|3[4-7]|[1-9]|4[2-9]|[1-4][0-9]|5[3-8]|20[4-7]|53[0-5]).1"
187 // re2-2020-07-06 produces a RE2 object with a ProgramSize() of 54,
188 // and that can be successfully constructed only with `max_mem` >= 1499.
191 
192 } // namespace master {
193 } // namespace internal {
194 } // namespace mesos {
195 
196 #endif // __MASTER_CONSTANTS_HPP__
constexpr Bytes DEFAULT_OFFER_CONSTRAINTS_RE2_MAX_MEM
Definition: constants.hpp:189
Definition: master.hpp:27
constexpr int DEFAULT_OFFER_CONSTRAINTS_RE2_MAX_PROGRAM_SIZE
Definition: constants.hpp:190
constexpr Duration DEFAULT_HEARTBEAT_INTERVAL
Definition: constants.hpp:61
constexpr Bytes Megabytes(uint64_t value)
Definition: bytes.hpp:123
constexpr Duration DEFAULT_AGENT_PING_TIMEOUT
Definition: constants.hpp:69
constexpr Duration DEFAULT_AUTHENTICATION_V0_TIMEOUT
Definition: constants.hpp:57
constexpr Duration DEFAULT_REGISTRY_GC_INTERVAL
Definition: constants.hpp:123
constexpr double RECOVERY_AGENT_REMOVAL_PERCENT_LIMIT
Definition: constants.hpp:90
constexpr char MASTER_INFO_JSON_LABEL[]
Label used by the Leader Contender and Detector, for JSON content.
Definition: constants.hpp:141
constexpr char READWRITE_HTTP_AUTHENTICATION_REALM[]
Definition: constants.hpp:164
constexpr Duration ZOOKEEPER_SESSION_TIMEOUT
Definition: constants.hpp:145
constexpr double DEFAULT_WEIGHT
Definition: constants.hpp:180
Definition: duration.hpp:32
constexpr Duration DEFAULT_ALLOCATION_INTERVAL
Definition: constants.hpp:154
constexpr char READONLY_HTTP_AUTHENTICATION_REALM[]
Definition: constants.hpp:160
constexpr size_t TASK_LIMIT
Definition: constants.hpp:121
constexpr char DEFAULT_ALLOCATOR[]
Definition: constants.hpp:151
Definition: duration.hpp:221
Definition: duration.hpp:207
constexpr size_t DEFAULT_MAX_COMPLETED_TASKS_PER_FRAMEWORK
Definition: constants.hpp:104
Definition: agent.hpp:25
std::vector< MasterInfo::Capability > MASTER_CAPABILITIES()
constexpr char MASTER_INFO_LABEL[]
Label used by the Leader Contender and Detector.
Definition: constants.hpp:134
constexpr size_t DEFAULT_MAX_UNREACHABLE_TASKS_PER_FRAMEWORK
Definition: constants.hpp:108
constexpr Duration MIN_WAIT_BEFORE_ORPHAN_OPERATION_ADOPTION
Definition: constants.hpp:115
Definition: attributes.hpp:24
constexpr Duration MIN_AGENT_REREGISTER_TIMEOUT
Definition: constants.hpp:79
constexpr char DEFAULT_AUTHENTICATOR[]
Definition: constants.hpp:148
Definition: version.hpp:41
constexpr size_t MAX_REMOVED_SLAVES
Definition: constants.hpp:93
constexpr Duration DEFAULT_REGISTRY_MAX_AGENT_AGE
Definition: constants.hpp:125
constexpr char DEFAULT_AUTHORIZER[]
Definition: constants.hpp:157
constexpr char DEFAULT_HTTP_FRAMEWORK_AUTHENTICATION_REALM[]
Definition: constants.hpp:168
constexpr size_t DEFAULT_REGISTRY_MAX_AGENT_COUNT
Definition: constants.hpp:127
constexpr size_t DEFAULT_MAX_AGENT_PING_TIMEOUTS
Definition: constants.hpp:72
constexpr size_t DEFAULT_MAX_COMPLETED_FRAMEWORKS
Definition: constants.hpp:100
Definition: bytes.hpp:30
const Quota DEFAULT_QUOTA
Definition: constants.hpp:177
constexpr int MAX_OFFERS_PER_FRAMEWORK
Definition: constants.hpp:43
const Version MINIMUM_AGENT_VERSION
Definition: constants.hpp:172
constexpr Duration WHITELIST_WATCH_INTERVAL
Definition: constants.hpp:118
constexpr size_t DEFAULT_MAX_OPERATOR_EVENT_STREAM_SUBSCRIBERS
Definition: constants.hpp:97
Definition: quota.hpp:27
constexpr Bytes MIN_MEM
Definition: constants.hpp:49
Definition: duration.hpp:263
constexpr double MIN_CPUS
Definition: constants.hpp:46