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