Skip to content

Commit 2936faa

Browse files
Google APIscopybara-github
authored andcommitted
feat: resource usage
docs: update comments PiperOrigin-RevId: 513425559
1 parent dacdbc8 commit 2936faa

4 files changed

Lines changed: 53 additions & 50 deletions

File tree

google/cloud/batch/v1alpha/batch.proto

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import "google/api/resource.proto";
2323
import "google/cloud/batch/v1alpha/job.proto";
2424
import "google/cloud/batch/v1alpha/task.proto";
2525
import "google/longrunning/operations.proto";
26+
import "google/protobuf/empty.proto";
2627
import "google/protobuf/timestamp.proto";
2728

2829
option csharp_namespace = "Google.Cloud.Batch.V1Alpha";
@@ -124,8 +125,8 @@ message CreateJobRequest {
124125
// ignore the request if it has already been completed. The server will
125126
// guarantee that for at least 60 minutes since the first request.
126127
//
127-
// For example, consider a situation where you make an initial request and t
128-
// he request times out. If you make the request again with the same request
128+
// For example, consider a situation where you make an initial request and
129+
// the request times out. If you make the request again with the same request
129130
// ID, the server can check if original operation with the same request ID
130131
// was received, and if so, will ignore the second request. This prevents
131132
// clients from accidentally creating duplicate commitments.
@@ -157,8 +158,8 @@ message DeleteJobRequest {
157158
// ignore the request if it has already been completed. The server will
158159
// guarantee that for at least 60 minutes after the first request.
159160
//
160-
// For example, consider a situation where you make an initial request and t
161-
// he request times out. If you make the request again with the same request
161+
// For example, consider a situation where you make an initial request and
162+
// the request times out. If you make the request again with the same request
162163
// ID, the server can check if original operation with the same request ID
163164
// was received, and if so, will ignore the second request. This prevents
164165
// clients from accidentally creating duplicate commitments.

google/cloud/batch/v1alpha/batch_v1alpha.yaml

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ title: Batch API
66
apis:
77
- name: google.cloud.batch.v1alpha.BatchService
88
- name: google.cloud.location.Locations
9-
- name: google.iam.v1.IAMPolicy
109
- name: google.longrunning.Operations
1110

1211
types:
@@ -22,29 +21,6 @@ documentation:
2221
- selector: google.cloud.location.Locations.ListLocations
2322
description: Lists information about the supported locations for this service.
2423

25-
- selector: google.iam.v1.IAMPolicy.GetIamPolicy
26-
description: |-
27-
Gets the access control policy for a resource. Returns an empty policy
28-
if the resource exists and does not have a policy set.
29-
30-
- selector: google.iam.v1.IAMPolicy.SetIamPolicy
31-
description: |-
32-
Sets the access control policy on the specified resource. Replaces
33-
any existing policy.
34-
35-
Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
36-
errors.
37-
38-
- selector: google.iam.v1.IAMPolicy.TestIamPermissions
39-
description: |-
40-
Returns permissions that a caller has on the specified resource. If the
41-
resource does not exist, this will return an empty set of
42-
permissions, not a `NOT_FOUND` error.
43-
44-
Note: This operation is designed to be used for building
45-
permission-aware UIs and command-line tools, not for authorization
46-
checking. This operation may "fail open" without warning.
47-
4824
backend:
4925
rules:
5026
- selector: 'google.cloud.batch.v1alpha.BatchService.*'
@@ -53,8 +29,6 @@ backend:
5329
deadline: 60.0
5430
- selector: google.cloud.location.Locations.ListLocations
5531
deadline: 60.0
56-
- selector: 'google.iam.v1.IAMPolicy.*'
57-
deadline: 60.0
5832
- selector: 'google.longrunning.Operations.*'
5933
deadline: 60.0
6034

@@ -64,14 +38,6 @@ http:
6438
get: '/v1alpha/{name=projects/*/locations/*}'
6539
- selector: google.cloud.location.Locations.ListLocations
6640
get: '/v1alpha/{name=projects/*}/locations'
67-
- selector: google.iam.v1.IAMPolicy.GetIamPolicy
68-
get: '/v1alpha/{resource=projects/*/locations/*/jobs/*}:getIamPolicy'
69-
- selector: google.iam.v1.IAMPolicy.SetIamPolicy
70-
post: '/v1alpha/{resource=projects/*/locations/*/jobs/*}:setIamPolicy'
71-
body: '*'
72-
- selector: google.iam.v1.IAMPolicy.TestIamPermissions
73-
post: '/v1alpha/{resource=projects/*/locations/*/jobs/*}:testIamPermissions'
74-
body: '*'
7541
- selector: google.longrunning.Operations.CancelOperation
7642
post: '/v1alpha/{name=projects/*/locations/*/operations/*}:cancel'
7743
body: '*'
@@ -96,10 +62,6 @@ authentication:
9662
oauth:
9763
canonical_scopes: |-
9864
https://www.googleapis.com/auth/cloud-platform
99-
- selector: 'google.iam.v1.IAMPolicy.*'
100-
oauth:
101-
canonical_scopes: |-
102-
https://www.googleapis.com/auth/cloud-platform
10365
- selector: 'google.longrunning.Operations.*'
10466
oauth:
10567
canonical_scopes: |-

google/cloud/batch/v1alpha/job.proto

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ message Job {
5757
string uid = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
5858

5959
// Priority of the Job.
60-
// The valid value range is [0, 100).
60+
// The valid value range is [0, 100). Default value is 0.
61+
// Higher value indicates higher priority.
6162
// A job with higher priority value is more likely to run earlier if all other
6263
// requirements are satisfied.
6364
int64 priority = 3;
@@ -227,6 +228,15 @@ message JobStatus {
227228

228229
// The duration of time that the Job spent in status RUNNING.
229230
google.protobuf.Duration run_duration = 5;
231+
232+
// The resource usage of the job.
233+
ResourceUsage resource_usage = 6;
234+
}
235+
236+
// ResourceUsage describes the resource usage of the job.
237+
message ResourceUsage {
238+
// The CPU core hours that the job consumes.
239+
double core_hours = 1;
230240
}
231241

232242
// Notification configurations.

google/cloud/batch/v1alpha/task.proto

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ message StatusEvent {
6060

6161
// Task Execution
6262
TaskExecution task_execution = 4;
63+
64+
// Task State
65+
TaskStatus.State task_state = 5;
6366
}
6467

6568
// This Task Execution field includes detail information for
@@ -98,6 +101,16 @@ message TaskStatus {
98101

99102
// Detailed info about why the state is reached.
100103
repeated StatusEvent status_events = 2;
104+
105+
// The resource usage of the task.
106+
TaskResourceUsage resource_usage = 3;
107+
}
108+
109+
// TaskResourceUsage describes the resource usage of the task.
110+
message TaskResourceUsage {
111+
// The CPU core hours the task consumes based on task requirement and run
112+
// time.
113+
double core_hours = 1;
101114
}
102115

103116
// Runnable describes instructions for executing a specific script or container
@@ -145,9 +158,23 @@ message Runnable {
145158
message Script {
146159
oneof command {
147160
// Script file path on the host VM.
161+
//
162+
// To specify an interpreter, please add a `#!<interpreter>`(also known as
163+
// [shebang line](https://en.wikipedia.org/wiki/Shebang_(Unix))) as the
164+
// first line of the file.(For example, to execute the script using bash,
165+
// `#!/bin/bash` should be the first line of the file. To execute the
166+
// script using`Python3`, `#!/usr/bin/env python3` should be the first
167+
// line of the file.) Otherwise, the file will by default be excuted by
168+
// `/bin/sh`.
148169
string path = 1;
149170

150171
// Shell script text.
172+
//
173+
// To specify an interpreter, please add a `#!<interpreter>\n` at the
174+
// beginning of the text.(For example, to execute the script using bash,
175+
// `#!/bin/bash\n` should be added. To execute the script using`Python3`,
176+
// `#!/usr/bin/env python3\n` should be added.) Otherwise, the script will
177+
// by default be excuted by `/bin/sh`.
151178
string text = 2;
152179
}
153180
}
@@ -228,13 +255,12 @@ message TaskSpec {
228255
int32 max_retry_count = 5;
229256

230257
// Lifecycle management schema when any task in a task group is failed.
231-
// The valid size of lifecycle policies are [0, 10].
232-
// For each lifecycle policy, when the condition is met,
233-
// the action in that policy will execute.
234-
// If there are multiple policies that the task execution result matches,
235-
// we use the action from the first matched policy. If task execution result
236-
// does not meet with any of the defined lifecycle policy, we consider it as
237-
// the default policy. Default policy means if the exit code is 0, exit task.
258+
// Currently we only support one lifecycle policy.
259+
// When the lifecycle policy condition is met,
260+
// the action in the policy will execute.
261+
// If task execution result does not meet with the defined lifecycle
262+
// policy, we consider it as the default policy.
263+
// Default policy means if the exit code is 0, exit task.
238264
// If task ends with non-zero exit code, retry the task with max_retry_count.
239265
repeated LifecyclePolicy lifecycle_policies = 9;
240266

@@ -273,6 +299,10 @@ message LifecyclePolicy {
273299
}
274300

275301
// Action to execute when ActionCondition is true.
302+
// When RETRY_TASK is specified, we will retry failed tasks
303+
// if we notice any exit code match and fail tasks if no match is found.
304+
// Likewise, when FAIL_TASK is specified, we will fail tasks
305+
// if we notice any exit code match and retry tasks if no match is found.
276306
Action action = 1;
277307

278308
// Conditions that decide why a task failure is dealt with a specific action.

0 commit comments

Comments
 (0)