diff --git a/.changelog/7425.txt b/.changelog/7425.txt new file mode 100644 index 00000000000..e19b12cd7ed --- /dev/null +++ b/.changelog/7425.txt @@ -0,0 +1,6 @@ +```release-note:breaking-change +cloudrunv2: set a default value of 3 for `max_retries` in `google_cloud_run_v2_job`. This should match the API's existing default, but may show a diff at plan time +``` +```release-note:bug +cloudrunv2: fixed the bug where setting `max_retries` to 0 in `google_cloud_run_v2_job` was not respected. +``` diff --git a/google/resource_cloud_run_v2_job.go b/google/resource_cloud_run_v2_job.go index c8b6a46177a..2c6cfa7a850 100644 --- a/google/resource_cloud_run_v2_job.go +++ b/google/resource_cloud_run_v2_job.go @@ -400,9 +400,9 @@ This field is not supported in Cloud Run Job currently.`, }, "max_retries": { Type: schema.TypeInt, - Computed: true, Optional: true, Description: `Number of retries allowed per Task, before marking this Task failed.`, + Default: 3, }, "service_account": { Type: schema.TypeString, @@ -2278,7 +2278,7 @@ func expandCloudRunV2JobTemplateTemplate(v interface{}, d TerraformResourceData, transformedMaxRetries, err := expandCloudRunV2JobTemplateTemplateMaxRetries(original["max_retries"], d, config) if err != nil { return nil, err - } else if val := reflect.ValueOf(transformedMaxRetries); val.IsValid() && !isEmptyValue(val) { + } else { transformed["maxRetries"] = transformedMaxRetries } diff --git a/google/resource_cloud_run_v2_job_test.go b/google/resource_cloud_run_v2_job_test.go index 1a365e1343a..311c87c87a4 100644 --- a/google/resource_cloud_run_v2_job_test.go +++ b/google/resource_cloud_run_v2_job_test.go @@ -157,7 +157,7 @@ resource "google_cloud_run_v2_job" "default" { connector = google_vpc_access_connector.connector.id egress = "ALL_TRAFFIC" } - max_retries = 2 + max_retries = 0 } }