From 995ade62b1813141d35274b6a716a13faa21d2d5 Mon Sep 17 00:00:00 2001 From: Sivaanand Murugesan Date: Mon, 13 May 2024 14:12:54 +0530 Subject: [PATCH] Release 0.20.0 (#451) * PLT-971:Added warning log for review repave (#449) * PLT-971:Added warning log for review repave * PLT-971: Added Warning message for repave approval attribute * PLT-1098: Resolved duplicated pack UID on day 2 operations on cluster profile (#446) * PLT-1128:Remove word master from TF examples and docs. (#452) * Updated SDK dependencies. (#453) (#454) --- docs/resources/cluster_aws.md | 4 +-- docs/resources/cluster_azure.md | 2 +- docs/resources/cluster_custom_cloud.md | 2 +- docs/resources/cluster_edge_native.md | 2 +- docs/resources/cluster_gcp.md | 2 +- docs/resources/cluster_openstack.md | 2 +- examples/e2e/aws/resource_cluster.tf | 2 +- examples/e2e/aws_spot/resource_cluster.tf | 2 +- examples/e2e/azure/resource_cluster.tf | 2 +- examples/e2e/edge-native/variables.tf | 2 +- examples/e2e/edge-vsphere/resource_cluster.tf | 2 +- examples/e2e/eks-static/resource_cluster.tf | 4 +-- .../e2e/eks-static/terraform.template.tfvars | 2 +- examples/e2e/eks-static/variables.tf | 2 +- examples/e2e/eks/resource_cluster.tf | 4 +-- examples/e2e/eks/terraform.template.tfvars | 4 +-- examples/e2e/eks/variables.tf | 2 +- .../eks_rbac_namespaces/resource_cluster.tf | 4 +-- .../terraform.template.tfvars | 4 +-- examples/e2e/eks_rbac_namespaces/variables.tf | 2 +- examples/e2e/eks_spot/resource_cluster.tf | 4 +-- .../e2e/eks_spot/terraform.template.tfvars | 4 +-- examples/e2e/eks_spot/variables.tf | 2 +- .../e2e/eks_taints_labels/resource_cluster.tf | 4 +-- .../terraform.template.tfvars | 4 +-- examples/e2e/eks_taints_labels/variables.tf | 2 +- examples/e2e/gcp/resource_cluster.tf | 10 ++++---- examples/e2e/gcp/variables.tf | 4 +-- .../libvirt_rbac_labels/resource_cluster.tf | 2 +- examples/e2e/libvirt_rbac_labels/variables.tf | 2 +- examples/e2e/maas/resource_cluster.tf | 2 +- ...esource_openstack_cluster_static_create.tf | 6 ++--- examples/e2e/openstack/variables.tf | 4 +-- .../e2e/tke_taints_labels/resource_cluster.tf | 2 +- examples/e2e/tke_taints_labels/variables.tf | 2 +- .../tke_taints_labels_dev/resource_cluster.tf | 2 +- .../e2e/tke_taints_labels_dev/variables.tf | 2 +- examples/e2e/vsphere/resource_cluster.tf | 2 +- .../spectrocloud_cluster_aws/resource.tf | 4 +-- .../spectrocloud_cluster_azure/resource.tf | 2 +- .../spectrocloud_cluster_gcp/resource.tf | 2 +- spectrocloud/cluster_common_fields.go | 25 +++++++++++++++++++ spectrocloud/cluster_common_test.go | 24 ++++++++++++++++++ spectrocloud/resource_cluster_aks.go | 2 +- spectrocloud/resource_cluster_aws.go | 2 +- spectrocloud/resource_cluster_azure.go | 2 +- spectrocloud/resource_cluster_edge_native.go | 2 +- spectrocloud/resource_cluster_edge_vsphere.go | 2 +- spectrocloud/resource_cluster_eks.go | 2 +- spectrocloud/resource_cluster_gcp.go | 3 +-- spectrocloud/resource_cluster_libvirt.go | 2 +- spectrocloud/resource_cluster_maas.go | 2 +- spectrocloud/resource_cluster_openstack.go | 2 +- spectrocloud/resource_cluster_profile.go | 5 ++-- spectrocloud/resource_cluster_tke.go | 2 +- spectrocloud/resource_cluster_vsphere.go | 2 +- templates/resources/cluster_aws.md.tmpl | 4 +-- templates/resources/cluster_azure.md.tmpl | 2 +- .../resources/cluster_custom_cloud.md.tmpl | 2 +- .../resources/cluster_edge_native.md.tmpl | 2 +- templates/resources/cluster_gcp.md.tmpl | 2 +- templates/resources/cluster_openstack.md.tmpl | 2 +- 62 files changed, 130 insertions(+), 83 deletions(-) diff --git a/docs/resources/cluster_aws.md b/docs/resources/cluster_aws.md index addb26ba..f2adf767 100644 --- a/docs/resources/cluster_aws.md +++ b/docs/resources/cluster_aws.md @@ -81,11 +81,11 @@ resource "spectrocloud_cluster_aws" "cluster" { additional_labels = { "owner" = "siva" "purpose" = "testing" - "type" = "master" + "type" = "cp" } control_plane = true control_plane_as_worker = true - name = "master-pool" + name = "cp-pool" count = 1 instance_type = "m4.large" disk_size_gb = 60 diff --git a/docs/resources/cluster_azure.md b/docs/resources/cluster_azure.md index 342cbd60..a01cde9d 100644 --- a/docs/resources/cluster_azure.md +++ b/docs/resources/cluster_azure.md @@ -61,7 +61,7 @@ resource "spectrocloud_cluster_azure" "cluster" { machine_pool { control_plane = true control_plane_as_worker = true - name = "master-pool" + name = "cp-pool" count = 1 instance_type = "Standard_D2_v3" azs = [""] diff --git a/docs/resources/cluster_custom_cloud.md b/docs/resources/cluster_custom_cloud.md index 6bdc2270..75c7950b 100644 --- a/docs/resources/cluster_custom_cloud.md +++ b/docs/resources/cluster_custom_cloud.md @@ -44,7 +44,7 @@ description: |- additional_labels = { "owner" = "tf" "purpose" = "testing" - "type" = "master" + "type" = "cp" } control_plane = true control_plane_as_worker = true diff --git a/docs/resources/cluster_edge_native.md b/docs/resources/cluster_edge_native.md index b565bf08..39d59c1e 100644 --- a/docs/resources/cluster_edge_native.md +++ b/docs/resources/cluster_edge_native.md @@ -33,7 +33,7 @@ resource "spectrocloud_cluster_edge_native" "cluster" { machine_pool { control_plane = true control_plane_as_worker = true - name = "master-pool" + name = "cp-pool" edge_host { host_uid = spectrocloud_appliance.appliance0.uid diff --git a/docs/resources/cluster_gcp.md b/docs/resources/cluster_gcp.md index bc93b800..2181e005 100644 --- a/docs/resources/cluster_gcp.md +++ b/docs/resources/cluster_gcp.md @@ -62,7 +62,7 @@ resource "spectrocloud_cluster_gcp" "cluster" { machine_pool { control_plane = true control_plane_as_worker = true - name = "master-pool" + name = "cp-pool" count = 1 instance_type = "e2-standard-2" disk_size_gb = 62 diff --git a/docs/resources/cluster_openstack.md b/docs/resources/cluster_openstack.md index 3e4eff98..01242a52 100644 --- a/docs/resources/cluster_openstack.md +++ b/docs/resources/cluster_openstack.md @@ -49,7 +49,7 @@ resource "spectrocloud_cluster_openstack" "cluster" { machine_pool { control_plane = true control_plane_as_worker = true - name = "master-pool" + name = "cp-pool" count = 1 instance_type = "spectro-xlarge" azs = ["zone1"] diff --git a/examples/e2e/aws/resource_cluster.tf b/examples/e2e/aws/resource_cluster.tf index d2b8e1cf..e9d0a1c0 100644 --- a/examples/e2e/aws/resource_cluster.tf +++ b/examples/e2e/aws/resource_cluster.tf @@ -34,7 +34,7 @@ resource "spectrocloud_cluster_aws" "cluster" { machine_pool { control_plane = true control_plane_as_worker = true - name = "master-pool" + name = "cp-pool" count = 1 instance_type = "t3.large" disk_size_gb = 62 diff --git a/examples/e2e/aws_spot/resource_cluster.tf b/examples/e2e/aws_spot/resource_cluster.tf index 54423272..26ef7008 100644 --- a/examples/e2e/aws_spot/resource_cluster.tf +++ b/examples/e2e/aws_spot/resource_cluster.tf @@ -36,7 +36,7 @@ resource "spectrocloud_cluster_aws" "cluster" { machine_pool { control_plane = true control_plane_as_worker = true - name = "master-pool" + name = "cp-pool" count = 1 instance_type = "t3.large" disk_size_gb = 62 diff --git a/examples/e2e/azure/resource_cluster.tf b/examples/e2e/azure/resource_cluster.tf index 2dce9a94..f897dd90 100644 --- a/examples/e2e/azure/resource_cluster.tf +++ b/examples/e2e/azure/resource_cluster.tf @@ -36,7 +36,7 @@ resource "spectrocloud_cluster_azure" "cluster" { machine_pool { control_plane = true control_plane_as_worker = true - name = "master-pool" + name = "cp-pool" count = 1 instance_type = "Standard_D2_v3" azs = [] diff --git a/examples/e2e/edge-native/variables.tf b/examples/e2e/edge-native/variables.tf index 161b2f45..3887c2f7 100644 --- a/examples/e2e/edge-native/variables.tf +++ b/examples/e2e/edge-native/variables.tf @@ -3,6 +3,6 @@ variable "cluster_ssh_key_name" { default = "spectro2020" } -#variable "master_appliance_name" {} +#variable "cp_appliance_name" {} #variable "worker_appliance_name" {} diff --git a/examples/e2e/edge-vsphere/resource_cluster.tf b/examples/e2e/edge-vsphere/resource_cluster.tf index 567a62f2..9284dba3 100644 --- a/examples/e2e/edge-vsphere/resource_cluster.tf +++ b/examples/e2e/edge-vsphere/resource_cluster.tf @@ -74,7 +74,7 @@ resource "spectrocloud_cluster_edge_vsphere" "cluster" { machine_pool { control_plane = true control_plane_as_worker = true - name = "master-pool" + name = "cp-pool" count = 1 placement { diff --git a/examples/e2e/eks-static/resource_cluster.tf b/examples/e2e/eks-static/resource_cluster.tf index a55bf4da..472ed17f 100644 --- a/examples/e2e/eks-static/resource_cluster.tf +++ b/examples/e2e/eks-static/resource_cluster.tf @@ -21,7 +21,7 @@ resource "spectrocloud_cluster_eks" "cluster" { region = var.aws_region vpc_id = var.aws_vpc_id azs = var.azs != [] ? var.azs : null - az_subnets = var.master_azs_subnets_map != {} ? var.master_azs_subnets_map : null + az_subnets = var.cp_azs_subnets_map != {} ? var.cp_azs_subnets_map : null } machine_pool { @@ -29,7 +29,7 @@ resource "spectrocloud_cluster_eks" "cluster" { count = 3 instance_type = "t3.large" azs = var.azs != [] ? var.azs : null - az_subnets = var.master_azs_subnets_map != {} ? var.master_azs_subnets_map : null + az_subnets = var.cp_azs_subnets_map != {} ? var.cp_azs_subnets_map : null disk_size_gb = 60 } diff --git a/examples/e2e/eks-static/terraform.template.tfvars b/examples/e2e/eks-static/terraform.template.tfvars index e2eeebb4..b7a937ab 100644 --- a/examples/e2e/eks-static/terraform.template.tfvars +++ b/examples/e2e/eks-static/terraform.template.tfvars @@ -57,7 +57,7 @@ cloud_account_type = "{enter AWS Cloud Account Type}" #eg. "secret" or "sts" # Static provisioning requires specifying the exiting VPC-ID and all subnets to target aws_vpc_id = "{enter AWS VPC ID}" #e.g: vpc-123456 -master_azs_subnets_map = { +cp_azs_subnets_map = { "{enter AWS Availability Zone A}" = "{enter Subnet for AZ A, ...}" "{enter AWS Availability Zone B}" = "{enter Subnet for AZ A, ...}" } diff --git a/examples/e2e/eks-static/variables.tf b/examples/e2e/eks-static/variables.tf index 6048b989..90ffc7a6 100644 --- a/examples/e2e/eks-static/variables.tf +++ b/examples/e2e/eks-static/variables.tf @@ -32,7 +32,7 @@ variable "azs" { } # Provisioning Option B (Static) -variable "master_azs_subnets_map" { +variable "cp_azs_subnets_map" { default = {} type = map(string) } diff --git a/examples/e2e/eks/resource_cluster.tf b/examples/e2e/eks/resource_cluster.tf index a55bf4da..472ed17f 100644 --- a/examples/e2e/eks/resource_cluster.tf +++ b/examples/e2e/eks/resource_cluster.tf @@ -21,7 +21,7 @@ resource "spectrocloud_cluster_eks" "cluster" { region = var.aws_region vpc_id = var.aws_vpc_id azs = var.azs != [] ? var.azs : null - az_subnets = var.master_azs_subnets_map != {} ? var.master_azs_subnets_map : null + az_subnets = var.cp_azs_subnets_map != {} ? var.cp_azs_subnets_map : null } machine_pool { @@ -29,7 +29,7 @@ resource "spectrocloud_cluster_eks" "cluster" { count = 3 instance_type = "t3.large" azs = var.azs != [] ? var.azs : null - az_subnets = var.master_azs_subnets_map != {} ? var.master_azs_subnets_map : null + az_subnets = var.cp_azs_subnets_map != {} ? var.cp_azs_subnets_map : null disk_size_gb = 60 } diff --git a/examples/e2e/eks/terraform.template.tfvars b/examples/e2e/eks/terraform.template.tfvars index 9d6bd122..9fa428e2 100644 --- a/examples/e2e/eks/terraform.template.tfvars +++ b/examples/e2e/eks/terraform.template.tfvars @@ -75,7 +75,7 @@ cloud_account_type = "{enter AWS Cloud Account Type}" #eg. "secret" or "sts" # (for STATIC, uncomment the following 9 lines) #aws_vpc_id = "{enter AWS VPC ID}" #e.g: vpc-123456 -#master_azs_subnets_map = { +#cp_azs_subnets_map = { # "{enter AWS Availability Zone A}" = "{enter Subnet for AZ A, ...}" # "{enter AWS Availability Zone B}" = "{enter Subnet for AZ A, ...}" #} @@ -85,7 +85,7 @@ cloud_account_type = "{enter AWS Cloud Account Type}" #eg. "secret" or "sts" #} ## e.g: -## master_azs_subnets_map = { +## cp_azs_subnets_map = { ## "us-west-2a" = "subnet-12345,subnet-4567" ## "us-west-2b" = "subnet-12345,subnet-4567" ## } \ No newline at end of file diff --git a/examples/e2e/eks/variables.tf b/examples/e2e/eks/variables.tf index 6048b989..90ffc7a6 100644 --- a/examples/e2e/eks/variables.tf +++ b/examples/e2e/eks/variables.tf @@ -32,7 +32,7 @@ variable "azs" { } # Provisioning Option B (Static) -variable "master_azs_subnets_map" { +variable "cp_azs_subnets_map" { default = {} type = map(string) } diff --git a/examples/e2e/eks_rbac_namespaces/resource_cluster.tf b/examples/e2e/eks_rbac_namespaces/resource_cluster.tf index 13a12d4d..fee83ad9 100644 --- a/examples/e2e/eks_rbac_namespaces/resource_cluster.tf +++ b/examples/e2e/eks_rbac_namespaces/resource_cluster.tf @@ -65,7 +65,7 @@ resource "spectrocloud_cluster_eks" "cluster" { region = var.aws_region vpc_id = var.aws_vpc_id azs = var.azs != [] ? var.azs : null - az_subnets = var.master_azs_subnets_map != {} ? var.master_azs_subnets_map : null + az_subnets = var.cp_azs_subnets_map != {} ? var.cp_azs_subnets_map : null } machine_pool { @@ -75,7 +75,7 @@ resource "spectrocloud_cluster_eks" "cluster" { max = 3 instance_type = "t3.large" azs = var.azs != [] ? var.azs : null - az_subnets = var.master_azs_subnets_map != {} ? var.master_azs_subnets_map : null + az_subnets = var.cp_azs_subnets_map != {} ? var.cp_azs_subnets_map : null disk_size_gb = 30 } } diff --git a/examples/e2e/eks_rbac_namespaces/terraform.template.tfvars b/examples/e2e/eks_rbac_namespaces/terraform.template.tfvars index 9d6bd122..9fa428e2 100644 --- a/examples/e2e/eks_rbac_namespaces/terraform.template.tfvars +++ b/examples/e2e/eks_rbac_namespaces/terraform.template.tfvars @@ -75,7 +75,7 @@ cloud_account_type = "{enter AWS Cloud Account Type}" #eg. "secret" or "sts" # (for STATIC, uncomment the following 9 lines) #aws_vpc_id = "{enter AWS VPC ID}" #e.g: vpc-123456 -#master_azs_subnets_map = { +#cp_azs_subnets_map = { # "{enter AWS Availability Zone A}" = "{enter Subnet for AZ A, ...}" # "{enter AWS Availability Zone B}" = "{enter Subnet for AZ A, ...}" #} @@ -85,7 +85,7 @@ cloud_account_type = "{enter AWS Cloud Account Type}" #eg. "secret" or "sts" #} ## e.g: -## master_azs_subnets_map = { +## cp_azs_subnets_map = { ## "us-west-2a" = "subnet-12345,subnet-4567" ## "us-west-2b" = "subnet-12345,subnet-4567" ## } \ No newline at end of file diff --git a/examples/e2e/eks_rbac_namespaces/variables.tf b/examples/e2e/eks_rbac_namespaces/variables.tf index 6048b989..90ffc7a6 100644 --- a/examples/e2e/eks_rbac_namespaces/variables.tf +++ b/examples/e2e/eks_rbac_namespaces/variables.tf @@ -32,7 +32,7 @@ variable "azs" { } # Provisioning Option B (Static) -variable "master_azs_subnets_map" { +variable "cp_azs_subnets_map" { default = {} type = map(string) } diff --git a/examples/e2e/eks_spot/resource_cluster.tf b/examples/e2e/eks_spot/resource_cluster.tf index c4fa8870..0d5f5e54 100644 --- a/examples/e2e/eks_spot/resource_cluster.tf +++ b/examples/e2e/eks_spot/resource_cluster.tf @@ -21,7 +21,7 @@ resource "spectrocloud_cluster_eks" "cluster" { region = var.aws_region vpc_id = var.aws_vpc_id azs = var.azs != [] ? var.azs : null - az_subnets = var.master_azs_subnets_map != {} ? var.master_azs_subnets_map : null + az_subnets = var.cp_azs_subnets_map != {} ? var.cp_azs_subnets_map : null } machine_pool { @@ -31,7 +31,7 @@ resource "spectrocloud_cluster_eks" "cluster" { capacity_type = "spot" max_price = "0.015" azs = var.azs != [] ? var.azs : null - az_subnets = var.master_azs_subnets_map != {} ? var.master_azs_subnets_map : null + az_subnets = var.cp_azs_subnets_map != {} ? var.cp_azs_subnets_map : null disk_size_gb = 60 } diff --git a/examples/e2e/eks_spot/terraform.template.tfvars b/examples/e2e/eks_spot/terraform.template.tfvars index 9d6bd122..9fa428e2 100644 --- a/examples/e2e/eks_spot/terraform.template.tfvars +++ b/examples/e2e/eks_spot/terraform.template.tfvars @@ -75,7 +75,7 @@ cloud_account_type = "{enter AWS Cloud Account Type}" #eg. "secret" or "sts" # (for STATIC, uncomment the following 9 lines) #aws_vpc_id = "{enter AWS VPC ID}" #e.g: vpc-123456 -#master_azs_subnets_map = { +#cp_azs_subnets_map = { # "{enter AWS Availability Zone A}" = "{enter Subnet for AZ A, ...}" # "{enter AWS Availability Zone B}" = "{enter Subnet for AZ A, ...}" #} @@ -85,7 +85,7 @@ cloud_account_type = "{enter AWS Cloud Account Type}" #eg. "secret" or "sts" #} ## e.g: -## master_azs_subnets_map = { +## cp_azs_subnets_map = { ## "us-west-2a" = "subnet-12345,subnet-4567" ## "us-west-2b" = "subnet-12345,subnet-4567" ## } \ No newline at end of file diff --git a/examples/e2e/eks_spot/variables.tf b/examples/e2e/eks_spot/variables.tf index 6048b989..90ffc7a6 100644 --- a/examples/e2e/eks_spot/variables.tf +++ b/examples/e2e/eks_spot/variables.tf @@ -32,7 +32,7 @@ variable "azs" { } # Provisioning Option B (Static) -variable "master_azs_subnets_map" { +variable "cp_azs_subnets_map" { default = {} type = map(string) } diff --git a/examples/e2e/eks_taints_labels/resource_cluster.tf b/examples/e2e/eks_taints_labels/resource_cluster.tf index 82b74eb5..65a728bb 100644 --- a/examples/e2e/eks_taints_labels/resource_cluster.tf +++ b/examples/e2e/eks_taints_labels/resource_cluster.tf @@ -65,7 +65,7 @@ resource "spectrocloud_cluster_eks" "cluster" { region = var.aws_region vpc_id = var.aws_vpc_id azs = var.azs != [] ? var.azs : null - az_subnets = var.master_azs_subnets_map != {} ? var.master_azs_subnets_map : null + az_subnets = var.cp_azs_subnets_map != {} ? var.cp_azs_subnets_map : null } machine_pool { @@ -73,7 +73,7 @@ resource "spectrocloud_cluster_eks" "cluster" { count = 1 instance_type = "t3.large" azs = var.azs != [] ? var.azs : null - az_subnets = var.master_azs_subnets_map != {} ? var.master_azs_subnets_map : null + az_subnets = var.cp_azs_subnets_map != {} ? var.cp_azs_subnets_map : null disk_size_gb = 30 additional_labels = { diff --git a/examples/e2e/eks_taints_labels/terraform.template.tfvars b/examples/e2e/eks_taints_labels/terraform.template.tfvars index 9d6bd122..9fa428e2 100644 --- a/examples/e2e/eks_taints_labels/terraform.template.tfvars +++ b/examples/e2e/eks_taints_labels/terraform.template.tfvars @@ -75,7 +75,7 @@ cloud_account_type = "{enter AWS Cloud Account Type}" #eg. "secret" or "sts" # (for STATIC, uncomment the following 9 lines) #aws_vpc_id = "{enter AWS VPC ID}" #e.g: vpc-123456 -#master_azs_subnets_map = { +#cp_azs_subnets_map = { # "{enter AWS Availability Zone A}" = "{enter Subnet for AZ A, ...}" # "{enter AWS Availability Zone B}" = "{enter Subnet for AZ A, ...}" #} @@ -85,7 +85,7 @@ cloud_account_type = "{enter AWS Cloud Account Type}" #eg. "secret" or "sts" #} ## e.g: -## master_azs_subnets_map = { +## cp_azs_subnets_map = { ## "us-west-2a" = "subnet-12345,subnet-4567" ## "us-west-2b" = "subnet-12345,subnet-4567" ## } \ No newline at end of file diff --git a/examples/e2e/eks_taints_labels/variables.tf b/examples/e2e/eks_taints_labels/variables.tf index 6048b989..90ffc7a6 100644 --- a/examples/e2e/eks_taints_labels/variables.tf +++ b/examples/e2e/eks_taints_labels/variables.tf @@ -32,7 +32,7 @@ variable "azs" { } # Provisioning Option B (Static) -variable "master_azs_subnets_map" { +variable "cp_azs_subnets_map" { default = {} type = map(string) } diff --git a/examples/e2e/gcp/resource_cluster.tf b/examples/e2e/gcp/resource_cluster.tf index 9a4f2536..92c9ed13 100644 --- a/examples/e2e/gcp/resource_cluster.tf +++ b/examples/e2e/gcp/resource_cluster.tf @@ -19,11 +19,11 @@ resource "spectrocloud_cluster_gcp" "cluster" { machine_pool { control_plane = true control_plane_as_worker = true - name = "master-pool" - count = var.master_nodes.count - instance_type = var.master_nodes.instance_type - disk_size_gb = var.master_nodes.disk_size_gb - azs = var.master_nodes.availability_zones + name = "cp-pool" + count = var.cp_nodes.count + instance_type = var.cp_nodes.instance_type + disk_size_gb = var.cp_nodes.disk_size_gb + azs = var.cp_nodes.availability_zones } machine_pool { diff --git a/examples/e2e/gcp/variables.tf b/examples/e2e/gcp/variables.tf index a580bff8..f00483cc 100644 --- a/examples/e2e/gcp/variables.tf +++ b/examples/e2e/gcp/variables.tf @@ -5,14 +5,14 @@ variable "gcp-cloud-account-name" { description = "The name of your GCP account as assigned in Palette" } -variable "master_nodes" { +variable "cp_nodes" { type = object({ count = string instance_type = string disk_size_gb = string availability_zones = list(string) }) - description = "Master nodes configuration." + description = "Control Plane nodes configuration." } variable "worker_nodes" { diff --git a/examples/e2e/libvirt_rbac_labels/resource_cluster.tf b/examples/e2e/libvirt_rbac_labels/resource_cluster.tf index d9ef9026..fe94df2f 100644 --- a/examples/e2e/libvirt_rbac_labels/resource_cluster.tf +++ b/examples/e2e/libvirt_rbac_labels/resource_cluster.tf @@ -65,7 +65,7 @@ resource "spectrocloud_cluster_libvirt" "cluster" { machine_pool { control_plane = true control_plane_as_worker = true - name = "master-pool" + name = "cp-pool" count = 1 placements { diff --git a/examples/e2e/libvirt_rbac_labels/variables.tf b/examples/e2e/libvirt_rbac_labels/variables.tf index 161b2f45..3887c2f7 100644 --- a/examples/e2e/libvirt_rbac_labels/variables.tf +++ b/examples/e2e/libvirt_rbac_labels/variables.tf @@ -3,6 +3,6 @@ variable "cluster_ssh_key_name" { default = "spectro2020" } -#variable "master_appliance_name" {} +#variable "cp_appliance_name" {} #variable "worker_appliance_name" {} diff --git a/examples/e2e/maas/resource_cluster.tf b/examples/e2e/maas/resource_cluster.tf index 58943edf..98080ab8 100644 --- a/examples/e2e/maas/resource_cluster.tf +++ b/examples/e2e/maas/resource_cluster.tf @@ -14,7 +14,7 @@ resource "spectrocloud_cluster_maas" "cluster" { machine_pool { control_plane = true control_plane_as_worker = true - name = "master-pool" + name = "cp-pool" count = 1 placement { resource_pool = var.maas_resource_pool diff --git a/examples/e2e/openstack/resource_openstack_cluster_static_create.tf b/examples/e2e/openstack/resource_openstack_cluster_static_create.tf index b1bb5188..40945120 100644 --- a/examples/e2e/openstack/resource_openstack_cluster_static_create.tf +++ b/examples/e2e/openstack/resource_openstack_cluster_static_create.tf @@ -79,9 +79,9 @@ resource "spectrocloud_cluster_openstack" "cluster" { machine_pool { control_plane = true control_plane_as_worker = true - name = "master-pool" - count = var.master_inst_count - instance_type = var.master_inst_type + name = "cp-pool" + count = var.cp_inst_count + instance_type = var.cp_inst_type azs = ["nova"] } diff --git a/examples/e2e/openstack/variables.tf b/examples/e2e/openstack/variables.tf index f1b7a03a..c75b9738 100644 --- a/examples/e2e/openstack/variables.tf +++ b/examples/e2e/openstack/variables.tf @@ -10,8 +10,8 @@ variable "addon_ver" {} variable "addon_name" {} variable "cp_name" {} variable "cluster_name" {} -variable "master_inst_count" {} -variable "master_inst_type" {} +variable "cp_inst_count" {} +variable "cp_inst_type" {} variable "worker_inst_type" {} variable "worker_inst_count" {} variable "sshkey" {} diff --git a/examples/e2e/tke_taints_labels/resource_cluster.tf b/examples/e2e/tke_taints_labels/resource_cluster.tf index 38d69796..3350735f 100644 --- a/examples/e2e/tke_taints_labels/resource_cluster.tf +++ b/examples/e2e/tke_taints_labels/resource_cluster.tf @@ -65,7 +65,7 @@ resource "spectrocloud_cluster_tke" "cluster" { ssh_key_name = var.tke_ssh_key_name region = var.tke_region vpc_id = var.tke_vpc_id - az_subnets = var.master_tke_subnets_map + az_subnets = var.cp_tke_subnets_map } machine_pool { diff --git a/examples/e2e/tke_taints_labels/variables.tf b/examples/e2e/tke_taints_labels/variables.tf index 2d4bfccd..8b5f234d 100644 --- a/examples/e2e/tke_taints_labels/variables.tf +++ b/examples/e2e/tke_taints_labels/variables.tf @@ -13,7 +13,7 @@ variable "tke_vpc_id" { default = "" } -variable "master_tke_subnets_map" { +variable "cp_tke_subnets_map" { type = map(string) } diff --git a/examples/e2e/tke_taints_labels_dev/resource_cluster.tf b/examples/e2e/tke_taints_labels_dev/resource_cluster.tf index d0405572..e760e3ac 100644 --- a/examples/e2e/tke_taints_labels_dev/resource_cluster.tf +++ b/examples/e2e/tke_taints_labels_dev/resource_cluster.tf @@ -65,7 +65,7 @@ resource "spectrocloud_cluster_tke" "cluster" { ssh_key_name = var.tke_ssh_key_name region = var.tke_region vpc_id = var.tke_vpc_id - az_subnets = var.master_tke_subnets_map + az_subnets = var.cp_tke_subnets_map } machine_pool { diff --git a/examples/e2e/tke_taints_labels_dev/variables.tf b/examples/e2e/tke_taints_labels_dev/variables.tf index 2d4bfccd..8b5f234d 100644 --- a/examples/e2e/tke_taints_labels_dev/variables.tf +++ b/examples/e2e/tke_taints_labels_dev/variables.tf @@ -13,7 +13,7 @@ variable "tke_vpc_id" { default = "" } -variable "master_tke_subnets_map" { +variable "cp_tke_subnets_map" { type = map(string) } diff --git a/examples/e2e/vsphere/resource_cluster.tf b/examples/e2e/vsphere/resource_cluster.tf index 4385d025..e72716a1 100644 --- a/examples/e2e/vsphere/resource_cluster.tf +++ b/examples/e2e/vsphere/resource_cluster.tf @@ -90,7 +90,7 @@ resource "spectrocloud_cluster_vsphere" "cluster" { machine_pool { control_plane = true control_plane_as_worker = true - name = "master-pool" + name = "cp-pool" count = 1 placement { diff --git a/examples/resources/spectrocloud_cluster_aws/resource.tf b/examples/resources/spectrocloud_cluster_aws/resource.tf index 7e141e6e..f85ee121 100644 --- a/examples/resources/spectrocloud_cluster_aws/resource.tf +++ b/examples/resources/spectrocloud_cluster_aws/resource.tf @@ -66,11 +66,11 @@ resource "spectrocloud_cluster_aws" "cluster" { additional_labels = { "owner" = "siva" "purpose" = "testing" - "type" = "master" + "type" = "cp" } control_plane = true control_plane_as_worker = true - name = "master-pool" + name = "cp-pool" count = 1 instance_type = "m4.large" disk_size_gb = 60 diff --git a/examples/resources/spectrocloud_cluster_azure/resource.tf b/examples/resources/spectrocloud_cluster_azure/resource.tf index 2c2d01dc..2bae3f11 100644 --- a/examples/resources/spectrocloud_cluster_azure/resource.tf +++ b/examples/resources/spectrocloud_cluster_azure/resource.tf @@ -39,7 +39,7 @@ resource "spectrocloud_cluster_azure" "cluster" { machine_pool { control_plane = true control_plane_as_worker = true - name = "master-pool" + name = "cp-pool" count = 1 instance_type = "Standard_D2_v3" azs = [] diff --git a/examples/resources/spectrocloud_cluster_gcp/resource.tf b/examples/resources/spectrocloud_cluster_gcp/resource.tf index 04ae6bb5..137a9905 100644 --- a/examples/resources/spectrocloud_cluster_gcp/resource.tf +++ b/examples/resources/spectrocloud_cluster_gcp/resource.tf @@ -47,7 +47,7 @@ resource "spectrocloud_cluster_gcp" "cluster" { machine_pool { control_plane = true control_plane_as_worker = true - name = "master-pool" + name = "cp-pool" count = 1 instance_type = "e2-standard-2" disk_size_gb = 62 diff --git a/spectrocloud/cluster_common_fields.go b/spectrocloud/cluster_common_fields.go index 8cc4631c..829977bf 100644 --- a/spectrocloud/cluster_common_fields.go +++ b/spectrocloud/cluster_common_fields.go @@ -2,6 +2,7 @@ package spectrocloud import ( "errors" + "fmt" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/spectrocloud/hapi/models" @@ -100,6 +101,12 @@ func readCommonFields(c *client.V1Client, d *schema.ResourceData, cluster *model } } + if _, ok := d.GetOk("review_repave_state"); ok { + if err := d.Set("review_repave_state", cluster.Status.Repave.State); err != nil { + return diag.FromErr(err), true + } + } + clusterContext := d.Get("context").(string) if clusterStatus, err := c.GetClusterWithoutStatus(clusterContext, d.Id()); err != nil { @@ -235,3 +242,21 @@ func validateSystemRepaveApproval(d *schema.ResourceData, c *client.V1Client) er } return nil } + +func validateReviewRepaveValue(val interface{}, key string) (warns []string, errs []error) { + repaveValue := val.(string) + validStatuses := map[string]bool{ + "": true, + "Approved": true, + "Pending": true, + } + if repaveValue == "Approved" { + warning := []string{"Review Repave Value Warning:", + "Setting `review_repave_state` to `Approved` will authorize the palette to repave the cluster if any system repave is in the pending state. Please exercise caution when using `review_repave_state` attribute."} + warns = append(warns, strings.Join(warning, "\n")) + } + if _, ok := validStatuses[repaveValue]; !ok { + errs = append(errs, fmt.Errorf("expected review_repave_state to be one of [``, `Pending`, `Approved`], got %s", repaveValue)) + } + return warns, errs +} diff --git a/spectrocloud/cluster_common_test.go b/spectrocloud/cluster_common_test.go index 1cc85142..e2caaf85 100644 --- a/spectrocloud/cluster_common_test.go +++ b/spectrocloud/cluster_common_test.go @@ -1,6 +1,7 @@ package spectrocloud import ( + "fmt" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/spectrocloud/gomi/pkg/ptr" "github.com/spectrocloud/palette-sdk-go/client" @@ -523,3 +524,26 @@ func TestToSSHKeys(t *testing.T) { assert.Nil(t, keys4) assert.Equal(t, "validation ssh_key: Kindly specify any one attribute ssh_key or ssh_keys", err4.Error()) } + +func TestValidateReviewRepaveValue(t *testing.T) { + // Valid repave values + validValues := []string{"", "Approved", "Pending"} + + for _, value := range validValues { + warns, errs := validateReviewRepaveValue(value, "review_repave_state") + assert.Empty(t, errs, "Expected no errors for valid repave value") + if value == "Approved" { + assert.NotEmpty(t, warns, "Expected warning for 'Approved' repave value") + } else { + assert.Empty(t, warns, "Expected no warnings for valid repave value") + } + } + + // Invalid repave value + invalidValue := "InvalidStatus" + warns, errs := validateReviewRepaveValue(invalidValue, "review_repave_state") + assert.NotEmpty(t, errs, "Expected error for invalid repave value") + assert.Empty(t, warns, "Expected no warnings for invalid repave value") + expectedError := fmt.Sprintf("expected review_repave_state to be one of [``, `Pending`, `Approved`], got %s", invalidValue) + assert.Equal(t, expectedError, errs[0].Error(), "Expected specific error message for invalid repave value") +} diff --git a/spectrocloud/resource_cluster_aks.go b/spectrocloud/resource_cluster_aks.go index 70ccafb2..a454d668 100644 --- a/spectrocloud/resource_cluster_aks.go +++ b/spectrocloud/resource_cluster_aks.go @@ -94,7 +94,7 @@ func resourceClusterAks() *schema.Resource { Type: schema.TypeString, Default: "", Optional: true, - ValidateFunc: validation.StringInSlice([]string{"", "Approved", "Pending"}, false), + ValidateFunc: validateReviewRepaveValue, Description: "To authorize the cluster repave, set the value to `Approved` for approval and `\"\"` to decline. Default value is `\"\"`.", }, "pause_agent_upgrades": { diff --git a/spectrocloud/resource_cluster_aws.go b/spectrocloud/resource_cluster_aws.go index 8c0e7a7f..5d2df6d8 100644 --- a/spectrocloud/resource_cluster_aws.go +++ b/spectrocloud/resource_cluster_aws.go @@ -94,7 +94,7 @@ func resourceClusterAws() *schema.Resource { Type: schema.TypeString, Default: "", Optional: true, - ValidateFunc: validation.StringInSlice([]string{"", "Approved", "Pending"}, false), + ValidateFunc: validateReviewRepaveValue, Description: "To authorize the cluster repave, set the value to `Approved` for approval and `\"\"` to decline. Default value is `\"\"`.", }, "pause_agent_upgrades": { diff --git a/spectrocloud/resource_cluster_azure.go b/spectrocloud/resource_cluster_azure.go index 699442ab..94eeff5e 100644 --- a/spectrocloud/resource_cluster_azure.go +++ b/spectrocloud/resource_cluster_azure.go @@ -92,7 +92,7 @@ func resourceClusterAzure() *schema.Resource { Type: schema.TypeString, Default: "", Optional: true, - ValidateFunc: validation.StringInSlice([]string{"", "Approved", "Pending"}, false), + ValidateFunc: validateReviewRepaveValue, Description: "To authorize the cluster repave, set the value to `Approved` for approval and `\"\"` to decline. Default value is `\"\"`.", }, "pause_agent_upgrades": { diff --git a/spectrocloud/resource_cluster_edge_native.go b/spectrocloud/resource_cluster_edge_native.go index d0876ed6..3e03371f 100644 --- a/spectrocloud/resource_cluster_edge_native.go +++ b/spectrocloud/resource_cluster_edge_native.go @@ -95,7 +95,7 @@ func resourceClusterEdgeNative() *schema.Resource { Type: schema.TypeString, Default: "", Optional: true, - ValidateFunc: validation.StringInSlice([]string{"", "Approved", "Pending"}, false), + ValidateFunc: validateReviewRepaveValue, Description: "To authorize the cluster repave, set the value to `Approved` for approval and `\"\"` to decline. Default value is `\"\"`.", }, "os_patch_on_boot": { diff --git a/spectrocloud/resource_cluster_edge_vsphere.go b/spectrocloud/resource_cluster_edge_vsphere.go index 149055ed..5d03682d 100644 --- a/spectrocloud/resource_cluster_edge_vsphere.go +++ b/spectrocloud/resource_cluster_edge_vsphere.go @@ -79,7 +79,7 @@ func resourceClusterEdgeVsphere() *schema.Resource { Type: schema.TypeString, Default: "", Optional: true, - ValidateFunc: validation.StringInSlice([]string{"", "Approved", "Pending"}, false), + ValidateFunc: validateReviewRepaveValue, Description: "To authorize the cluster repave, set the value to `Approved` for approval and `\"\"` to decline. Default value is `\"\"`.", }, "pause_agent_upgrades": { diff --git a/spectrocloud/resource_cluster_eks.go b/spectrocloud/resource_cluster_eks.go index 118992a3..cc02c808 100644 --- a/spectrocloud/resource_cluster_eks.go +++ b/spectrocloud/resource_cluster_eks.go @@ -92,7 +92,7 @@ func resourceClusterEks() *schema.Resource { Type: schema.TypeString, Default: "", Optional: true, - ValidateFunc: validation.StringInSlice([]string{"", "Approved", "Pending"}, false), + ValidateFunc: validateReviewRepaveValue, Description: "To authorize the cluster repave, set the value to `Approved` for approval and `\"\"` to decline. Default value is `\"\"`.", }, "pause_agent_upgrades": { diff --git a/spectrocloud/resource_cluster_gcp.go b/spectrocloud/resource_cluster_gcp.go index 664e8046..aafd61c5 100644 --- a/spectrocloud/resource_cluster_gcp.go +++ b/spectrocloud/resource_cluster_gcp.go @@ -90,7 +90,7 @@ func resourceClusterGcp() *schema.Resource { Type: schema.TypeString, Default: "", Optional: true, - ValidateFunc: validation.StringInSlice([]string{"", "Approved", "Pending"}, false), + ValidateFunc: validateReviewRepaveValue, Description: "To authorize the cluster repave, set the value to `Approved` for approval and `\"\"` to decline. Default value is `\"\"`.", }, "pause_agent_upgrades": { @@ -319,7 +319,6 @@ func flattenCloudConfigGcp(configUID string, d *schema.ResourceData, c *client.V return diag.FromErr(err) } } - return diag.Diagnostics{} } diff --git a/spectrocloud/resource_cluster_libvirt.go b/spectrocloud/resource_cluster_libvirt.go index 258f0257..97ac2012 100644 --- a/spectrocloud/resource_cluster_libvirt.go +++ b/spectrocloud/resource_cluster_libvirt.go @@ -92,7 +92,7 @@ func resourceClusterLibvirt() *schema.Resource { Type: schema.TypeString, Default: "", Optional: true, - ValidateFunc: validation.StringInSlice([]string{"", "Approved", "Pending"}, false), + ValidateFunc: validateReviewRepaveValue, Description: "To authorize the cluster repave, set the value to `Approved` for approval and `\"\"` to decline. Default value is `\"\"`.", }, "pause_agent_upgrades": { diff --git a/spectrocloud/resource_cluster_maas.go b/spectrocloud/resource_cluster_maas.go index 1fff66aa..6f43d9b0 100644 --- a/spectrocloud/resource_cluster_maas.go +++ b/spectrocloud/resource_cluster_maas.go @@ -95,7 +95,7 @@ func resourceClusterMaas() *schema.Resource { Type: schema.TypeString, Default: "", Optional: true, - ValidateFunc: validation.StringInSlice([]string{"", "Approved", "Pending"}, false), + ValidateFunc: validateReviewRepaveValue, Description: "To authorize the cluster repave, set the value to `Approved` for approval and `\"\"` to decline. Default value is `\"\"`.", }, "pause_agent_upgrades": { diff --git a/spectrocloud/resource_cluster_openstack.go b/spectrocloud/resource_cluster_openstack.go index e319a800..1e12dedb 100644 --- a/spectrocloud/resource_cluster_openstack.go +++ b/spectrocloud/resource_cluster_openstack.go @@ -90,7 +90,7 @@ func resourceClusterOpenStack() *schema.Resource { Type: schema.TypeString, Default: "", Optional: true, - ValidateFunc: validation.StringInSlice([]string{"", "Approved", "Pending"}, false), + ValidateFunc: validateReviewRepaveValue, Description: "To authorize the cluster repave, set the value to `Approved` for approval and `\"\"` to decline. Default value is `\"\"`.", }, "pause_agent_upgrades": { diff --git a/spectrocloud/resource_cluster_profile.go b/spectrocloud/resource_cluster_profile.go index 602ca723..e35c278a 100644 --- a/spectrocloud/resource_cluster_profile.go +++ b/spectrocloud/resource_cluster_profile.go @@ -422,6 +422,7 @@ func toClusterProfilePackUpdate(pSrc interface{}, packs []*models.V1PackRef) (*m pName := p["name"].(string) pTag := p["tag"].(string) pUID := p["uid"].(string) + pRegistryUID := "" if p["registry_uid"] != nil { pRegistryUID = p["registry_uid"].(string) @@ -434,9 +435,7 @@ func toClusterProfilePackUpdate(pSrc interface{}, packs []*models.V1PackRef) (*m return nil, fmt.Errorf("pack %s needs to specify tag", pName) } case models.V1PackTypeManifest: - if pUID == "" { - pUID = "spectro-manifest-pack" - } + pUID = "spectro-manifest-pack" } pack := &models.V1PackManifestUpdateEntity{ diff --git a/spectrocloud/resource_cluster_tke.go b/spectrocloud/resource_cluster_tke.go index 586a94d7..df761d2f 100644 --- a/spectrocloud/resource_cluster_tke.go +++ b/spectrocloud/resource_cluster_tke.go @@ -231,7 +231,7 @@ func resourceClusterTke() *schema.Resource { Type: schema.TypeString, Default: "", Optional: true, - ValidateFunc: validation.StringInSlice([]string{"", "Approved", "Pending"}, false), + ValidateFunc: validateReviewRepaveValue, Description: "To authorize the cluster repave, set the value to `Approved` for approval and `\"\"` to decline. Default value is `\"\"`.", }, "pause_agent_upgrades": { diff --git a/spectrocloud/resource_cluster_vsphere.go b/spectrocloud/resource_cluster_vsphere.go index ce25f6f3..ca92fe6f 100644 --- a/spectrocloud/resource_cluster_vsphere.go +++ b/spectrocloud/resource_cluster_vsphere.go @@ -94,7 +94,7 @@ func resourceClusterVsphere() *schema.Resource { Type: schema.TypeString, Default: "", Optional: true, - ValidateFunc: validation.StringInSlice([]string{"", "Approved", "Pending"}, false), + ValidateFunc: validateReviewRepaveValue, Description: "To authorize the cluster repave, set the value to `Approved` for approval and `\"\"` to decline. Default value is `\"\"`.", }, "pause_agent_upgrades": { diff --git a/templates/resources/cluster_aws.md.tmpl b/templates/resources/cluster_aws.md.tmpl index 538f69cc..da3d1cb8 100644 --- a/templates/resources/cluster_aws.md.tmpl +++ b/templates/resources/cluster_aws.md.tmpl @@ -81,11 +81,11 @@ resource "spectrocloud_cluster_aws" "cluster" { additional_labels = { "owner" = "siva" "purpose" = "testing" - "type" = "master" + "type" = "cp" } control_plane = true control_plane_as_worker = true - name = "master-pool" + name = "cp-pool" count = 1 instance_type = "m4.large" disk_size_gb = 60 diff --git a/templates/resources/cluster_azure.md.tmpl b/templates/resources/cluster_azure.md.tmpl index 00c32e9e..e2dae954 100644 --- a/templates/resources/cluster_azure.md.tmpl +++ b/templates/resources/cluster_azure.md.tmpl @@ -61,7 +61,7 @@ resource "spectrocloud_cluster_azure" "cluster" { machine_pool { control_plane = true control_plane_as_worker = true - name = "master-pool" + name = "cp-pool" count = 1 instance_type = "Standard_D2_v3" azs = [""] diff --git a/templates/resources/cluster_custom_cloud.md.tmpl b/templates/resources/cluster_custom_cloud.md.tmpl index 35d1ad8e..b590e8a9 100644 --- a/templates/resources/cluster_custom_cloud.md.tmpl +++ b/templates/resources/cluster_custom_cloud.md.tmpl @@ -44,7 +44,7 @@ description: |- additional_labels = { "owner" = "tf" "purpose" = "testing" - "type" = "master" + "type" = "cp" } control_plane = true control_plane_as_worker = true diff --git a/templates/resources/cluster_edge_native.md.tmpl b/templates/resources/cluster_edge_native.md.tmpl index d8b95bac..050469ba 100644 --- a/templates/resources/cluster_edge_native.md.tmpl +++ b/templates/resources/cluster_edge_native.md.tmpl @@ -33,7 +33,7 @@ resource "spectrocloud_cluster_edge_native" "cluster" { machine_pool { control_plane = true control_plane_as_worker = true - name = "master-pool" + name = "cp-pool" edge_host { host_uid = spectrocloud_appliance.appliance0.uid diff --git a/templates/resources/cluster_gcp.md.tmpl b/templates/resources/cluster_gcp.md.tmpl index a6278993..148012b6 100644 --- a/templates/resources/cluster_gcp.md.tmpl +++ b/templates/resources/cluster_gcp.md.tmpl @@ -62,7 +62,7 @@ resource "spectrocloud_cluster_gcp" "cluster" { machine_pool { control_plane = true control_plane_as_worker = true - name = "master-pool" + name = "cp-pool" count = 1 instance_type = "e2-standard-2" disk_size_gb = 62 diff --git a/templates/resources/cluster_openstack.md.tmpl b/templates/resources/cluster_openstack.md.tmpl index 7defc216..2103c97d 100644 --- a/templates/resources/cluster_openstack.md.tmpl +++ b/templates/resources/cluster_openstack.md.tmpl @@ -49,7 +49,7 @@ resource "spectrocloud_cluster_openstack" "cluster" { machine_pool { control_plane = true control_plane_as_worker = true - name = "master-pool" + name = "cp-pool" count = 1 instance_type = "spectro-xlarge" azs = ["zone1"]