Skip to content

Commit 778762c

Browse files
Google APIscopybara-github
authored andcommitted
feat: Adds Startup and Liveness probes to Cloud Run v2 API client libraries
For more information about this feature, visit https://cloud.google.com/run/docs/configuring/healthchecks PiperOrigin-RevId: 481203788
1 parent 9fba835 commit 778762c

5 files changed

Lines changed: 110 additions & 8 deletions

File tree

google/cloud/run/v2/BUILD.bazel

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ proto_library_with_info(
4949
deps = [
5050
":run_proto",
5151
"//google/cloud:common_resources_proto",
52+
"//google/cloud/location:location_proto",
5253
],
5354
)
5455

@@ -80,15 +81,18 @@ java_gapic_library(
8081
srcs = [":run_proto_with_info"],
8182
gapic_yaml = None,
8283
grpc_service_config = "run_grpc_service_config.json",
84+
rest_numeric_enums = False,
8385
service_yaml = "run_v2.yaml",
8486
test_deps = [
8587
":run_java_grpc",
88+
"//google/cloud/location:location_java_grpc",
8689
"//google/iam/v1:iam_java_grpc",
8790
],
8891
transport = "grpc+rest",
8992
deps = [
9093
":run_java_proto",
9194
"//google/api:api_java_proto",
95+
"//google/cloud/location:location_java_proto",
9296
"//google/iam/v1:iam_java_proto",
9397
],
9498
)
@@ -148,10 +152,12 @@ go_gapic_library(
148152
grpc_service_config = "run_grpc_service_config.json",
149153
importpath = "cloud.google.com/go/run/apiv2;run",
150154
metadata = True,
155+
rest_numeric_enums = False,
151156
service_yaml = "run_v2.yaml",
152157
transport = "grpc+rest",
153158
deps = [
154159
":run_go_proto",
160+
"//google/cloud/location:location_go_proto",
155161
"//google/iam/v1:iam_go_proto",
156162
"//google/longrunning:longrunning_go_proto",
157163
"@com_google_cloud_go//longrunning:go_default_library",
@@ -185,12 +191,14 @@ load(
185191
"@com_google_googleapis_imports//:imports.bzl",
186192
"py_gapic_assembly_pkg",
187193
"py_gapic_library",
194+
"py_test",
188195
)
189196

190197
py_gapic_library(
191198
name = "run_py_gapic",
192199
srcs = [":run_proto"],
193200
grpc_service_config = "run_grpc_service_config.json",
201+
rest_numeric_enums = False,
194202
service_yaml = "run_v2.yaml",
195203
transport = "grpc+rest",
196204
deps = [
@@ -242,6 +250,7 @@ php_gapic_library(
242250
name = "run_php_gapic",
243251
srcs = [":run_proto_with_info"],
244252
grpc_service_config = "run_grpc_service_config.json",
253+
rest_numeric_enums = False,
245254
service_yaml = "run_v2.yaml",
246255
deps = [
247256
":run_php_grpc",
@@ -275,6 +284,7 @@ nodejs_gapic_library(
275284
extra_protoc_parameters = ["metadata"],
276285
grpc_service_config = "run_grpc_service_config.json",
277286
package = "google.cloud.run.v2",
287+
rest_numeric_enums = False,
278288
service_yaml = "run_v2.yaml",
279289
deps = [],
280290
)
@@ -320,8 +330,10 @@ ruby_cloud_gapic_library(
320330
"ruby-cloud-wrapper-gem-override=google-cloud-run-client",
321331
],
322332
grpc_service_config = "run_grpc_service_config.json",
333+
rest_numeric_enums = False,
323334
ruby_cloud_description = "Cloud Run deploys and manages user provided container images that scale automatically based on incoming requests.",
324335
ruby_cloud_title = "Cloud Run V2",
336+
service_yaml = "run_v2.yaml",
325337
deps = [
326338
":run_ruby_grpc",
327339
":run_ruby_proto",
@@ -365,6 +377,7 @@ csharp_gapic_library(
365377
srcs = [":run_proto_with_info"],
366378
common_resources_config = "@gax_dotnet//:Google.Api.Gax/ResourceNames/CommonResourcesConfig.json",
367379
grpc_service_config = "run_grpc_service_config.json",
380+
rest_numeric_enums = False,
368381
service_yaml = "run_v2.yaml",
369382
deps = [
370383
":run_csharp_grpc",

google/cloud/run/v2/condition.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ message Condition {
162162
// A task reached its retry limit and the last attempt failed due to the
163163
// user container exiting with a non-zero exit code.
164164
NON_ZERO_EXIT_CODE = 2;
165+
166+
// The execution was cancelled by users.
167+
CANCELLED = 3;
165168
}
166169

167170
// type is used to communicate the status of the reconciliation process.

google/cloud/run/v2/k8s.min.proto

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,25 @@ message Container {
9393

9494
// Volume to mount into the container's filesystem.
9595
repeated VolumeMount volume_mounts = 8;
96+
97+
// Container's working directory.
98+
// If not specified, the container runtime's default will be used, which
99+
// might be configured in the container image.
100+
string working_dir = 9;
101+
102+
// Periodic probe of container liveness.
103+
// Container will be restarted if the probe fails.
104+
// More info:
105+
// https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes
106+
Probe liveness_probe = 10;
107+
108+
// Startup probe of application within the container.
109+
// All other probes are disabled if a startup probe is provided, until it
110+
// succeeds. Container will not be added to service endpoints if the probe
111+
// fails.
112+
// More info:
113+
// https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes
114+
Probe startup_probe = 11;
96115
}
97116

98117
// ResourceRequirements describes the compute resource requirements.
@@ -215,7 +234,7 @@ message SecretVolumeSource {
215234
repeated VersionToPath items = 2;
216235

217236
// Integer representation of mode bits to use on created files by default.
218-
// Must be a value between 0000 and 0777 (octal), defaulting to 0644.
237+
// Must be a value between 0000 and 0777 (octal), defaulting to 0444.
219238
// Directories within the path are not affected by this setting.
220239
//
221240
// Notes
@@ -272,3 +291,66 @@ message CloudSqlInstance {
272291
// {project}:{location}:{instance}
273292
repeated string instances = 1;
274293
}
294+
295+
// Probe describes a health check to be performed against a container to
296+
// determine whether it is alive or ready to receive traffic.
297+
message Probe {
298+
// Number of seconds after the container has started before the probe is
299+
// initiated.
300+
// Defaults to 0 seconds. Minimum value is 0. Maximum value for liveness probe
301+
// is 3600. Maximum value for startup probe is 240.
302+
// More info:
303+
// https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes
304+
int32 initial_delay_seconds = 1;
305+
306+
// Number of seconds after which the probe times out.
307+
// Defaults to 1 second. Minimum value is 1. Maximum value is 3600.
308+
// Must be smaller than period_seconds.
309+
// More info:
310+
// https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes
311+
int32 timeout_seconds = 2;
312+
313+
// How often (in seconds) to perform the probe.
314+
// Default to 10 seconds. Minimum value is 1. Maximum value for liveness probe
315+
// is 3600. Maximum value for startup probe is 240.
316+
// Must be greater or equal than timeout_seconds.
317+
int32 period_seconds = 3;
318+
319+
// Minimum consecutive failures for the probe to be considered failed after
320+
// having succeeded. Defaults to 3. Minimum value is 1.
321+
int32 failure_threshold = 4;
322+
323+
oneof probe_type {
324+
// HTTPGet specifies the http request to perform.
325+
// Exactly one of HTTPGet or TCPSocket must be specified.
326+
HTTPGetAction http_get = 5;
327+
328+
// TCPSocket specifies an action involving a TCP port.
329+
// Exactly one of HTTPGet or TCPSocket must be specified.
330+
TCPSocketAction tcp_socket = 6;
331+
}
332+
}
333+
334+
// HTTPGetAction describes an action based on HTTP Get requests.
335+
message HTTPGetAction {
336+
// Path to access on the HTTP server. Defaults to '/'.
337+
string path = 1;
338+
339+
// Custom headers to set in the request. HTTP allows repeated headers.
340+
repeated HTTPHeader http_headers = 4;
341+
}
342+
343+
// HTTPHeader describes a custom header to be used in HTTP probes
344+
message HTTPHeader {
345+
// Required. The header field name
346+
string name = 1 [(google.api.field_behavior) = REQUIRED];
347+
348+
// The header field value
349+
string value = 2;
350+
}
351+
352+
// TCPSocketAction describes an action based on opening a socket
353+
message TCPSocketAction {
354+
// Port number to access on the container. Must be in the range 1 to 65535.
355+
int32 port = 1;
356+
}

google/cloud/run/v2/run_v2.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ name: run.googleapis.com
44
title: Cloud Run Admin API
55

66
apis:
7+
- name: google.cloud.location.Locations
78
- name: google.cloud.run.v2.Revisions
89
- name: google.cloud.run.v2.Services
10+
- name: google.longrunning.Operations
911

1012
documentation:
1113
rules:

google/cloud/run/v2/service.proto

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,9 @@ service Services {
157157

158158
// Request message for creating a Service.
159159
message CreateServiceRequest {
160-
// Required. The location and project in which this service should be created.
161-
// Format: projects/{projectnumber}/locations/{location}
160+
// The location and project in which this service should be created.
161+
// Format: projects/{project}/locations/{location}
162+
// Only lowercase characters, digits, and hyphens.
162163
string parent = 1 [
163164
(google.api.field_behavior) = REQUIRED,
164165
(google.api.resource_reference) = {
@@ -169,8 +170,9 @@ message CreateServiceRequest {
169170
// Required. The Service instance to create.
170171
Service service = 2 [(google.api.field_behavior) = REQUIRED];
171172

172-
// Required. The unique identifier for the Service. The name of the service becomes
173-
// {parent}/services/{service_id}.
173+
// Required. The unique identifier for the Service. It must begin with letter,
174+
// and may not end with hyphen; must contain fewer than 50 characters.
175+
// The name of the service becomes {parent}/services/{service_id}.
174176
string service_id = 3 [(google.api.field_behavior) = REQUIRED];
175177

176178
// Indicates that the request should be validated and default values
@@ -197,7 +199,7 @@ message UpdateServiceRequest {
197199
message ListServicesRequest {
198200
// Required. The location and project to list resources on.
199201
// Location must be a valid GCP region, and may not be the "-" wildcard.
200-
// Format: projects/{projectnumber}/locations/{location}
202+
// Format: projects/{project}/locations/{location}
201203
string parent = 1 [
202204
(google.api.field_behavior) = REQUIRED,
203205
(google.api.resource_reference) = {
@@ -229,7 +231,7 @@ message ListServicesResponse {
229231
// Request message for obtaining a Service by its full name.
230232
message GetServiceRequest {
231233
// Required. The full name of the Service.
232-
// Format: projects/{projectnumber}/locations/{location}/services/{service}
234+
// Format: projects/{project}/locations/{location}/services/{service}
233235
string name = 1 [
234236
(google.api.field_behavior) = REQUIRED,
235237
(google.api.resource_reference) = {
@@ -241,7 +243,7 @@ message GetServiceRequest {
241243
// Request message to delete a Service by its full name.
242244
message DeleteServiceRequest {
243245
// Required. The full name of the Service.
244-
// Format: projects/{projectnumber}/locations/{location}/services/{service}
246+
// Format: projects/{project}/locations/{location}/services/{service}
245247
string name = 1 [
246248
(google.api.field_behavior) = REQUIRED,
247249
(google.api.resource_reference) = {

0 commit comments

Comments
 (0)