Skip to content

Commit

Permalink
add nfs support to cloudrun v2 jobs in beta (GoogleCloudPlatform#10220)
Browse files Browse the repository at this point in the history
  • Loading branch information
bskaplan authored and pengq-google committed May 21, 2024
1 parent c39121d commit d1e22fc
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
29 changes: 29 additions & 0 deletions mmv1/products/cloudrunv2/Job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand All @@ -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'
Expand All @@ -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'
Expand All @@ -487,6 +491,31 @@ 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
# 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'
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: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 -%>

0 comments on commit d1e22fc

Please sign in to comment.