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

Clarify worker_pool host_label usage and fix blank entry in array #4189

Merged
merged 5 commits into from
Nov 28, 2022
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
2 changes: 1 addition & 1 deletion ibm/flex/structures.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Even if user doesn't provide operating_system we always get "os" label ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct. The service will automatically assign an OS label based on the operating system of the worker pool. Current options are RHEL7, RHEL8, and RHCOS.

idx := 0
for k, v := range hostLabels {
if strings.HasPrefix(k, "os") {
Expand Down
14 changes: 5 additions & 9 deletions ibm/service/satellite/resource_ibm_satellite_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(`
Expand Down Expand Up @@ -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(`
Expand Down Expand Up @@ -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" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down Expand Up @@ -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" {
Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/satellite_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/satellite_cluster_worker_pool.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ 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, 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 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.
Expand Down