Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add nfs support to cloudrun v2 jobs in beta #10220

Merged
merged 2 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
bskaplan marked this conversation as resolved.
Show resolved Hide resolved
# 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 -%>