Skip to content

add AutoTier support for netapp storagePools and Volumes #11645

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

Merged
merged 15 commits into from
Sep 12, 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
6 changes: 6 additions & 0 deletions mmv1/products/netapp/StoragePool.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,5 +161,11 @@ properties:
Specifies the replica zone for regional Flex pools. `zone` and `replica_zone` values can be swapped to initiate a
[zone switch](https://cloud.google.com/netapp/volumes/docs/configure-and-use/storage-pools/edit-or-delete-storage-pool#switch_active_and_replica_zones).
min_version: beta
- !ruby/object:Api::Type::Boolean
name: 'allowAutoTiering'
description: |
Optional. True if the storage pool supports Auto Tiering enabled volumes. Default is false.
Auto-tiering can be enabled after storage pool creation but it can't be disabled once enabled.
immutable: true
custom_code: !ruby/object:Provider::Terraform::CustomCode
pre_update: templates/terraform/pre_update/netapp_storagepool.go.erb
26 changes: 26 additions & 0 deletions mmv1/products/netapp/Volume.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -503,3 +503,29 @@ properties:
description: |
Optional. Flag indicating if the volume will have an IP address per node for volumes supporting multiple IP endpoints.
Only the volume with largeCapacity will be allowed to have multiple endpoints.
- !ruby/object:Api::Type::String
name: 'coldTierSizeGib'
description: |
Output only. Size of the volume cold tier data in GiB.
output: true
- !ruby/object:Api::Type::NestedObject
name: tieringPolicy
description: |-
Tiering policy for the volume.
update_mask_fields:
Copy link
Member

Choose a reason for hiding this comment

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

non-actionable: I'll flag that requiring this means an AIP is being broken, as the top-level field should have been sufficient: https://google.aip.dev/161#specifying-specific-fields

- 'tiering_policy.cooling_threshold_days'
- 'tiering_policy.tier_action'
properties:
- !ruby/object:Api::Type::Integer
name: 'coolingThresholdDays'
description: |
Optional. Time in days to mark the volume's data block as cold and make it eligible for tiering, can be range from 7-183.
Default is 31.
- !ruby/object:Api::Type::Enum
name: 'tierAction'
description: |
Optional. Flag indicating if the volume has tiering policy enable/pause. Default is PAUSED.
values:
- :ENABLED
- :PAUSED
default_value: :PAUSED
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,75 @@ resource "google_netapp_storage_pool" "test_pool" {
`, context)
}


func TestAccNetappStoragePool_autoTieredStoragePoolCreateExample_update(t *testing.T) {
context := map[string]interface{}{
"network_name": acctest.BootstrapSharedServiceNetworkingConnection(t, "gcnv-network-config-1", acctest.ServiceNetworkWithParentService("netapp.servicenetworking.goog")),
"random_suffix": acctest.RandString(t, 10),
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckNetappStoragePoolDestroyProducer(t),
ExternalProviders: map[string]resource.ExternalProvider{
"time": {},
},
Steps: []resource.TestStep{
{
Config: testAccNetappStoragePool_autoTieredStoragePoolCreateExample_full(context),
},
{
ResourceName: "google_netapp_storage_pool.test_pool",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"location", "name", "labels", "terraform_labels"},
},
},
})
}

func testAccNetappStoragePool_autoTieredStoragePoolCreateExample_full(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_compute_network" "peering_network" {
name = "tf-test-network%{random_suffix}"
}

# Create an IP address
resource "google_compute_global_address" "private_ip_alloc" {
name = "tf-test-address%{random_suffix}"
purpose = "VPC_PEERING"
address_type = "INTERNAL"
prefix_length = 16
network = google_compute_network.peering_network.id
}

# Create a private connection
resource "google_service_networking_connection" "default" {
network = google_compute_network.peering_network.id
service = "netapp.servicenetworking.goog"
reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name]
}

resource "google_netapp_storage_pool" "test_pool" {
name = "tf-test-pool%{random_suffix}"
location = "us-east4"
service_level = "PREMIUM"
capacity_gib = "2048"
network = google_compute_network.peering_network.id
active_directory = ""
description = "this is a test description"
kms_config = ""
labels = {
key= "test"
value= "pool"
}
ldap_enabled = false
allow_auto_tiering = true
}
`, context)
}

<% unless version == 'ga' -%>
func TestAccNetappStoragePool_FlexRegionalStoragePoolCreateExample_update(t *testing.T) {
context := map[string]interface{}{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ resource "google_netapp_storage_pool" "default" {
capacity_gib = "2048"
network = data.google_compute_network.default.id
}

resource "google_netapp_storage_pool" "default2" {
name = "tf-test-pool%{random_suffix}"
location = "us-west2"
Expand Down Expand Up @@ -659,3 +658,97 @@ func testAccNetappVolume_volumeBasicExample_cleanupScheduledBackup(t *testing.T,
return nil
}
}

func TestAccNetappVolume_autoTieredNetappVolume_update(t *testing.T) {
context := map[string]interface{}{
"network_name": acctest.BootstrapSharedServiceNetworkingConnection(t, "gcnv-network-config-1", acctest.ServiceNetworkWithParentService("netapp.servicenetworking.goog")),
"random_suffix": acctest.RandString(t, 10),
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckNetappVolumeDestroyProducer(t),
ExternalProviders: map[string]resource.ExternalProvider{
"time": {},
},
Steps: []resource.TestStep{
{
Config: testAccNetappVolume_autoTieredVolume_default(context),
},
{
ResourceName: "google_netapp_volume.test_volume",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"restore_parameters", "location", "name", "deletion_policy", "labels", "terraform_labels"},
},
{
Config: testAccNetappVolume_autoTieredVolume_custom(context),
},
{
ResourceName: "google_netapp_volume.test_volume",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"restore_parameters", "location", "name", "deletion_policy", "labels", "terraform_labels"},
},
},
})
}

func testAccNetappVolume_autoTieredVolume_default(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_netapp_storage_pool" "default" {
name = "tf-test-pool%{random_suffix}"
location = "us-west2"
service_level = "PREMIUM"
capacity_gib = "2048"
network = data.google_compute_network.default.id
allow_auto_tiering = true
}
resource "google_netapp_volume" "test_volume" {
location = "us-west2"
name = "tf-test-volume%{random_suffix}"
capacity_gib = "100"
share_name = "tf-test-volume%{random_suffix}"
storage_pool = google_netapp_storage_pool.default.name
protocols = ["NFSV3"]
tiering_policy {
cooling_threshold_days = 31
tier_action = "ENABLED"
}
}
data "google_compute_network" "default" {
name = "%{network_name}"
}
`, context)
}

func testAccNetappVolume_autoTieredVolume_custom(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_netapp_storage_pool" "default" {
name = "tf-test-pool%{random_suffix}"
location = "us-west2"
service_level = "PREMIUM"
capacity_gib = "2048"
network = data.google_compute_network.default.id
allow_auto_tiering = true
}

resource "google_netapp_volume" "test_volume" {
location = "us-west2"
name = "tf-test-volume%{random_suffix}"
capacity_gib = "100"
share_name = "tf-test-volume%{random_suffix}"
storage_pool = google_netapp_storage_pool.default.name
protocols = ["NFSV3"]
tiering_policy {
cooling_threshold_days = 20
tier_action = "ENABLED"
}
}

data "google_compute_network" "default" {
name = "%{network_name}"
}
`, context)
}