This repository has been archived by the owner on Nov 29, 2023. It is now read-only.
/
autoscaling_policies.py
361 lines (293 loc) · 14.8 KB
/
autoscaling_policies.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
# -*- coding: utf-8 -*-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import proto # type: ignore
from google.protobuf import duration_pb2 # type: ignore
__protobuf__ = proto.module(
package="google.cloud.dataproc.v1",
manifest={
"AutoscalingPolicy",
"BasicAutoscalingAlgorithm",
"BasicYarnAutoscalingConfig",
"InstanceGroupAutoscalingPolicyConfig",
"CreateAutoscalingPolicyRequest",
"GetAutoscalingPolicyRequest",
"UpdateAutoscalingPolicyRequest",
"DeleteAutoscalingPolicyRequest",
"ListAutoscalingPoliciesRequest",
"ListAutoscalingPoliciesResponse",
},
)
class AutoscalingPolicy(proto.Message):
r"""Describes an autoscaling policy for Dataproc cluster
autoscaler.
Attributes:
id (str):
Required. The policy id.
The id must contain only letters (a-z, A-Z), numbers (0-9),
underscores (_), and hyphens (-). Cannot begin or end with
underscore or hyphen. Must consist of between 3 and 50
characters.
name (str):
Output only. The "resource name" of the autoscaling policy,
as described in
https://cloud.google.com/apis/design/resource_names.
- For ``projects.regions.autoscalingPolicies``, the
resource name of the policy has the following format:
``projects/{project_id}/regions/{region}/autoscalingPolicies/{policy_id}``
- For ``projects.locations.autoscalingPolicies``, the
resource name of the policy has the following format:
``projects/{project_id}/locations/{location}/autoscalingPolicies/{policy_id}``
basic_algorithm (google.cloud.dataproc_v1.types.BasicAutoscalingAlgorithm):
worker_config (google.cloud.dataproc_v1.types.InstanceGroupAutoscalingPolicyConfig):
Required. Describes how the autoscaler will
operate for primary workers.
secondary_worker_config (google.cloud.dataproc_v1.types.InstanceGroupAutoscalingPolicyConfig):
Optional. Describes how the autoscaler will
operate for secondary workers.
labels (Sequence[google.cloud.dataproc_v1.types.AutoscalingPolicy.LabelsEntry]):
Optional. The labels to associate with this autoscaling
policy. Label **keys** must contain 1 to 63 characters, and
must conform to `RFC
1035 <https://www.ietf.org/rfc/rfc1035.txt>`__. Label
**values** may be empty, but, if present, must contain 1 to
63 characters, and must conform to `RFC
1035 <https://www.ietf.org/rfc/rfc1035.txt>`__. No more than
32 labels can be associated with an autoscaling policy.
"""
id = proto.Field(proto.STRING, number=1,)
name = proto.Field(proto.STRING, number=2,)
basic_algorithm = proto.Field(
proto.MESSAGE, number=3, oneof="algorithm", message="BasicAutoscalingAlgorithm",
)
worker_config = proto.Field(
proto.MESSAGE, number=4, message="InstanceGroupAutoscalingPolicyConfig",
)
secondary_worker_config = proto.Field(
proto.MESSAGE, number=5, message="InstanceGroupAutoscalingPolicyConfig",
)
labels = proto.MapField(proto.STRING, proto.STRING, number=6,)
class BasicAutoscalingAlgorithm(proto.Message):
r"""Basic algorithm for autoscaling.
Attributes:
yarn_config (google.cloud.dataproc_v1.types.BasicYarnAutoscalingConfig):
Required. YARN autoscaling configuration.
cooldown_period (google.protobuf.duration_pb2.Duration):
Optional. Duration between scaling events. A scaling period
starts after the update operation from the previous event
has completed.
Bounds: [2m, 1d]. Default: 2m.
"""
yarn_config = proto.Field(
proto.MESSAGE, number=1, message="BasicYarnAutoscalingConfig",
)
cooldown_period = proto.Field(
proto.MESSAGE, number=2, message=duration_pb2.Duration,
)
class BasicYarnAutoscalingConfig(proto.Message):
r"""Basic autoscaling configurations for YARN.
Attributes:
graceful_decommission_timeout (google.protobuf.duration_pb2.Duration):
Required. Timeout for YARN graceful decommissioning of Node
Managers. Specifies the duration to wait for jobs to
complete before forcefully removing workers (and potentially
interrupting jobs). Only applicable to downscaling
operations.
Bounds: [0s, 1d].
scale_up_factor (float):
Required. Fraction of average YARN pending memory in the
last cooldown period for which to add workers. A scale-up
factor of 1.0 will result in scaling up so that there is no
pending memory remaining after the update (more aggressive
scaling). A scale-up factor closer to 0 will result in a
smaller magnitude of scaling up (less aggressive scaling).
See `How autoscaling
works <https://cloud.google.com/dataproc/docs/concepts/configuring-clusters/autoscaling#how_autoscaling_works>`__
for more information.
Bounds: [0.0, 1.0].
scale_down_factor (float):
Required. Fraction of average YARN pending memory in the
last cooldown period for which to remove workers. A
scale-down factor of 1 will result in scaling down so that
there is no available memory remaining after the update
(more aggressive scaling). A scale-down factor of 0 disables
removing workers, which can be beneficial for autoscaling a
single job. See `How autoscaling
works <https://cloud.google.com/dataproc/docs/concepts/configuring-clusters/autoscaling#how_autoscaling_works>`__
for more information.
Bounds: [0.0, 1.0].
scale_up_min_worker_fraction (float):
Optional. Minimum scale-up threshold as a fraction of total
cluster size before scaling occurs. For example, in a
20-worker cluster, a threshold of 0.1 means the autoscaler
must recommend at least a 2-worker scale-up for the cluster
to scale. A threshold of 0 means the autoscaler will scale
up on any recommended change.
Bounds: [0.0, 1.0]. Default: 0.0.
scale_down_min_worker_fraction (float):
Optional. Minimum scale-down threshold as a fraction of
total cluster size before scaling occurs. For example, in a
20-worker cluster, a threshold of 0.1 means the autoscaler
must recommend at least a 2 worker scale-down for the
cluster to scale. A threshold of 0 means the autoscaler will
scale down on any recommended change.
Bounds: [0.0, 1.0]. Default: 0.0.
"""
graceful_decommission_timeout = proto.Field(
proto.MESSAGE, number=5, message=duration_pb2.Duration,
)
scale_up_factor = proto.Field(proto.DOUBLE, number=1,)
scale_down_factor = proto.Field(proto.DOUBLE, number=2,)
scale_up_min_worker_fraction = proto.Field(proto.DOUBLE, number=3,)
scale_down_min_worker_fraction = proto.Field(proto.DOUBLE, number=4,)
class InstanceGroupAutoscalingPolicyConfig(proto.Message):
r"""Configuration for the size bounds of an instance group,
including its proportional size to other groups.
Attributes:
min_instances (int):
Optional. Minimum number of instances for this group.
Primary workers - Bounds: [2, max_instances]. Default: 2.
Secondary workers - Bounds: [0, max_instances]. Default: 0.
max_instances (int):
Required. Maximum number of instances for this group.
Required for primary workers. Note that by default, clusters
will not use secondary workers. Required for secondary
workers if the minimum secondary instances is set.
Primary workers - Bounds: [min_instances, ). Secondary
workers - Bounds: [min_instances, ). Default: 0.
weight (int):
Optional. Weight for the instance group, which is used to
determine the fraction of total workers in the cluster from
this instance group. For example, if primary workers have
weight 2, and secondary workers have weight 1, the cluster
will have approximately 2 primary workers for each secondary
worker.
The cluster may not reach the specified balance if
constrained by min/max bounds or other autoscaling settings.
For example, if ``max_instances`` for secondary workers is
0, then only primary workers will be added. The cluster can
also be out of balance when created.
If weight is not set on any instance group, the cluster will
default to equal weight for all groups: the cluster will
attempt to maintain an equal number of workers in each group
within the configured size bounds for each group. If weight
is set for one group only, the cluster will default to zero
weight on the unset group. For example if weight is set only
on primary workers, the cluster will use primary workers
only and no secondary workers.
"""
min_instances = proto.Field(proto.INT32, number=1,)
max_instances = proto.Field(proto.INT32, number=2,)
weight = proto.Field(proto.INT32, number=3,)
class CreateAutoscalingPolicyRequest(proto.Message):
r"""A request to create an autoscaling policy.
Attributes:
parent (str):
Required. The "resource name" of the region or location, as
described in
https://cloud.google.com/apis/design/resource_names.
- For ``projects.regions.autoscalingPolicies.create``, the
resource name of the region has the following format:
``projects/{project_id}/regions/{region}``
- For ``projects.locations.autoscalingPolicies.create``,
the resource name of the location has the following
format: ``projects/{project_id}/locations/{location}``
policy (google.cloud.dataproc_v1.types.AutoscalingPolicy):
Required. The autoscaling policy to create.
"""
parent = proto.Field(proto.STRING, number=1,)
policy = proto.Field(proto.MESSAGE, number=2, message="AutoscalingPolicy",)
class GetAutoscalingPolicyRequest(proto.Message):
r"""A request to fetch an autoscaling policy.
Attributes:
name (str):
Required. The "resource name" of the autoscaling policy, as
described in
https://cloud.google.com/apis/design/resource_names.
- For ``projects.regions.autoscalingPolicies.get``, the
resource name of the policy has the following format:
``projects/{project_id}/regions/{region}/autoscalingPolicies/{policy_id}``
- For ``projects.locations.autoscalingPolicies.get``, the
resource name of the policy has the following format:
``projects/{project_id}/locations/{location}/autoscalingPolicies/{policy_id}``
"""
name = proto.Field(proto.STRING, number=1,)
class UpdateAutoscalingPolicyRequest(proto.Message):
r"""A request to update an autoscaling policy.
Attributes:
policy (google.cloud.dataproc_v1.types.AutoscalingPolicy):
Required. The updated autoscaling policy.
"""
policy = proto.Field(proto.MESSAGE, number=1, message="AutoscalingPolicy",)
class DeleteAutoscalingPolicyRequest(proto.Message):
r"""A request to delete an autoscaling policy.
Autoscaling policies in use by one or more clusters will not be
deleted.
Attributes:
name (str):
Required. The "resource name" of the autoscaling policy, as
described in
https://cloud.google.com/apis/design/resource_names.
- For ``projects.regions.autoscalingPolicies.delete``, the
resource name of the policy has the following format:
``projects/{project_id}/regions/{region}/autoscalingPolicies/{policy_id}``
- For ``projects.locations.autoscalingPolicies.delete``,
the resource name of the policy has the following format:
``projects/{project_id}/locations/{location}/autoscalingPolicies/{policy_id}``
"""
name = proto.Field(proto.STRING, number=1,)
class ListAutoscalingPoliciesRequest(proto.Message):
r"""A request to list autoscaling policies in a project.
Attributes:
parent (str):
Required. The "resource name" of the region or location, as
described in
https://cloud.google.com/apis/design/resource_names.
- For ``projects.regions.autoscalingPolicies.list``, the
resource name of the region has the following format:
``projects/{project_id}/regions/{region}``
- For ``projects.locations.autoscalingPolicies.list``, the
resource name of the location has the following format:
``projects/{project_id}/locations/{location}``
page_size (int):
Optional. The maximum number of results to
return in each response. Must be less than or
equal to 1000. Defaults to 100.
page_token (str):
Optional. The page token, returned by a
previous call, to request the next page of
results.
"""
parent = proto.Field(proto.STRING, number=1,)
page_size = proto.Field(proto.INT32, number=2,)
page_token = proto.Field(proto.STRING, number=3,)
class ListAutoscalingPoliciesResponse(proto.Message):
r"""A response to a request to list autoscaling policies in a
project.
Attributes:
policies (Sequence[google.cloud.dataproc_v1.types.AutoscalingPolicy]):
Output only. Autoscaling policies list.
next_page_token (str):
Output only. This token is included in the
response if there are more results to fetch.
"""
@property
def raw_page(self):
return self
policies = proto.RepeatedField(
proto.MESSAGE, number=1, message="AutoscalingPolicy",
)
next_page_token = proto.Field(proto.STRING, number=2,)
__all__ = tuple(sorted(__protobuf__.manifest))