Skip to content

Commit

Permalink
deprecate startup_probe and liveness_probe fields from google_cloud_r…
Browse files Browse the repository at this point in the history
…un_v2_job resource (#7135) (#13531)

Signed-off-by: Modular Magician <magic-modules@google.com>

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician committed Jan 19, 2023
1 parent cec7ccc commit 46b96dc
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 336 deletions.
3 changes: 3 additions & 0 deletions .changelog/7135.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:deprecation
cloudrunv2: deprecated `startup_probe` and `liveness_probe` fields from `google_cloud_run_v2_job` resource as they are not supported by the API and they will be removed in a future major release
```
22 changes: 13 additions & 9 deletions google/resource_cloud_run_v2_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,12 @@ func resourceCloudRunV2Job() *schema.Resource {
},
},
"liveness_probe": {
Type: schema.TypeList,
Optional: true,
Description: `Periodic probe of container liveness. Container will be restarted if the probe fails. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes`,
MaxItems: 1,
Type: schema.TypeList,
Optional: true,
Deprecated: "Cloud Run Job does not support liveness probe and `liveness_probe` field will be removed in a future major release.",
Description: `Periodic probe of container liveness. Container will be restarted if the probe fails. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes
This field is not supported in Cloud Run Job currently.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"failure_threshold": {
Expand Down Expand Up @@ -269,11 +271,13 @@ If omitted, a port number will be chosen and passed to the container through the
},
},
"startup_probe": {
Type: schema.TypeList,
Computed: true,
Optional: true,
Description: `Startup probe of application within the container. All other probes are disabled if a startup probe is provided, until it succeeds. Container will not be added to service endpoints if the probe fails. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes`,
MaxItems: 1,
Type: schema.TypeList,
Computed: true,
Optional: true,
Deprecated: "Cloud Run Job does not support startup probe and `startup_probe` field will be removed in a future major release.",
Description: `Startup probe of application within the container. All other probes are disabled if a startup probe is provided, until it succeeds. Container will not be added to service endpoints if the probe fails. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes
This field is not supported in Cloud Run Job currently.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"failure_threshold": {
Expand Down
57 changes: 0 additions & 57 deletions google/resource_cloud_run_v2_job_generated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,63 +236,6 @@ resource "google_compute_network" "custom_test" {
`, context)
}

func TestAccCloudRunV2Job_cloudrunv2JobProbesExample(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"random_suffix": randString(t, 10),
}

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckCloudRunV2JobDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccCloudRunV2Job_cloudrunv2JobProbesExample(context),
},
{
ResourceName: "google_cloud_run_v2_job.default",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"name", "location"},
},
},
})
}

func testAccCloudRunV2Job_cloudrunv2JobProbesExample(context map[string]interface{}) string {
return Nprintf(`
resource "google_cloud_run_v2_job" "default" {
name = "tf-test-cloudrun-job%{random_suffix}"
location = "us-central1"
launch_stage = "BETA"
template {
template{
containers {
image = "us-docker.pkg.dev/cloudrun/container/hello"
startup_probe {
initial_delay_seconds = 0
timeout_seconds = 1
period_seconds = 3
failure_threshold = 1
tcp_socket {
port = 8080
}
}
liveness_probe {
http_get {
path = "/"
}
}
}
}
}
}
`, context)
}

func TestAccCloudRunV2Job_cloudrunv2JobSecretExample(t *testing.T) {
t.Parallel()

Expand Down
231 changes: 0 additions & 231 deletions google/resource_cloud_run_v2_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,234 +181,3 @@ resource "google_compute_network" "custom_test" {
}
`, context)
}

func TestAccCloudRunV2Job_cloudrunv2JobProbesUpdate(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"random_suffix": randString(t, 10),
}

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckCloudRunV2JobDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccCloudRunV2Job_cloudrunv2JobWithEmptyTCPStartupProbeAndHTTPLivenessProbe(context),
},
{
ResourceName: "google_cloud_run_v2_job.default",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"name", "location"},
},
{
Config: testAccCloudRunV2Job_cloudrunv2JobUpdateWithTCPStartupProbeAndHTTPLivenessProbe(context),
},
{
ResourceName: "google_cloud_run_v2_job.default",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"name", "location"},
},
{
Config: testAccCloudRunV2Job_cloudrunv2JobUpdateWithHTTPStartupProbeAndTCPLivenessProbe(context),
},
{
ResourceName: "google_cloud_run_v2_job.default",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"name", "location"},
},
{
Config: testAccCloudRunV2Job_cloudrunv2JobUpdateWithEmptyHTTPStartupProbe(context),
},
{
ResourceName: "google_cloud_run_v2_job.default",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"name", "location"},
},
{
Config: testAccCloudRunV2Job_cloudrunv2JobUpdateWithHTTPStartupProbe(context),
},
{
ResourceName: "google_cloud_run_v2_job.default",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"name", "location"},
},
},
})
}

func testAccCloudRunV2Job_cloudrunv2JobWithEmptyTCPStartupProbeAndHTTPLivenessProbe(context map[string]interface{}) string {
return Nprintf(`
resource "google_cloud_run_v2_job" "default" {
name = "tf-test-cloudrun-job%{random_suffix}"
location = "us-central1"
launch_stage = "BETA"
template {
template {
containers {
image = "us-docker.pkg.dev/cloudrun/container/hello"
ports {
container_port = 8080
}
startup_probe {
tcp_socket {}
}
liveness_probe {
http_get {}
}
}
}
}
}
`, context)
}

func testAccCloudRunV2Job_cloudrunv2JobUpdateWithTCPStartupProbeAndHTTPLivenessProbe(context map[string]interface{}) string {
return Nprintf(`
resource "google_cloud_run_v2_job" "default" {
name = "tf-test-cloudrun-job%{random_suffix}"
location = "us-central1"
launch_stage = "BETA"
template{
template {
containers {
image = "us-docker.pkg.dev/cloudrun/container/hello"
ports {
container_port = 8080
}
startup_probe {
initial_delay_seconds = 2
period_seconds = 1
timeout_seconds = 5
failure_threshold = 2
tcp_socket {
port = 8080
}
}
liveness_probe {
initial_delay_seconds = 2
period_seconds = 1
timeout_seconds = 5
failure_threshold = 2
http_get {
path = "/some-path"
http_headers {
name = "User-Agent"
value = "magic-modules"
}
http_headers {
name = "Some-Name"
}
}
}
}
}
}
}
`, context)
}

func testAccCloudRunV2Job_cloudrunv2JobUpdateWithHTTPStartupProbeAndTCPLivenessProbe(context map[string]interface{}) string {
return Nprintf(`
resource "google_cloud_run_v2_job" "default" {
name = "tf-test-cloudrun-job%{random_suffix}"
location = "us-central1"
launch_stage = "BETA"
template{
template {
containers {
image = "us-docker.pkg.dev/cloudrun/container/hello"
ports {
container_port = 8080
}
startup_probe {
initial_delay_seconds = 2
period_seconds = 1
timeout_seconds = 5
failure_threshold = 2
http_get {
path = "/some-path"
http_headers {
name = "User-Agent"
value = "magic-modules"
}
http_headers {
name = "Some-Name"
}
}
}
liveness_probe {
initial_delay_seconds = 2
period_seconds = 1
timeout_seconds = 5
failure_threshold = 2
tcp_socket {
port = 8080
}
}
}
}
}
}
`, context)
}

func testAccCloudRunV2Job_cloudrunv2JobUpdateWithEmptyHTTPStartupProbe(context map[string]interface{}) string {
return Nprintf(`
resource "google_cloud_run_v2_job" "default" {
name = "tf-test-cloudrun-job%{random_suffix}"
location = "us-central1"
launch_stage = "BETA"
template {
template {
containers {
image = "us-docker.pkg.dev/cloudrun/container/hello"
startup_probe {
http_get {}
}
}
}
}
}
`, context)
}

func testAccCloudRunV2Job_cloudrunv2JobUpdateWithHTTPStartupProbe(context map[string]interface{}) string {
return Nprintf(`
resource "google_cloud_run_v2_job" "default" {
name = "tf-test-cloudrun-job%{random_suffix}"
location = "us-central1"
launch_stage = "BETA"
template{
template {
containers {
image = "us-docker.pkg.dev/cloudrun/container/hello"
startup_probe {
http_get {
path = "/some-path"
http_headers {
name = "User-Agent"
value = "magic-modules"
}
http_headers {
name = "Some-Name"
}
}
}
}
}
}
}
`, context)
}
Loading

0 comments on commit 46b96dc

Please sign in to comment.