From 0613861b7b7a73558022b0b70a268135509431e3 Mon Sep 17 00:00:00 2001 From: Benjamin Kaplan Date: Mon, 18 Mar 2024 12:06:43 -0700 Subject: [PATCH 1/2] add nfs support to cloudrun v2 jobs in beta --- mmv1/products/cloudrunv2/Job.yaml | 19 ++++++ .../resource_cloud_run_v2_job_test.go.erb | 64 +++++++++++++++++++ 2 files changed, 83 insertions(+) diff --git a/mmv1/products/cloudrunv2/Job.yaml b/mmv1/products/cloudrunv2/Job.yaml index 4daa40450fc6..1fef69316ce7 100644 --- a/mmv1/products/cloudrunv2/Job.yaml +++ b/mmv1/products/cloudrunv2/Job.yaml @@ -487,6 +487,25 @@ properties: name: 'readOnly' description: |- If true, mount this volume as read-only in all mounts. If false, mount this volume as read-write. + - !ruby/object:Api::Type::NestedObject + name: 'nfs' + description: |- + NFS share mounted as a volume. This feature requires the launch stage to be set to ALPHA or BETA. + min_version: beta + properties: + - !ruby/object:Api::Type::String + name: 'server' + required: true + description: |- + Hostname or IP address of the NFS server. + - !ruby/object:Api::Type::String + name: 'path' + description: |- + Path that is exported by the NFS server. + - !ruby/object:Api::Type::Boolean + name: 'readOnly' + description: |- + If true, mount this volume as read-only in all mounts. - !ruby/object:Api::Type::String name: 'timeout' description: |- diff --git a/mmv1/third_party/terraform/services/cloudrunv2/resource_cloud_run_v2_job_test.go.erb b/mmv1/third_party/terraform/services/cloudrunv2/resource_cloud_run_v2_job_test.go.erb index feca32ee81e7..c46a43fb3e51 100644 --- a/mmv1/third_party/terraform/services/cloudrunv2/resource_cloud_run_v2_job_test.go.erb +++ b/mmv1/third_party/terraform/services/cloudrunv2/resource_cloud_run_v2_job_test.go.erb @@ -386,4 +386,68 @@ func testAccCloudRunV2Job_cloudrunv2JobWithGcsVolume(context map[string]interfac } `, context) } + +func TestAccCloudRunV2Job_cloudrunv2JobWithNfsUpdate(t *testing.T) { + t.Parallel() + + jobName := fmt.Sprintf("tf-test-cloudrun-service%s", acctest.RandString(t, 10)) + context := map[string]interface{}{ + "job_name": jobName, + } + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + CheckDestroy: testAccCheckCloudRunV2JobDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccCloudRunV2Job_cloudrunv2JobWithNoVolume(context), + }, + { + ResourceName: "google_cloud_run_v2_job.default", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"location", "launch_stage"}, + }, + { + Config: testAccCloudRunV2Job_cloudrunv2JobWithNfsVolume(context), + }, + { + ResourceName: "google_cloud_run_v2_job.default", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"location", "launch_stage"}, + }, + }, + }) +} + +func testAccCloudRunV2Job_cloudrunv2JobWithNfsVolume(context map[string]interface{}) string { + return acctest.Nprintf(` + resource "google_cloud_run_v2_job" "default" { + name = "%{job_name}" + location = "us-central1" + launch_stage = "BETA" + template { + template { + containers { + image = "us-docker.pkg.dev/cloudrun/container/job" + volume_mounts { + name = "nfs" + mount_path = "/mnt/nfs" + } + } + volumes { + name = "nfs" + nfs { + server = "10.0.10.10" + path = "/" + read_only = true + } + } + } + } + } +`, context) +} <% end -%> From a17f802b563e34750b0cb5534117f7dd5be37587 Mon Sep 17 00:00:00 2001 From: Benjamin Kaplan Date: Wed, 27 Mar 2024 09:22:30 -0700 Subject: [PATCH 2/2] update commented-out one-of blocks for nfs volumes --- mmv1/products/cloudrunv2/Job.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mmv1/products/cloudrunv2/Job.yaml b/mmv1/products/cloudrunv2/Job.yaml index 1fef69316ce7..50bed7b9cff2 100644 --- a/mmv1/products/cloudrunv2/Job.yaml +++ b/mmv1/products/cloudrunv2/Job.yaml @@ -400,6 +400,7 @@ properties: # - template.0.template.0.volumes.0.cloudSqlInstance # - template.0.template.0.volumes.0.emptyDir # - template.0.volumes.0.gcs + # - template.0.volumes.0.nfs properties: - !ruby/object:Api::Type::String name: 'secret' @@ -439,6 +440,7 @@ properties: # - template.0.template.0.volumes.0.cloudSqlInstance # - template.0.template.0.volumes.0.emptyDir # - template.0.volumes.0.gcs + # - template.0.volumes.0.nfs properties: - !ruby/object:Api::Type::Array name: 'instances' @@ -455,6 +457,7 @@ properties: # - template.0.template.0.volumes.0.cloudSqlInstance # - template.0.template.0.volumes.0.emptyDir # - template.0.volumes.0.gcs + # - template.0.volumes.0.nfs properties: - !ruby/object:Api::Type::Enum name: 'medium' @@ -477,6 +480,7 @@ properties: # - template.0.volumes.0.cloudSqlInstance # - template.0.volumes.0.emptyDir # - template.0.volumes.0.gcs + # - template.0.volumes.0.nfs properties: - !ruby/object:Api::Type::String name: 'bucket' @@ -492,6 +496,12 @@ properties: description: |- NFS share mounted as a volume. This feature requires the launch stage to be set to ALPHA or BETA. min_version: beta + # exactly_one_of: + # - template.0.volumes.0.secret + # - template.0.volumes.0.cloudSqlInstance + # - template.0.volumes.0.emptyDir + # - template.0.volumes.0.gcs + # - template.0.volumes.0.nfs properties: - !ruby/object:Api::Type::String name: 'server'