Skip to content

Commit

Permalink
feat: added support for predeploy and postdeploy actions
Browse files Browse the repository at this point in the history
Users can now configure predeploy and postdeploy actions as a part of Deploy Hooks.

PiperOrigin-RevId: 551539532
  • Loading branch information
Google APIs authored and copybara-github committed Jul 27, 2023
1 parent 3f76966 commit c940ce2
Show file tree
Hide file tree
Showing 2 changed files with 175 additions and 4 deletions.
1 change: 1 addition & 0 deletions google/cloud/deploy/v1/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ load(

csharp_proto_library(
name = "deploy_csharp_proto",
extra_opts = [],
deps = [":deploy_proto"],
)

Expand Down
178 changes: 174 additions & 4 deletions google/cloud/deploy/v1/cloud_deploy.proto
Original file line number Diff line number Diff line change
Expand Up @@ -446,10 +446,32 @@ message Strategy {
}
}

// Predeploy contains the predeploy job configuration information.
message Predeploy {
// Optional. A sequence of skaffold custom actions to invoke during execution
// of the predeploy job.
repeated string actions = 1 [(google.api.field_behavior) = OPTIONAL];
}

// Postdeploy contains the postdeploy job configuration information.
message Postdeploy {
// Optional. A sequence of skaffold custom actions to invoke during execution
// of the postdeploy job.
repeated string actions = 1 [(google.api.field_behavior) = OPTIONAL];
}

// Standard represents the standard deployment strategy.
message Standard {
// Whether to verify a deployment.
bool verify = 1;

// Optional. Configuration for the predeploy job. If this is not configured,
// predeploy job will not be present.
Predeploy predeploy = 2 [(google.api.field_behavior) = OPTIONAL];

// Optional. Configuration for the postdeploy job. If this is not configured,
// postdeploy job will not be present.
Postdeploy postdeploy = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Canary represents the canary deployment strategy.
Expand Down Expand Up @@ -480,6 +502,14 @@ message CanaryDeployment {

// Whether to run verify tests after each percentage deployment.
bool verify = 2;

// Optional. Configuration for the predeploy job of the first phase. If this
// is not configured, predeploy job will not be present.
Predeploy predeploy = 3 [(google.api.field_behavior) = OPTIONAL];

// Optional. Configuration for the postdeploy job of the last phase. If this
// is not configured, postdeploy job will not be present.
Postdeploy postdeploy = 4 [(google.api.field_behavior) = OPTIONAL];
}

// CustomCanaryDeployment represents the custom canary deployment
Expand All @@ -505,6 +535,14 @@ message CustomCanaryDeployment {

// Whether to run verify tests after the deployment.
bool verify = 4;

// Optional. Configuration for the predeploy job of this phase. If this is
// not configured, predeploy job will not be present for this phase.
Predeploy predeploy = 5 [(google.api.field_behavior) = OPTIONAL];

// Optional. Configuration for the postdeploy job of this phase. If this is
// not configured, postdeploy job will not be present for this phase.
Postdeploy postdeploy = 6 [(google.api.field_behavior) = OPTIONAL];
}

// Required. Configuration for each phase in the canary deployment in the
Expand Down Expand Up @@ -918,6 +956,12 @@ message ExecutionConfig {

// Use for deployment verification.
VERIFY = 3;

// Use for predeploy job execution.
PREDEPLOY = 4;

// Use for postdeploy job execution.
POSTDEPLOY = 5;
}

// Required. Usages when this configuration should be applied.
Expand Down Expand Up @@ -1268,7 +1312,7 @@ message Release {

// Cloud Build is not available, either because it is not enabled or
// because Cloud Deploy has insufficient permissions. See [required
// permission](/deploy/docs/cloud-deploy-service-account#required_permissions).
// permission](https://cloud.google.com/deploy/docs/cloud-deploy-service-account#required_permissions).
CLOUD_BUILD_UNAVAILABLE = 1;

// The render operation did not complete successfully; check Cloud Build
Expand All @@ -1278,6 +1322,11 @@ message Release {
// Cloud Build failed to fulfill Cloud Deploy's request. See
// failure_message for additional details.
CLOUD_BUILD_REQUEST_FAILED = 3;

// The render operation did not complete successfully because the custom
// action required for predeploy or postdeploy was not found in the
// skaffold configuration. See failure_message for additional details.
CUSTOM_ACTION_NOT_FOUND = 5;
}

// Output only. The resource name of the Cloud Build `Build` object that is
Expand Down Expand Up @@ -1683,7 +1732,7 @@ message Rollout {

// Cloud Build is not available, either because it is not enabled or because
// Cloud Deploy has insufficient permissions. See [required
// permission](/deploy/docs/cloud-deploy-service-account#required_permissions).
// permission](https://cloud.google.com/deploy/docs/cloud-deploy-service-account#required_permissions).
CLOUD_BUILD_UNAVAILABLE = 1;

// The deploy operation did not complete successfully; check Cloud Build
Expand Down Expand Up @@ -1891,6 +1940,14 @@ message DeploymentJobs {

// Output only. The verify Job. Runs after a deploy if the deploy succeeds.
Job verify_job = 2 [(google.api.field_behavior) = OUTPUT_ONLY];

// Output only. The predeploy Job. This is the predeploy job in the phase.
// This is the first job of the phase.
Job predeploy_job = 3 [(google.api.field_behavior) = OUTPUT_ONLY];

// Output only. The postdeploy Job. This is the postdeploy job in the phase.
// This is the last job of the phase.
Job postdeploy_job = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// ChildRollouts job composition
Expand Down Expand Up @@ -1963,6 +2020,13 @@ message Job {
// Output only. A verify Job.
VerifyJob verify_job = 5 [(google.api.field_behavior) = OUTPUT_ONLY];

// Output only. A predeploy Job.
PredeployJob predeploy_job = 9 [(google.api.field_behavior) = OUTPUT_ONLY];

// Output only. A postdeploy Job.
PostdeployJob postdeploy_job = 10
[(google.api.field_behavior) = OUTPUT_ONLY];

// Output only. A createChildRollout Job.
CreateChildRolloutJob create_child_rollout_job = 6
[(google.api.field_behavior) = OUTPUT_ONLY];
Expand All @@ -1979,6 +2043,18 @@ message DeployJob {}
// A verify Job.
message VerifyJob {}

// A predeploy Job.
message PredeployJob {
// Output only. The custom actions that the predeploy Job executes.
repeated string actions = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// A postdeploy Job.
message PostdeployJob {
// Output only. The custom actions that the postdeploy Job executes.
repeated string actions = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// A createChildRollout Job.
message CreateChildRolloutJob {}

Expand Down Expand Up @@ -2297,6 +2373,14 @@ message JobRun {
VerifyJobRun verify_job_run = 10
[(google.api.field_behavior) = OUTPUT_ONLY];

// Output only. Information specific to a predeploy `JobRun`.
PredeployJobRun predeploy_job_run = 14
[(google.api.field_behavior) = OUTPUT_ONLY];

// Output only. Information specific to a postdeploy `JobRun`.
PostdeployJobRun postdeploy_job_run = 15
[(google.api.field_behavior) = OUTPUT_ONLY];

// Output only. Information specific to a createChildRollout `JobRun`.
CreateChildRolloutJobRun create_child_rollout_job_run = 12
[(google.api.field_behavior) = OUTPUT_ONLY];
Expand All @@ -2321,7 +2405,7 @@ message DeployJobRun {

// Cloud Build is not available, either because it is not enabled or because
// Cloud Deploy has insufficient permissions. See [Required
// permission](/deploy/docs/cloud-deploy-service-account#required_permissions).
// permission](https://cloud.google.com/deploy/docs/cloud-deploy-service-account#required_permissions).
CLOUD_BUILD_UNAVAILABLE = 1;

// The deploy operation did not complete successfully; check Cloud Build
Expand Down Expand Up @@ -2373,7 +2457,7 @@ message VerifyJobRun {

// Cloud Build is not available, either because it is not enabled or because
// Cloud Deploy has insufficient permissions. See [required
// permission](/deploy/docs/cloud-deploy-service-account#required_permissions).
// permission](https://cloud.google.com/deploy/docs/cloud-deploy-service-account#required_permissions).
CLOUD_BUILD_UNAVAILABLE = 1;

// The verify operation did not complete successfully; check Cloud Build
Expand Down Expand Up @@ -2417,6 +2501,92 @@ message VerifyJobRun {
string failure_message = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// PredeployJobRun contains information specific to a predeploy `JobRun`.
message PredeployJobRun {
// Well-known predeploy failures.
enum FailureCause {
// No reason for failure is specified.
FAILURE_CAUSE_UNSPECIFIED = 0;

// Cloud Build is not available, either because it is not enabled or because
// Cloud Deploy has insufficient permissions. See [required
// permission](https://cloud.google.com/deploy/docs/cloud-deploy-service-account#required_permissions).
CLOUD_BUILD_UNAVAILABLE = 1;

// The predeploy operation did not complete successfully; check Cloud Build
// logs.
EXECUTION_FAILED = 2;

// The predeploy build did not complete within the alloted time.
DEADLINE_EXCEEDED = 3;

// Cloud Build failed to fulfill Cloud Deploy's request. See failure_message
// for additional details.
CLOUD_BUILD_REQUEST_FAILED = 4;
}

// Output only. The resource name of the Cloud Build `Build` object that is
// used to execute the custom actions associated with the predeploy Job.
// Format is projects/{project}/locations/{location}/builds/{build}.
string build = 1 [
(google.api.field_behavior) = OUTPUT_ONLY,
(google.api.resource_reference) = {
type: "cloudbuild.googleapis.com/Build"
}
];

// Output only. The reason the predeploy failed. This will always be
// unspecified while the predeploy is in progress or if it succeeded.
FailureCause failure_cause = 2 [(google.api.field_behavior) = OUTPUT_ONLY];

// Output only. Additional information about the predeploy failure, if
// available.
string failure_message = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// PostdeployJobRun contains information specific to a postdeploy `JobRun`.
message PostdeployJobRun {
// Well-known postdeploy failures.
enum FailureCause {
// No reason for failure is specified.
FAILURE_CAUSE_UNSPECIFIED = 0;

// Cloud Build is not available, either because it is not enabled or because
// Cloud Deploy has insufficient permissions. See [required
// permission](https://cloud.google.com/deploy/docs/cloud-deploy-service-account#required_permissions).
CLOUD_BUILD_UNAVAILABLE = 1;

// The postdeploy operation did not complete successfully; check Cloud Build
// logs.
EXECUTION_FAILED = 2;

// The postdeploy build did not complete within the alloted time.
DEADLINE_EXCEEDED = 3;

// Cloud Build failed to fulfill Cloud Deploy's request. See failure_message
// for additional details.
CLOUD_BUILD_REQUEST_FAILED = 4;
}

// Output only. The resource name of the Cloud Build `Build` object that is
// used to execute the custom actions associated with the postdeploy Job.
// Format is projects/{project}/locations/{location}/builds/{build}.
string build = 1 [
(google.api.field_behavior) = OUTPUT_ONLY,
(google.api.resource_reference) = {
type: "cloudbuild.googleapis.com/Build"
}
];

// Output only. The reason the postdeploy failed. This will always be
// unspecified while the postdeploy is in progress or if it succeeded.
FailureCause failure_cause = 2 [(google.api.field_behavior) = OUTPUT_ONLY];

// Output only. Additional information about the postdeploy failure, if
// available.
string failure_message = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// CreateChildRolloutJobRun contains information specific to a
// createChildRollout `JobRun`.
message CreateChildRolloutJobRun {
Expand Down

0 comments on commit c940ce2

Please sign in to comment.