Skip to content

Commit 386f722

Browse files
Google APIscopybara-github
authored andcommitted
feat: added RPCs StopAirflowCommand, ExecuteAirflowCommand, PollAirflowCommand, DatabaseFailover, FetchDatabaseProperties
PiperOrigin-RevId: 540052133
1 parent 8637121 commit 386f722

3 files changed

Lines changed: 175 additions & 0 deletions

File tree

google/cloud/orchestration/airflow/service/v1beta1/composer_v1beta1.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ apis:
1010

1111
types:
1212
- name: google.cloud.orchestration.airflow.service.v1beta1.CheckUpgradeResponse
13+
- name: google.cloud.orchestration.airflow.service.v1beta1.DatabaseFailoverResponse
1314
- name: google.cloud.orchestration.airflow.service.v1beta1.ExecuteAirflowCommandResponse
15+
- name: google.cloud.orchestration.airflow.service.v1beta1.FetchDatabasePropertiesResponse
1416
- name: google.cloud.orchestration.airflow.service.v1beta1.LoadSnapshotResponse
1517
- name: google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata
1618
- name: google.cloud.orchestration.airflow.service.v1beta1.PollAirflowCommandResponse
1719
- name: google.cloud.orchestration.airflow.service.v1beta1.SaveSnapshotResponse
20+
- name: google.cloud.orchestration.airflow.service.v1beta1.StopAirflowCommandResponse
1821

1922
documentation:
2023
summary: Manages Apache Airflow environments on Google Cloud Platform.

google/cloud/orchestration/airflow/service/v1beta1/environments.proto

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,33 @@ service Environments {
121121
};
122122
}
123123

124+
// Executes Airflow CLI command.
125+
rpc ExecuteAirflowCommand(ExecuteAirflowCommandRequest)
126+
returns (ExecuteAirflowCommandResponse) {
127+
option (google.api.http) = {
128+
post: "/v1beta1/{environment=projects/*/locations/*/environments/*}:executeAirflowCommand"
129+
body: "*"
130+
};
131+
}
132+
133+
// Stops Airflow CLI command execution.
134+
rpc StopAirflowCommand(StopAirflowCommandRequest)
135+
returns (StopAirflowCommandResponse) {
136+
option (google.api.http) = {
137+
post: "/v1beta1/{environment=projects/*/locations/*/environments/*}:stopAirflowCommand"
138+
body: "*"
139+
};
140+
}
141+
142+
// Polls Airflow CLI command execution and fetches logs.
143+
rpc PollAirflowCommand(PollAirflowCommandRequest)
144+
returns (PollAirflowCommandResponse) {
145+
option (google.api.http) = {
146+
post: "/v1beta1/{environment=projects/*/locations/*/environments/*}:pollAirflowCommand"
147+
body: "*"
148+
};
149+
}
150+
124151
// Creates a snapshots of a Cloud Composer environment.
125152
//
126153
// As a result of this operation, snapshot of environment's state is stored
@@ -150,6 +177,27 @@ service Environments {
150177
metadata_type: "google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata"
151178
};
152179
}
180+
181+
// Triggers database failover (only for highly resilient environments).
182+
rpc DatabaseFailover(DatabaseFailoverRequest)
183+
returns (google.longrunning.Operation) {
184+
option (google.api.http) = {
185+
post: "/v1beta1/{environment=projects/*/locations/*/environments/*}:databaseFailover"
186+
body: "*"
187+
};
188+
option (google.longrunning.operation_info) = {
189+
response_type: "google.cloud.orchestration.airflow.service.v1beta1.DatabaseFailoverResponse"
190+
metadata_type: "google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata"
191+
};
192+
}
193+
194+
// Fetches database properties.
195+
rpc FetchDatabaseProperties(FetchDatabasePropertiesRequest)
196+
returns (FetchDatabasePropertiesResponse) {
197+
option (google.api.http) = {
198+
get: "/v1beta1/{environment=projects/*/locations/*/environments/*}:fetchDatabaseProperties"
199+
};
200+
}
153201
}
154202

155203
// Create a new environment.
@@ -364,6 +412,25 @@ message RestartWebServerRequest {
364412
string name = 1;
365413
}
366414

415+
// Execute Airflow Command request.
416+
message ExecuteAirflowCommandRequest {
417+
// The resource name of the environment in the form:
418+
// "projects/{projectId}/locations/{locationId}/environments/{environmentId}".
419+
string environment = 1;
420+
421+
// Airflow command.
422+
string command = 2;
423+
424+
// Airflow subcommand.
425+
string subcommand = 3;
426+
427+
// Parameters for the Airflow command/subcommand as an array of arguments.
428+
// It may contain positional arguments like `["my-dag-id"]`, key-value
429+
// parameters like `["--foo=bar"]` or `["--foo","bar"]`,
430+
// or other flags like `["-f"]`.
431+
repeated string parameters = 4;
432+
}
433+
367434
// Response to ExecuteAirflowCommandRequest.
368435
message ExecuteAirflowCommandResponse {
369436
// The unique ID of the command execution for polling.
@@ -379,6 +446,54 @@ message ExecuteAirflowCommandResponse {
379446
string error = 4;
380447
}
381448

449+
// Stop Airflow Command request.
450+
message StopAirflowCommandRequest {
451+
// The resource name of the environment in the form:
452+
// "projects/{projectId}/locations/{locationId}/environments/{environmentId}".
453+
string environment = 1;
454+
455+
// The unique ID of the command execution.
456+
string execution_id = 2;
457+
458+
// The name of the pod where the command is executed.
459+
string pod = 3;
460+
461+
// The namespace of the pod where the command is executed.
462+
string pod_namespace = 4;
463+
464+
// If true, the execution is terminated forcefully (SIGKILL). If false, the
465+
// execution is stopped gracefully, giving it time for cleanup.
466+
bool force = 5;
467+
}
468+
469+
// Response to StopAirflowCommandRequest.
470+
message StopAirflowCommandResponse {
471+
// Whether the execution is still running.
472+
bool is_done = 1;
473+
474+
// Output message from stopping execution request.
475+
repeated string output = 2;
476+
}
477+
478+
// Poll Airflow Command request.
479+
message PollAirflowCommandRequest {
480+
// The resource name of the environment in the form:
481+
// "projects/{projectId}/locations/{locationId}/environments/{environmentId}"
482+
string environment = 1;
483+
484+
// The unique ID of the command execution.
485+
string execution_id = 2;
486+
487+
// The name of the pod where the command is executed.
488+
string pod = 3;
489+
490+
// The namespace of the pod where the command is executed.
491+
string pod_namespace = 4;
492+
493+
// Line number from which new logs should be fetched.
494+
int32 next_line_number = 5;
495+
}
496+
382497
// Response to PollAirflowCommandRequest.
383498
message PollAirflowCommandResponse {
384499
// Contains information about a single line from logs.
@@ -460,6 +575,44 @@ message LoadSnapshotRequest {
460575
// Response to LoadSnapshotRequest.
461576
message LoadSnapshotResponse {}
462577

578+
// Request to trigger database failover (only for highly resilient
579+
// environments).
580+
message DatabaseFailoverRequest {
581+
// Target environment:
582+
// "projects/{projectId}/locations/{locationId}/environments/{environmentId}"
583+
string environment = 1;
584+
}
585+
586+
// Response for DatabaseFailoverRequest.
587+
message DatabaseFailoverResponse {}
588+
589+
// Request to fetch properties of environment's database.
590+
message FetchDatabasePropertiesRequest {
591+
// Required. The resource name of the environment, in the form:
592+
// "projects/{projectId}/locations/{locationId}/environments/{environmentId}"
593+
string environment = 1 [
594+
(google.api.field_behavior) = REQUIRED,
595+
(google.api.resource_reference) = {
596+
type: "composer.googleapis.com/Environment"
597+
}
598+
];
599+
}
600+
601+
// Response for FetchDatabasePropertiesRequest.
602+
message FetchDatabasePropertiesResponse {
603+
// The Compute Engine zone that the instance is currently serving from.
604+
string primary_gce_zone = 1;
605+
606+
// The Compute Engine zone that the failover instance is currently serving
607+
// from for a regional Cloud SQL instance.
608+
string secondary_gce_zone = 2;
609+
610+
// The availability status of the failover replica. A false status indicates
611+
// that the failover replica is out of sync. The primary instance can only
612+
// fail over to the failover replica when the status is true.
613+
bool is_failover_replica_available = 3;
614+
}
615+
463616
// Configuration information for an environment.
464617
message EnvironmentConfig {
465618
// The size of the Cloud Composer environment.
@@ -477,6 +630,15 @@ message EnvironmentConfig {
477630
ENVIRONMENT_SIZE_LARGE = 3;
478631
}
479632

633+
// Resilience mode of the Cloud Composer Environment.
634+
enum ResilienceMode {
635+
// Default mode doesn't change environment parameters.
636+
RESILIENCE_MODE_UNSPECIFIED = 0;
637+
638+
// Enabled High Resilience mode, including Cloud SQL HA.
639+
HIGH_RESILIENCE = 1;
640+
}
641+
480642
// Output only. The Kubernetes Engine cluster used to run this environment.
481643
string gke_cluster = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
482644

@@ -584,6 +746,12 @@ message EnvironmentConfig {
584746
// This field is supported for Cloud Composer environments in versions
585747
// composer-2.*.*-airflow-*.*.* and newer.
586748
RecoveryConfig recovery_config = 18 [(google.api.field_behavior) = OPTIONAL];
749+
750+
// Optional. Resilience mode of the Cloud Composer Environment.
751+
//
752+
// This field is supported for Cloud Composer environments in versions
753+
// composer-2.2.0-airflow-*.*.* and newer.
754+
ResilienceMode resilience_mode = 20 [(google.api.field_behavior) = OPTIONAL];
587755
}
588756

589757
// Network-level access control policy for the Airflow web server.

google/cloud/orchestration/airflow/service/v1beta1/operations.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ message OperationMetadata {
6565

6666
// Loads snapshot of the resource operation.
6767
LOAD_SNAPSHOT = 6;
68+
69+
// Triggers failover of environment's Cloud SQL instance (only for highly
70+
// resilient environments).
71+
DATABASE_FAILOVER = 7;
6872
}
6973

7074
// Output only. The current operation state.

0 commit comments

Comments
 (0)