Skip to content

Commit a4c2343

Browse files
feat: [batch] added StatusEvent.task_state (#4042)
* feat: resource usage docs: update comments PiperOrigin-RevId: 513425559 Source-Link: googleapis/googleapis@2936faa Source-Link: googleapis/googleapis-gen@5219e27 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJhdGNoLy5Pd2xCb3QueWFtbCIsImgiOiI1MjE5ZTI3YmFlZWI2M2IyMDljNGYwZTljYTZjNjhlM2I2Njk4ZDY2In0= * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * feat: added StatusEvent.task_state docs: updated comments PiperOrigin-RevId: 513426000 Source-Link: googleapis/googleapis@3f95ea2 Source-Link: googleapis/googleapis-gen@b191b40 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJhdGNoLy5Pd2xCb3QueWFtbCIsImgiOiJiMTkxYjQwYjk1ZTQyZWVlYThkMGJjY2Y5MWRkMWQxYmE4YTYxZmIxIn0= * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: danieljbruce <[email protected]>
1 parent b01cab5 commit a4c2343

17 files changed

Lines changed: 941 additions & 1011 deletions

packages/google-cloud-batch/protos/google/cloud/batch/v1/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/v1/job.proto";
2424
import "google/cloud/batch/v1/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.V1";
@@ -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.

packages/google-cloud-batch/protos/google/cloud/batch/v1/job.proto

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

4848
// Priority of the Job.
49-
// The valid value range is [0, 100).
49+
// The valid value range is [0, 100). Default value is 0.
50+
// Higher value indicates higher priority.
5051
// A job with higher priority value is more likely to run earlier if all other
5152
// requirements are satisfied.
5253
int64 priority = 3;

packages/google-cloud-batch/protos/google/cloud/batch/v1/task.proto

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ message StatusEvent {
5555

5656
// Task Execution
5757
TaskExecution task_execution = 4;
58+
59+
// Task State
60+
TaskStatus.State task_state = 5;
5861
}
5962

6063
// This Task Execution field includes detail information for
@@ -140,9 +143,23 @@ message Runnable {
140143
message Script {
141144
oneof command {
142145
// Script file path on the host VM.
146+
//
147+
// To specify an interpreter, please add a `#!<interpreter>`(also known as
148+
// [shebang line](https://en.wikipedia.org/wiki/Shebang_(Unix))) as the
149+
// first line of the file.(For example, to execute the script using bash,
150+
// `#!/bin/bash` should be the first line of the file. To execute the
151+
// script using`Python3`, `#!/usr/bin/env python3` should be the first
152+
// line of the file.) Otherwise, the file will by default be excuted by
153+
// `/bin/sh`.
143154
string path = 1;
144155

145156
// Shell script text.
157+
//
158+
// To specify an interpreter, please add a `#!<interpreter>\n` at the
159+
// beginning of the text.(For example, to execute the script using bash,
160+
// `#!/bin/bash\n` should be added. To execute the script using`Python3`,
161+
// `#!/usr/bin/env python3\n` should be added.) Otherwise, the script will
162+
// by default be excuted by `/bin/sh`.
146163
string text = 2;
147164
}
148165
}
@@ -220,13 +237,12 @@ message TaskSpec {
220237
int32 max_retry_count = 5;
221238

222239
// Lifecycle management schema when any task in a task group is failed.
223-
// The valid size of lifecycle policies are [0, 10].
224-
// For each lifecycle policy, when the condition is met,
225-
// the action in that policy will execute.
226-
// If there are multiple policies that the task execution result matches,
227-
// we use the action from the first matched policy. If task execution result
228-
// does not meet with any of the defined lifecycle policy, we consider it as
229-
// the default policy. Default policy means if the exit code is 0, exit task.
240+
// Currently we only support one lifecycle policy.
241+
// When the lifecycle policy condition is met,
242+
// the action in the policy will execute.
243+
// If task execution result does not meet with the defined lifecycle
244+
// policy, we consider it as the default policy.
245+
// Default policy means if the exit code is 0, exit task.
230246
// If task ends with non-zero exit code, retry the task with max_retry_count.
231247
repeated LifecyclePolicy lifecycle_policies = 9;
232248

@@ -265,6 +281,10 @@ message LifecyclePolicy {
265281
}
266282

267283
// Action to execute when ActionCondition is true.
284+
// When RETRY_TASK is specified, we will retry failed tasks
285+
// if we notice any exit code match and fail tasks if no match is found.
286+
// Likewise, when FAIL_TASK is specified, we will fail tasks
287+
// if we notice any exit code match and retry tasks if no match is found.
268288
Action action = 1;
269289

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

packages/google-cloud-batch/protos/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.

packages/google-cloud-batch/protos/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.

packages/google-cloud-batch/protos/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)