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

Added volume module for Google Cloud NetApp Volume #9513

Merged
merged 9 commits into from
Jan 12, 2024

Conversation

G-NamanGupta
Copy link
Contributor

@G-NamanGupta G-NamanGupta commented Nov 22, 2023

Fixes hashicorp/terraform-provider-google#16019

This PR is to support provisioning volume for Google Cloud NetApp Volumes through GCP terraform provider.

`google_netapp_volume`

This is extension to #9229

@modular-magician
Copy link
Collaborator

Hello! I am a robot. It looks like you are a: Community Contributor Googler Core Contributor. Tests will require approval to run.

@rileykarson, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look.

You can help make sure that review is quick by doing a self-review and by running impacted tests locally.

@modular-magician modular-magician added the awaiting-approval Pull requests that needs reviewer's approval to run presubmit tests label Nov 22, 2023
# limitations under the License.

--- !ruby/object:Api::Resource
name: 'volume'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: 'volume'
name: 'Volume'

- !ruby/object:Api::Type::String
name: 'name'
description:
The name of the volume. Needs to be unique per location.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The name of the volume. Needs to be unique per location.
The name of the volume. Needs to be unique per location.

url_param_only: true
examples:
- !ruby/object:Provider::Terraform::Examples
name: 'Volume_create'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: 'Volume_create'
name: 'volume_basic'
  • change the filename, we use _basic for the simple examples by convention!

base_url: projects/{{project}}/locations/{{location}}/volumes
self_link: projects/{{project}}/locations/{{location}}/volumes/{{name}}
create_url: projects/{{project}}/locations/{{location}}/volumes?volumeId={{name}}
update_url: projects/{{project}}/locations/{{location}}/volumes/{{name}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to add an update test! https://googlecloudplatform.github.io/magic-modules/develop/test/#add-an-update-test

Each updatable field should have its value changed in at least one test!

network_name: 'test-network'
global_name: 'test-address'
properties:
# Fields go here
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Fields go here

mmv1/products/netapp/volume.yaml Show resolved Hide resolved
mmv1/products/netapp/volume.yaml Show resolved Hide resolved
- !ruby/object:Api::Type::String
name: 'exportFull'
description: |
Full export ptah of the volume.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Full export ptah of the volume.
Full export path of the volume.

mmv1/products/netapp/volume.yaml Show resolved Hide resolved
immutable: true
properties:
- !ruby/object:Api::Type::String
name: 'sourceSnapshot'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

required: true? We can remove it if we add sourceBackup in the future.

@modular-magician modular-magician removed the awaiting-approval Pull requests that needs reviewer's approval to run presubmit tests label Nov 22, 2023
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 5 files changed, 2724 insertions(+), 2 deletions(-))
Terraform Beta: Diff ( 5 files changed, 2724 insertions(+), 2 deletions(-))
TF Conversion: Diff ( 1 file changed, 624 insertions(+))
TF OiCS: Diff ( 4 files changed, 148 insertions(+))

Missing test report

Your PR includes resource fields which are not covered by any test.

Resource: google_netapp_volume (1 total tests)
Please add an acceptance test which includes these fields. The test should include the following:

resource "google_netapp_volume" "primary" {
  export_policy {
    rules {
      access_type           = # value needed
      allowed_clients       = # value needed
      has_root_access       = # value needed
      kerberos5_read_only   = # value needed
      kerberos5_read_write  = # value needed
      kerberos5i_read_only  = # value needed
      kerberos5i_read_write = # value needed
      kerberos5p_read_only  = # value needed
      kerberos5p_read_write = # value needed
      nfsv3                 = # value needed
      nfsv4                 = # value needed
    }
  }
  restore_parameters {
    source_snapshot = # value needed
  }
  restricted_actions = # value needed
  snapshot_policy {
    daily_schedule {
      hour              = # value needed
      minute            = # value needed
      snapshots_to_keep = # value needed
    }
    enabled = # value needed
    hourly_schedule {
      minute            = # value needed
      snapshots_to_keep = # value needed
    }
    monthly_schedule {
      days_of_month     = # value needed
      hour              = # value needed
      minute            = # value needed
      snapshots_to_keep = # value needed
    }
    weekly_schedule {
      day               = # value needed
      hour              = # value needed
      minute            = # value needed
      snapshots_to_keep = # value needed
    }
  }
}

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3238
Passed tests 2906
Skipped tests: 330
Affected tests: 2

Action taken

Found 2 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccDataprocClusterIamPolicy|TestAccNetappvolume_volumeCreateExample

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$
TestAccDataprocClusterIamPolicy[Debug log]

Rerun these tests in REPLAYING mode to catch issues

$\textcolor{green}{\textsf{No issues found for passed tests after REPLAYING rerun.}}$


$\textcolor{red}{\textsf{Tests failed during RECORDING mode:}}$
TestAccNetappvolume_volumeCreateExample[Error message] [Debug log]

$\textcolor{red}{\textsf{Please fix these to complete your PR.}}$
View the build log or the debug log for each test

@G-NamanGupta
Copy link
Contributor Author

Hi @rileykarson, Thanks for all the suggestions. I'll update the code and will push it in some time.
Meantime, the error we are seeing here seems to be related to hashicorp/terraform-provider-google#16275. just to confirm can you please post the error logs?

@okrause
Copy link
Contributor

okrause commented Nov 28, 2023

Hi @rileykarson, Thanks for all the suggestions. I'll update the code and will push it in some time. Meantime, the error we are seeing here seems to be related to hashicorp/terraform-provider-google#16275. just to confirm can you please post the error logs?

Are we blocked by that? Can we use the workaround which was meanwhile mentioned in hashicorp/terraform-provider-google#16275? We need to move on!

@imrannayer
Copy link
Member

@G-NamanGupta any update on this?

@G-NamanGupta
Copy link
Contributor Author

@G-NamanGupta any update on this?

@imrannayer , we are working with google dev team to reach to a viable solution for the issue we are facing with VPC network.
Will update here once the approach is finalized.

network = google_compute_network.peering_network.id
}

# Create a private connection
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're gonna want to use a bootstrapping function here- @shuyama1 was looking into some pre-work required to use one for this case. Leaving this open until that's resolved.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#9598 is merged, which refactored the bootstrapping function BootstrapSharedServiceNetworkingConnection to allow using different services. Hopefully it unblocks the test here.

BootstrapSharedServiceNetworkingConnection(t, "YOUR_NETWORK_NAME", acctest.ServiceNetworkWithParentService("netapp.servicenetworking.goog")) is likely what you'll need in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the changes related to network, added update test and also did cosmetic changes asked by Riley.

@modular-magician modular-magician added the awaiting-approval Pull requests that needs reviewer's approval to run presubmit tests label Dec 11, 2023
Name of the Private Service Access allocated range. Inherited from storage pool.
output: true
- !ruby/object:Api::Type::String
name: 'storagePool'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems like it would be immutable? Can we test changing it if not?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Volumes can be assigned to a different storagePool in certain situations.
The condition set is complex and cannot be handled by the provider. Let the API return good or bad.
https://cloud.google.com/netapp/volumes/docs/configure-and-use/volumes/edit-volume
Summary: storagePool should be mutable. Test case: create two pools in same region with same parameters (VPC, AD, CMEK, LDAP), but differing service levels (premium and extreme). Reassign a volume from one to the other.

security_style = "UNIX"
kerberos_enabled = false
export_policy {
rules {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a second rule here?

access_type = "READ_ONLY"
allowed_clients = "0.0.0.0/0"
has_root_access = "true"
kerberos5_read_only = false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change the value of these booleans between the update steps?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has_root_access can be changed easily. All the kerberos parameters can only be changed it the volumes would be exported with Kerberos and that requires complex infrastructure to be in place in the test environment. Not realistic.

capacity_gib = "200"
share_name = "testshare"
storage_pool = google_netapp_storage_pool.default.name
protocols = ["NFSV3"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a protocol in this update?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Protocols setting is immutable. We should mark it immutable.

share_name = "testshare"
storage_pool = google_netapp_storage_pool.default.name
protocols = ["NFSV3"]
smb_settings = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we set some SMB settings in the initial step?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend:
SHOW_SNAPSHOT, SHOW_PREVIOUS_VERSIONS
I intentionally left away a few settings which I expect the API to set automatically during volume creation, like BROWSABLE, CHANGE_NOTIFY, OPLOCKS (and maybe more or less).
TF should expect that create returns some settings which the user didn't put in.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it again: smb_settings only apply to SMB volumes and SMb volumes cannot be created without an AD server in the test environment and setting up an AD server is pretty heavy weight and out of scope for the tests.
But please make sure a TF is prepared to receive back some default values from the create operation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it. If smb_settings isn't specified at create, API doesn't return smb_settings on subsequent reads. That means it doesn't return any unexpected default values.

storage_pool = google_netapp_storage_pool.default.name
protocols = ["NFSV3"]
smb_settings = []
unix_permissions = "0770"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
unix_permissions = "0770"
unix_permissions = "0740"

value= "pool"
}
description = "This is a test description"
snapshot_directory = false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change this value during the update?

minute = 1
snapshots_to_keep = 1
}
enabled = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a third update step where we disable the schedule?

description: |-
Set the day or days of the month to make a snapshot (1-31). Accepts a comma separated number of days. Defaults to '1'.
- !ruby/object:Api::Type::NestedObject
name: restoreParameters
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this appear in a test?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. This is a parameter for Volume Backup. The resources for backup (backupPolicies, backupVaults and backupVaults.backups) are new their creation is not scheduled yet.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we consider excluding this from implementation for now? We can implement it after the resources for backup are added to the provider since we can't test the creation of volume from backup and can not test if the feature is working or not for now.

@modular-magician modular-magician removed the awaiting-approval Pull requests that needs reviewer's approval to run presubmit tests label Dec 14, 2023
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 6 files changed, 3028 insertions(+), 2 deletions(-))
Terraform Beta: Diff ( 6 files changed, 3028 insertions(+), 2 deletions(-))
TF Conversion: Diff ( 1 file changed, 624 insertions(+))
TF OiCS: Diff ( 4 files changed, 130 insertions(+))

Missing test report

Your PR includes resource fields which are not covered by any test.

Resource: google_netapp_volume (4 total tests)
Please add an acceptance test which includes these fields. The test should include the following:

resource "google_netapp_volume" "primary" {
  restore_parameters {
    source_snapshot = # value needed
  }
}

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3295
Passed tests 2956
Skipped tests: 337
Affected tests: 2

Action taken

Found 2 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccNetappvolume_volumeCreateExample_update|TestAccNetappVolume_volumeBasicExample

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 10
Passed tests 8
Skipped tests: 0
Affected tests: 2

Click here to see the affected service packages
  • netapp

Action taken

Found 2 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccNetappVolume_volumeBasicExample|TestAccNetappVolume_volumeBasicExample_update

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{red}{\textsf{Tests failed during RECORDING mode:}}$
TestAccNetappVolume_volumeBasicExample[Error message] [Debug log]
TestAccNetappVolume_volumeBasicExample_update[Error message] [Debug log]

$\textcolor{red}{\textsf{Please fix these to complete your PR.}}$
View the build log or the debug log for each test

@shuyama1
Copy link
Member

@G-NamanGupta Tests failed with error Error creating storagePool: googleapi: Error 400: StoragePool creation is not allowed in this region. Discussed with the service team offline, it seems only us-east4 or us-west2 could be used for StoragePool creation besides us-central1. Let's try one of those and see if it works. Thanks

@modular-magician modular-magician added the awaiting-approval Pull requests that needs reviewer's approval to run presubmit tests label Jan 12, 2024
@okrause
Copy link
Contributor

okrause commented Jan 12, 2024

/gcbrun

@okrause
Copy link
Contributor

okrause commented Jan 12, 2024

Okay, I didn't expect my /gcbrun to work, but I had to test it anyway :D

@modular-magician modular-magician removed the awaiting-approval Pull requests that needs reviewer's approval to run presubmit tests label Jan 12, 2024
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 6 files changed, 2943 insertions(+), 2 deletions(-))
Terraform Beta: Diff ( 6 files changed, 2943 insertions(+), 2 deletions(-))
TF Conversion: Diff ( 1 file changed, 595 insertions(+))
TF OiCS: Diff ( 4 files changed, 121 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 10
Passed tests 8
Skipped tests: 0
Affected tests: 2

Click here to see the affected service packages
  • netapp

Action taken

Found 2 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccNetappVolume_volumeBasicExample|TestAccNetappVolume_volumeBasicExample_update

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$
TestAccNetappVolume_volumeBasicExample[Debug log]
TestAccNetappVolume_volumeBasicExample_update[Debug log]

Rerun these tests in REPLAYING mode to catch issues

$\textcolor{green}{\textsf{No issues found for passed tests after REPLAYING rerun.}}$


$\textcolor{green}{\textsf{All tests passed!}}$
View the build log or the debug log for each test

@okrause
Copy link
Contributor

okrause commented Jan 12, 2024

@shuyama1 Can you please have a look if the resource is fine now? Sorry for being pushy.

Copy link
Member

@shuyama1 shuyama1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@okrause
Copy link
Contributor

okrause commented Jan 12, 2024

@rileykarson @shuyama1 Many, many thanks for your help on getting this reviewed and merged. Very appreciated!

@imrannayer
Copy link
Member

@okrause is there any plan to add BackupConfig block to google_netapp_volume?
Thanks

bskaplan pushed a commit to bskaplan/magic-modules that referenced this pull request Jan 17, 2024
…rm#9513)

* added volume module

* Added updated function and network fix

* updated update test fields.

* updated unixPermissions field.

* updated test file for snapshot_policy

* updated description.
updated test file with basic example and function name.

* removed the *_UNSPECIFIED values for inputs
Default values for minutes, hours, days and day_of_week in snapshot block
Updated tests to incorporate suggestions by shuya
Fixes some indentation in tests
Updates some test to get better test coverage
commented restoreParamters as suggested by Shuya.

* updated tests to use us-west1 region

* updated region to us-west2
@okrause
Copy link
Contributor

okrause commented Jan 18, 2024

@okrause is there any plan to add BackupConfig block to google_netapp_volume? Thanks

We plan to add more features over time. backupConfig was blocked so far, since we didn't had resources for Backup Vault and Backup Policy. They are now merged. Adding backupConfig should be easy to do, but we may experience some problems to solve in the required test code due to associating/disassociating a volume from a vault. Need to take a closer look.

kylase pushed a commit to yuanchuankee/magic-modules that referenced this pull request Jan 21, 2024
…rm#9513)

* added volume module

* Added updated function and network fix

* updated update test fields.

* updated unixPermissions field.

* updated test file for snapshot_policy

* updated description.
updated test file with basic example and function name.

* removed the *_UNSPECIFIED values for inputs
Default values for minutes, hours, days and day_of_week in snapshot block
Updated tests to incorporate suggestions by shuya
Fixes some indentation in tests
Updates some test to get better test coverage
commented restoreParamters as suggested by Shuya.

* updated tests to use us-west1 region

* updated region to us-west2
balanaguharsha pushed a commit to balanaguharsha/magic-modules that referenced this pull request May 2, 2024
…rm#9513)

* added volume module

* Added updated function and network fix

* updated update test fields.

* updated unixPermissions field.

* updated test file for snapshot_policy

* updated description.
updated test file with basic example and function name.

* removed the *_UNSPECIFIED values for inputs
Default values for minutes, hours, days and day_of_week in snapshot block
Updated tests to incorporate suggestions by shuya
Fixes some indentation in tests
Updates some test to get better test coverage
commented restoreParamters as suggested by Shuya.

* updated tests to use us-west1 region

* updated region to us-west2
pengq-google pushed a commit to pengq-google/magic-modules that referenced this pull request May 21, 2024
…rm#9513)

* added volume module

* Added updated function and network fix

* updated update test fields.

* updated unixPermissions field.

* updated test file for snapshot_policy

* updated description.
updated test file with basic example and function name.

* removed the *_UNSPECIFIED values for inputs
Default values for minutes, hours, days and day_of_week in snapshot block
Updated tests to incorporate suggestions by shuya
Fixes some indentation in tests
Updates some test to get better test coverage
commented restoreParamters as suggested by Shuya.

* updated tests to use us-west1 region

* updated region to us-west2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants