From c1b31679458e3660569016d11e5d5a14d7b29f26 Mon Sep 17 00:00:00 2001 From: bhpratt Date: Fri, 18 Nov 2022 10:32:17 -0500 Subject: [PATCH 1/5] fix struct size and force new for hostlabels --- ibm/flex/structures.go | 2 +- .../satellite/resource_ibm_satellite_cluster_worker_pool.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ibm/flex/structures.go b/ibm/flex/structures.go index 72b9f62116..a4c743ae2f 100644 --- a/ibm/flex/structures.go +++ b/ibm/flex/structures.go @@ -3348,7 +3348,7 @@ func FlattenSatelliteHosts(hostList []kubernetesserviceapiv1.MultishiftQueueNode } func FlattenWorkerPoolHostLabels(hostLabels map[string]string) *schema.Set { - mapped := make([]string, len(hostLabels)) + mapped := make([]string, len(hostLabels)-1) idx := 0 for k, v := range hostLabels { if strings.HasPrefix(k, "os") { diff --git a/ibm/service/satellite/resource_ibm_satellite_cluster_worker_pool.go b/ibm/service/satellite/resource_ibm_satellite_cluster_worker_pool.go index e61b53c68c..e94f270b59 100644 --- a/ibm/service/satellite/resource_ibm_satellite_cluster_worker_pool.go +++ b/ibm/service/satellite/resource_ibm_satellite_cluster_worker_pool.go @@ -150,6 +150,7 @@ func ResourceIBMSatelliteClusterWorkerPool() *schema.Resource { Type: schema.TypeSet, Optional: true, Computed: true, + ForceNew: true, Elem: &schema.Schema{Type: schema.TypeString}, Set: flex.ResourceIBMVPCHash, Description: "Labels that describe a Satellite host", From 4698f40650353546d1c3726d1a7d7566740a506d Mon Sep 17 00:00:00 2001 From: bhpratt Date: Fri, 18 Nov 2022 12:35:15 -0500 Subject: [PATCH 2/5] update docs to clarify usage of host label --- website/docs/r/satellite_cluster.html.markdown | 2 +- .../docs/r/satellite_cluster_worker_pool.html.markdown | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/website/docs/r/satellite_cluster.html.markdown b/website/docs/r/satellite_cluster.html.markdown index 25bce4ca6b..800b36fb55 100644 --- a/website/docs/r/satellite_cluster.html.markdown +++ b/website/docs/r/satellite_cluster.html.markdown @@ -53,7 +53,7 @@ Review the argument references that you can specify for your resource. - `zones` - (Optional, Array of Strings) The name of the zones to create the default worker pool. - `worker_count` - (Optional, String) The number of worker nodes to create per zone in the default worker pool. - `enable_config_admin` - (Optional, Bool) User provided value to indicate opt-in agreement to SatCon admin agent. -- `host_labels` - (Optional, Array of Strings) Key-value pairs to label the host, such as `cpu=4` to describe the host capabilities. +- `host_labels` - (Optional, Set(Strings)) Labels to add to the default worker pool, formatted as `cpu:4` key-value pairs. Satellite uses host labels to automatically assign hosts to worker pools with matching labels. - `default_worker_pool_labels` - (Optional, String) The labels on all the workers in the default worker pool. - `pull_secret` - (Optional, String) The Red Hat pull secret to create the OpenShift cluster. - `zone` - (Optional, List) The zone for the worker pool in a multi-zone cluster. diff --git a/website/docs/r/satellite_cluster_worker_pool.html.markdown b/website/docs/r/satellite_cluster_worker_pool.html.markdown index 8642361885..72bd27c701 100644 --- a/website/docs/r/satellite_cluster_worker_pool.html.markdown +++ b/website/docs/r/satellite_cluster_worker_pool.html.markdown @@ -61,19 +61,21 @@ Review the argument references that you can specify for your resource. - `name` - (Required, Forces new resource, String) The name of the worker pool. - `cluster` - (Required, Forces new resource, String) The name or id of the cluster. +- `entitlement` - (Optional, String) The openshift cluster entitlement avoids the OCP licence charges incurred. Use cloud paks with OCP Licence entitlement to add the Openshift cluster worker pool. - `operating_system` - (Optional, String) Operating system of the worker pool. Options are REDHAT_7_64, REDHAT_8_64, or RHCOS. - `worker_count` - (Optional, Integer) The number of worker nodes per zone in the worker pool. - `flavor` - (Optional, String) The flavor defines the amount of virtual CPU, memory, and disk space that is set up in each worker node. - `isolation` - (Optional, String) Isolation for the worker node. - `disk_encryption` - (Optional, String) Disk encryption for worker node. +- `host_labels` - (Optional, Set(Strings)) Labels to add to the worker pool, formatted as `cpu:4` key-value pairs. Satellite uses host labels to automatically assign hosts to worker pools with matching labels. +- `worker_pool_labels` - Labels on all the workers in the worker pool. + - `zones` - (Required, List) A nested block describing the zones of this worker_pool. Nested scheme for `zones`: - `id` - (Required, String) The name of the zone. -- `host_labels` - (Optional, Array of Strings) Key-value pairs to label the host, such as cpu=4 to describe the host capabilities. -- `worker_pool_labels` - Labels on all the workers in the worker pool. - `resource_group_id` - (Optional, Forces new resource, String) The ID of the resource group. You can retrieve the value from data source -- `entitlement` - (Optional, String) The openshift cluster entitlement avoids the OCP licence charges incurred. Use cloud paks with OCP Licence entitlement to add the Openshift cluster worker pool. + ## Attribute reference From 34187ba31f8bc315f14ab16fda4bde8d60a65134 Mon Sep 17 00:00:00 2001 From: bhpratt Date: Fri, 18 Nov 2022 12:37:19 -0500 Subject: [PATCH 3/5] return ordering of doc --- website/docs/r/satellite_cluster_worker_pool.html.markdown | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/website/docs/r/satellite_cluster_worker_pool.html.markdown b/website/docs/r/satellite_cluster_worker_pool.html.markdown index 72bd27c701..225ce7ff21 100644 --- a/website/docs/r/satellite_cluster_worker_pool.html.markdown +++ b/website/docs/r/satellite_cluster_worker_pool.html.markdown @@ -61,21 +61,18 @@ Review the argument references that you can specify for your resource. - `name` - (Required, Forces new resource, String) The name of the worker pool. - `cluster` - (Required, Forces new resource, String) The name or id of the cluster. -- `entitlement` - (Optional, String) The openshift cluster entitlement avoids the OCP licence charges incurred. Use cloud paks with OCP Licence entitlement to add the Openshift cluster worker pool. - `operating_system` - (Optional, String) Operating system of the worker pool. Options are REDHAT_7_64, REDHAT_8_64, or RHCOS. - `worker_count` - (Optional, Integer) The number of worker nodes per zone in the worker pool. - `flavor` - (Optional, String) The flavor defines the amount of virtual CPU, memory, and disk space that is set up in each worker node. - `isolation` - (Optional, String) Isolation for the worker node. - `disk_encryption` - (Optional, String) Disk encryption for worker node. -- `host_labels` - (Optional, Set(Strings)) Labels to add to the worker pool, formatted as `cpu:4` key-value pairs. Satellite uses host labels to automatically assign hosts to worker pools with matching labels. -- `worker_pool_labels` - Labels on all the workers in the worker pool. - - `zones` - (Required, List) A nested block describing the zones of this worker_pool. Nested scheme for `zones`: - `id` - (Required, String) The name of the zone. +- `host_labels` - (Optional, Set(Strings)) Labels to add to the worker pool, formatted as `cpu:4` key-value pairs. Satellite uses host labels to automatically assign hosts to worker pools with matching labels.- `worker_pool_labels` - Labels on all the workers in the worker pool. - `resource_group_id` - (Optional, Forces new resource, String) The ID of the resource group. You can retrieve the value from data source - +- `entitlement` - (Optional, String) The openshift cluster entitlement avoids the OCP licence charges incurred. Use cloud paks with OCP Licence entitlement to add the Openshift cluster worker pool. ## Attribute reference From 17c9c3e9a97dd1714674356fdc9c2d8a76d7163a Mon Sep 17 00:00:00 2001 From: bhpratt Date: Fri, 18 Nov 2022 12:37:38 -0500 Subject: [PATCH 4/5] fix formatting --- website/docs/r/satellite_cluster_worker_pool.html.markdown | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/website/docs/r/satellite_cluster_worker_pool.html.markdown b/website/docs/r/satellite_cluster_worker_pool.html.markdown index 225ce7ff21..d9fb46339c 100644 --- a/website/docs/r/satellite_cluster_worker_pool.html.markdown +++ b/website/docs/r/satellite_cluster_worker_pool.html.markdown @@ -70,7 +70,8 @@ Review the argument references that you can specify for your resource. Nested scheme for `zones`: - `id` - (Required, String) The name of the zone. -- `host_labels` - (Optional, Set(Strings)) Labels to add to the worker pool, formatted as `cpu:4` key-value pairs. Satellite uses host labels to automatically assign hosts to worker pools with matching labels.- `worker_pool_labels` - Labels on all the workers in the worker pool. +- `host_labels` - (Optional, Set(Strings)) Labels to add to the worker pool, formatted as `cpu:4` key-value pairs. Satellite uses host labels to automatically assign hosts to worker pools with matching labels. +- `worker_pool_labels` - Labels on all the workers in the worker pool. - `resource_group_id` - (Optional, Forces new resource, String) The ID of the resource group. You can retrieve the value from data source - `entitlement` - (Optional, String) The openshift cluster entitlement avoids the OCP licence charges incurred. Use cloud paks with OCP Licence entitlement to add the Openshift cluster worker pool. From ce0dfbfdde5700b38566a5ece4c1ad16d0df527b Mon Sep 17 00:00:00 2001 From: bhpratt Date: Mon, 21 Nov 2022 13:35:40 -0500 Subject: [PATCH 5/5] update test to remove duplicate provider and change region to us-south --- .../resource_ibm_satellite_cluster_test.go | 14 +++++--------- ...ource_ibm_satellite_cluster_worker_pool_test.go | 10 +++------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/ibm/service/satellite/resource_ibm_satellite_cluster_test.go b/ibm/service/satellite/resource_ibm_satellite_cluster_test.go index 4e52633bf0..43d31fd28c 100644 --- a/ibm/service/satellite/resource_ibm_satellite_cluster_test.go +++ b/ibm/service/satellite/resource_ibm_satellite_cluster_test.go @@ -23,9 +23,9 @@ func TestAccSatelliteCluster_Basic(t *testing.T) { locationName := fmt.Sprintf("tf-satellitelocation-%d", acctest.RandIntRange(10, 100)) managed_from := "wdc04" operatingSystem := "REDHAT_7_64" - zones := []string{"us-east-1", "us-east-2", "us-east-3"} + zones := []string{"us-south-1", "us-south-2", "us-south-3"} resource_group := "default" - region := "us-east" + region := "us-south" resource_prefix := "tf-satellite" host_provider := "ibm" publicKey := strings.TrimSpace(` @@ -55,9 +55,9 @@ func TestAccSatelliteCluster_Import(t *testing.T) { locationName := fmt.Sprintf("tf-satellitelocation-%d", acctest.RandIntRange(10, 100)) managed_from := "wdc04" operatingSystem := "REDHAT_7_64" - zones := []string{"us-east-1", "us-east-2", "us-east-3"} + zones := []string{"us-south-1", "us-south-2", "us-south-3"} resource_group := "default" - region := "us-east" + region := "us-south" resource_prefix := "tf-satellite" host_provider := "ibm" publicKey := strings.TrimSpace(` @@ -147,14 +147,10 @@ func testAccCheckSatelliteClusterDestroy(s *terraform.State) error { func testAccCheckSatelliteClusterCreate(clusterName, locationName, managed_from, operatingSystem, resource_group, resource_prefix, region, publicKey, host_provider string, zones []string) string { return fmt.Sprintf(` - provider "ibm" { - region = "us-east" - } - variable "location_zones" { description = "Allocate your hosts across these three zones" type = list(string) - default = ["us-east-1", "us-east-2", "us-east-3"] + default = ["us-south-1", "us-south-2", "us-south-3"] } data "ibm_is_image" "rhel7" { diff --git a/ibm/service/satellite/resource_ibm_satellite_cluster_worker_pool_test.go b/ibm/service/satellite/resource_ibm_satellite_cluster_worker_pool_test.go index 82d2612ad5..9b7d163091 100644 --- a/ibm/service/satellite/resource_ibm_satellite_cluster_worker_pool_test.go +++ b/ibm/service/satellite/resource_ibm_satellite_cluster_worker_pool_test.go @@ -146,14 +146,10 @@ func testAccCheckSatelliteClusterWorkerPoolDestroy(s *terraform.State) error { func testAccCheckSatelliteClusterWorkerPoolCreate(clusterName, locationName, operatingSystem, workerPoolName, resource_prefix string) string { return fmt.Sprintf(` - provider "ibm" { - region = "us-east" - } - variable "location_zones" { description = "Allocate your hosts across these three zones" type = list(string) - default = ["us-east-1", "us-east-2", "us-east-3"] + default = ["us-south-1", "us-south-2", "us-south-3"] } resource "ibm_satellite_location" "location" { @@ -186,7 +182,7 @@ func testAccCheckSatelliteClusterWorkerPoolCreate(clusterName, locationName, ope name = "%s-subnet-${count.index}" vpc = ibm_is_vpc.satellite_vpc.id total_ipv4_address_count = 256 - zone = "us-east-${count.index + 1}" + zone = "us-south-${count.index + 1}" } resource "ibm_is_ssh_key" "satellite_ssh" { @@ -199,7 +195,7 @@ func testAccCheckSatelliteClusterWorkerPoolCreate(clusterName, locationName, ope name = "%s-instance-${count.index}" vpc = ibm_is_vpc.satellite_vpc.id - zone = "us-east-${count.index + 1}" + zone = "us-south-${count.index + 1}" image = data.ibm_is_image.rhel7.id profile = "mx2-8x64" keys = [ibm_is_ssh_key.satellite_ssh.id]