From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E5472E3371 for ; Tue, 1 Apr 2025 01:00:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743469215; cv=none; b=Emi0asY1oRQXcnWGnZsRmgY03Z4Ku08QfPS0gD++JeRIjsSMmDmJfvcopQKklwad90aYGcN+2JGOcw3JhfWY5wA6whzDzf5ySsQgQqJul7r3UV1yk5rv5bitky9Ew3sLJE+Xfy/wPnaHpQy1RUsg7uAor7Zk4FokEitAtQULvPs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743469215; c=relaxed/simple; bh=0dQL5VnJtc1ka1u0DMVaNGu9TiV60JlT5cP8pv7q1OU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jAiv7OUYmFTiIFTrI7tvn9Eg4U0basRc8Ie7tIGtXjOI7rWbPTRHS/yaQJGHDCz3EURaXS5zM9G1wmnW7RfrJ7aNWEA2MeO1SQWeGsf4dRbh2gP+oS7bAgVBYTB2BmEproSPEXAUnK3QfW7J9WaKU31yVGzYxvl+y+SuZyqkTfo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=V/Ys65v1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="V/Ys65v1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD09DC4CEEA; Tue, 1 Apr 2025 01:00:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743469215; bh=0dQL5VnJtc1ka1u0DMVaNGu9TiV60JlT5cP8pv7q1OU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V/Ys65v1a3pqwR95NIPX7LrcC6XD5ChoDx9RHDUcsTNuSrhyq0vNxMDcdGpJPX66D bEn2XDXj9h99a/dqIarkVSalADwzaO6jbhS/TV9k7sk6TLJ+cif9aTFkVdC82EmeR1 wQPXXf3/yHrgtl+9CaHWf6etjpJSsYZf6nlSdRNze/Rjrd/GHDWULpbNdyLnhVkOls w9HMTkL3pLJ549JSwyX6FpKqCmAtRpQpa1Q9szCsfPE7kQTaxiFz0iYjk30sgOt1mg xTUOJ7EyY8ncicuMY1yTHsev7yqbfOSMJSRtc5hRZYbdRHYsLxcEoCuEWWjrnuy8v7 0igc0ltlGfHbg== From: cel@kernel.org To: Cc: Chandan Babu R , Chuck Lever Subject: [RFC PATCH 13/31] terraform/OCI: Add an availability domain selector Date: Mon, 31 Mar 2025 20:59:42 -0400 Message-ID: <20250401010000.764234-14-cel@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250401010000.764234-1-cel@kernel.org> References: <20250401010000.764234-1-cel@kernel.org> Precedence: bulk X-Mailing-List: kdevops@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Chuck Lever In order to balance load, OCI adds a prefix to availability domain names. This prefix is fixed but unique for each user. The user has to look up the prefixed name (at least once) before specifying an availability domain name for terraform, which is not user-friendly. Fortunately, terraform provides a data source to look up the user's unique prefix and form the correct full domain name for terraform. So the Kconfig selector only needs to pick an integer from 1 to 3, and that hides a needless detail from our user. Signed-off-by: Chuck Lever --- .../templates/oci/terraform.tfvars.j2 | 2 +- scripts/terraform.Makefile | 1 - terraform/oci/kconfigs/Kconfig.location | 26 +++++--------- .../kconfigs/regions/Kconfig.ap-hyderabad-1 | 28 +++++++++++++++ .../oci/kconfigs/regions/Kconfig.ap-mumbai-1 | 27 ++++++++++++++ .../kconfigs/regions/Kconfig.ca-montreal-1 | 28 +++++++++++++++ .../oci/kconfigs/regions/Kconfig.ca-toronto-1 | 28 +++++++++++++++ .../oci/kconfigs/regions/Kconfig.us-ashburn-1 | 36 +++++++++++++++++++ .../oci/kconfigs/regions/Kconfig.us-chicago-1 | 36 +++++++++++++++++++ .../oci/kconfigs/regions/Kconfig.us-phoenix-1 | 36 +++++++++++++++++++ .../oci/kconfigs/regions/Kconfig.us-sanjose-1 | 28 +++++++++++++++ terraform/oci/main.tf | 15 ++++---- terraform/oci/vars.tf | 10 +++--- 13 files changed, 270 insertions(+), 31 deletions(-) create mode 100644 terraform/oci/kconfigs/regions/Kconfig.ap-hyderabad-1 create mode 100644 terraform/oci/kconfigs/regions/Kconfig.ap-mumbai-1 create mode 100644 terraform/oci/kconfigs/regions/Kconfig.ca-montreal-1 create mode 100644 terraform/oci/kconfigs/regions/Kconfig.ca-toronto-1 create mode 100644 terraform/oci/kconfigs/regions/Kconfig.us-ashburn-1 create mode 100644 terraform/oci/kconfigs/regions/Kconfig.us-chicago-1 create mode 100644 terraform/oci/kconfigs/regions/Kconfig.us-phoenix-1 create mode 100644 terraform/oci/kconfigs/regions/Kconfig.us-sanjose-1 diff --git a/playbooks/roles/gen_tfvars/templates/oci/terraform.tfvars.j2 b/playbooks/roles/gen_tfvars/templates/oci/terraform.tfvars.j2 index f7b9ffb48c64..864d5d5a89f0 100644 --- a/playbooks/roles/gen_tfvars/templates/oci/terraform.tfvars.j2 +++ b/playbooks/roles/gen_tfvars/templates/oci/terraform.tfvars.j2 @@ -3,7 +3,7 @@ oci_tenancy_ocid = "{{ terraform_oci_tenancy_ocid }}" oci_user_ocid = "{{ terraform_oci_user_ocid }}" oci_user_private_key_path = "{{ terraform_oci_user_private_key_path }}" oci_user_fingerprint = "{{ terraform_oci_user_fingerprint }}" -oci_availablity_domain = "{{ terraform_oci_availablity_domain }}" +oci_ad_number = {{ terraform_oci_ad_number }} oci_compartment_ocid = "{{ terraform_oci_compartment_ocid }}" oci_shape = "{{ terraform_oci_shape }}" oci_instance_flex_ocpus = {{ terraform_oci_instance_flex_ocpus }} diff --git a/scripts/terraform.Makefile b/scripts/terraform.Makefile index ea5309d5da2e..0aca0b508086 100644 --- a/scripts/terraform.Makefile +++ b/scripts/terraform.Makefile @@ -95,7 +95,6 @@ TERRAFORM_EXTRA_VARS += terraform_gce_credentials=$(subst ",,$(CONFIG_TERRAFORM_ endif ifeq (y,$(CONFIG_TERRAFORM_OCI)) -TERRAFORM_EXTRA_VARS += terraform_oci_availablity_domain=$(subst ",,$(CONFIG_TERRAFORM_OCI_AVAILABLITY_DOMAIN)) TERRAFORM_EXTRA_VARS += terraform_oci_compartment_ocid=$(subst ",,$(CONFIG_TERRAFORM_OCI_COMPARTMENT_OCID)) TERRAFORM_EXTRA_VARS += terraform_oci_shape=$(subst ",,$(CONFIG_TERRAFORM_OCI_SHAPE)) TERRAFORM_EXTRA_VARS += terraform_oci_instance_flex_ocpus=$(subst ",,$(CONFIG_TERRAFORM_OCI_INSTANCE_FLEX_OCPUS)) diff --git a/terraform/oci/kconfigs/Kconfig.location b/terraform/oci/kconfigs/Kconfig.location index 9ef81cedd235..7bf5ae49ba03 100644 --- a/terraform/oci/kconfigs/Kconfig.location +++ b/terraform/oci/kconfigs/Kconfig.location @@ -36,24 +36,14 @@ config TERRAFORM_OCI_REGION_SJC endchoice -config TERRAFORM_OCI_REGION - string - output yaml - default "ap-hyderabad-1" if TERRAFORM_OCI_REGION_HYD - default "ap-mumbai-1" if TERRAFORM_OCI_REGION_BOM - default "ca-montreal-1" if TERRAFORM_OCI_REGION_YUL - default "ca-toronto-1" if TERRAFORM_OCI_REGION_YYZ - default "us-ashburn-1" if TERRAFORM_OCI_REGION_IAD - default "us-chicago-1" if TERRAFORM_OCI_REGION_ORD - default "us-phoenix-1" if TERRAFORM_OCI_REGION_PHX - default "us-sanjose-1" if TERRAFORM_OCI_REGION_SJC - -config TERRAFORM_OCI_AVAILABLITY_DOMAIN - string "OCI availablity domain" - help - The name of the availability domain. - Read this: - https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/terraformproviderconfiguration.htm +source "terraform/oci/kconfigs/regions/Kconfig.ap-hyderabad-1" +source "terraform/oci/kconfigs/regions/Kconfig.ap-mumbai-1" +source "terraform/oci/kconfigs/regions/Kconfig.ca-montreal-1" +source "terraform/oci/kconfigs/regions/Kconfig.ca-toronto-1" +source "terraform/oci/kconfigs/regions/Kconfig.us-ashburn-1" +source "terraform/oci/kconfigs/regions/Kconfig.us-chicago-1" +source "terraform/oci/kconfigs/regions/Kconfig.us-phoenix-1" +source "terraform/oci/kconfigs/regions/Kconfig.us-sanjose-1" config TERRAFORM_OCI_COMPARTMENT_OCID string "OCI compartment OCID" diff --git a/terraform/oci/kconfigs/regions/Kconfig.ap-hyderabad-1 b/terraform/oci/kconfigs/regions/Kconfig.ap-hyderabad-1 new file mode 100644 index 000000000000..f4ac37ef38da --- /dev/null +++ b/terraform/oci/kconfigs/regions/Kconfig.ap-hyderabad-1 @@ -0,0 +1,28 @@ +if TERRAFORM_OCI_REGION_HYD + +config TERRAFORM_OCI_REGION + string + output yaml + default "ap-hyderabad-1" + +choice + prompt "Availability Domain" + default TERRAFORM_OCI_REGION_HYD_AD1 + help + The number of the Availability Domain. This number + corresponds to the integer at the end of the Availability + Domain name. + + The OCI Fault Domain is chosen automatically. + +config TERRAFORM_OCI_REGION_HYD_AD1 + bool "1" + +endchoice + +config TERRAFORM_OCI_AD_NUMBER + int + output yaml + default 1 if TERRAFORM_OCI_REGION_HYD_1_AD1 + +endif # TERRAFORM_OCI_REGION_HYD_1 diff --git a/terraform/oci/kconfigs/regions/Kconfig.ap-mumbai-1 b/terraform/oci/kconfigs/regions/Kconfig.ap-mumbai-1 new file mode 100644 index 000000000000..f05b595c3993 --- /dev/null +++ b/terraform/oci/kconfigs/regions/Kconfig.ap-mumbai-1 @@ -0,0 +1,27 @@ +if TERRAFORM_OCI_REGION_BOM + +config TERRAFORM_OCI_REGION + string + output yaml + default "ap-mumbai-1" +choice + prompt "Availability Domain" + default TERRAFORM_OCI_REGION_BOM_AD1 + help + The number of the Availability Domain. This number + corresponds to the integer at the end of the Availability + Domain name. + + The OCI Fault Domain is chosen automatically. + +config TERRAFORM_OCI_REGION_BOM_AD1 + bool "1" + +endchoice + +config TERRAFORM_OCI_AD_NUMBER + int + output yaml + default 1 if TERRAFORM_OCI_REGION_BOM_AD1 + +endif # TERRAFORM_OCI_REGION_BOM diff --git a/terraform/oci/kconfigs/regions/Kconfig.ca-montreal-1 b/terraform/oci/kconfigs/regions/Kconfig.ca-montreal-1 new file mode 100644 index 000000000000..ce71f531e488 --- /dev/null +++ b/terraform/oci/kconfigs/regions/Kconfig.ca-montreal-1 @@ -0,0 +1,28 @@ +if TERRAFORM_OCI_REGION_YUL + +config TERRAFORM_OCI_REGION + string + output yaml + default "ca-montreal-1" + +choice + prompt "Availability Domain" + default TERRAFORM_OCI_REGION_YUL_AD1 + help + The number of the Availability Domain. This number + corresponds to the integer at the end of the Availability + Domain name. + + The OCI Fault Domain is chosen automatically. + +config TERRAFORM_OCI_REGION_YUL_AD1 + bool "1" + +endchoice + +config TERRAFORM_OCI_AD_NUMBER + int + output yaml + default 1 if TERRAFORM_OCI_REGION_YUL_AD1 + +endif # TERRAFORM_OCI_REGION_YUL diff --git a/terraform/oci/kconfigs/regions/Kconfig.ca-toronto-1 b/terraform/oci/kconfigs/regions/Kconfig.ca-toronto-1 new file mode 100644 index 000000000000..16053e94e983 --- /dev/null +++ b/terraform/oci/kconfigs/regions/Kconfig.ca-toronto-1 @@ -0,0 +1,28 @@ +if TERRAFORM_OCI_REGION_YYZ + +config TERRAFORM_OCI_REGION + string + output yaml + default "ca-toronto-1" + +choice + prompt "Availability Domain" + default TERRAFORM_OCI_REGION_YYZ_AD1 + help + The number of the Availability Domain. This number + corresponds to the integer at the end of the Availability + Domain name. + + The OCI Fault Domain is chosen automatically. + +config TERRAFORM_OCI_REGION_YYZ_AD1 + bool "1" + +endchoice + +config TERRAFORM_OCI_AD_NUMBER + int + output yaml + default 1 if TERRAFORM_OCI_REGION_YYZ_AD1 + +endif # TERRAFORM_OCI_REGION_YYZ diff --git a/terraform/oci/kconfigs/regions/Kconfig.us-ashburn-1 b/terraform/oci/kconfigs/regions/Kconfig.us-ashburn-1 new file mode 100644 index 000000000000..9aa4d2714452 --- /dev/null +++ b/terraform/oci/kconfigs/regions/Kconfig.us-ashburn-1 @@ -0,0 +1,36 @@ +if TERRAFORM_OCI_REGION_IAD + +config TERRAFORM_OCI_REGION + string + output yaml + default "us-ashburn-1" + +choice + prompt "Availability Domain" + default TERRAFORM_OCI_REGION_IAD_AD1 + help + The number of the Availability Domain. This number + corresponds to the integer at the end of the Availability + Domain name. + + The OCI Fault Domain is chosen automatically. + +config TERRAFORM_OCI_REGION_IAD_AD1 + bool "1" + +config TERRAFORM_OCI_REGION_IAD_AD2 + bool "2" + +config TERRAFORM_OCI_REGION_IAD_AD3 + bool "3" + +endchoice + +config TERRAFORM_OCI_AD_NUMBER + int + output yaml + default 1 if TERRAFORM_OCI_REGION_IAD_AD1 + default 2 if TERRAFORM_OCI_REGION_IAD_AD2 + default 3 if TERRAFORM_OCI_REGION_IAD_AD3 + +endif # TERRAFORM_OCI_REGION_IAD diff --git a/terraform/oci/kconfigs/regions/Kconfig.us-chicago-1 b/terraform/oci/kconfigs/regions/Kconfig.us-chicago-1 new file mode 100644 index 000000000000..19c3b50c2772 --- /dev/null +++ b/terraform/oci/kconfigs/regions/Kconfig.us-chicago-1 @@ -0,0 +1,36 @@ +if TERRAFORM_OCI_REGION_ORD + +config TERRAFORM_OCI_REGION + string + output yaml + default "us-chicago-1" + +choice + prompt "Availability Domain" + default TERRAFORM_OCI_REGION_ORD_AD1 + help + The number of the Availability Domain. This number + corresponds to the integer at the end of the Availability + Domain name. + + The OCI Fault Domain is chosen automatically. + +config TERRAFORM_OCI_REGION_ORD_AD1 + bool "1" + +config TERRAFORM_OCI_REGION_ORD_AD2 + bool "2" + +config TERRAFORM_OCI_REGION_ORD_AD3 + bool "3" + +endchoice + +config TERRAFORM_OCI_AD_NUMBER + int + output yaml + default 1 if TERRAFORM_OCI_REGION_ORD_AD1 + default 2 if TERRAFORM_OCI_REGION_ORD_AD2 + default 3 if TERRAFORM_OCI_REGION_ORD_AD3 + +endif # TERRAFORM_OCI_REGION_ORD diff --git a/terraform/oci/kconfigs/regions/Kconfig.us-phoenix-1 b/terraform/oci/kconfigs/regions/Kconfig.us-phoenix-1 new file mode 100644 index 000000000000..eb8021191ba3 --- /dev/null +++ b/terraform/oci/kconfigs/regions/Kconfig.us-phoenix-1 @@ -0,0 +1,36 @@ +if TERRAFORM_OCI_REGION_PHX + +config TERRAFORM_OCI_REGION + string + output yaml + default "us-phoenix-1" + +choice + prompt "Availability Domain" + default TERRAFORM_OCI_REGION_PHX_AD1 + help + The number of the Availability Domain. This number + corresponds to the integer at the end of the Availability + Domain name. + + The OCI Fault Domain is chosen automatically. + +config TERRAFORM_OCI_REGION_PHX_AD1 + bool "1" + +config TERRAFORM_OCI_REGION_PHX_AD2 + bool "2" + +config TERRAFORM_OCI_REGION_PHX_AD3 + bool "3" + +endchoice + +config TERRAFORM_OCI_AD_NUMBER + int + output yaml + default 1 if TERRAFORM_OCI_REGION_PHX_AD1 + default 2 if TERRAFORM_OCI_REGION_PHX_AD2 + default 3 if TERRAFORM_OCI_REGION_PHX_AD3 + +endif # TERRAFORM_OCI_REGION_PHX diff --git a/terraform/oci/kconfigs/regions/Kconfig.us-sanjose-1 b/terraform/oci/kconfigs/regions/Kconfig.us-sanjose-1 new file mode 100644 index 000000000000..69b4035f2b9b --- /dev/null +++ b/terraform/oci/kconfigs/regions/Kconfig.us-sanjose-1 @@ -0,0 +1,28 @@ +if TERRAFORM_OCI_REGION_SJC + +config TERRAFORM_OCI_REGION + string + output yaml + default "us-sanjose-1" + +choice + prompt "Availability Domain" + default TERRAFORM_OCI_REGION_SJC_AD1 + help + The number of the Availability Domain. This number + corresponds to the integer at the end of the Availability + Domain name. + + The OCI Fault Domain is chosen automatically. + +config TERRAFORM_OCI_REGION_SJC_AD1 + bool "1" + +endchoice + +config TERRAFORM_OCI_AD_NUMBER + int + output yaml + default 1 if TERRAFORM_OCI_REGION_SJC_AD1 + +endif # TERRAFORM_OCI_REGION_SJC diff --git a/terraform/oci/main.tf b/terraform/oci/main.tf index c96e050b36e2..5520fdbed517 100644 --- a/terraform/oci/main.tf +++ b/terraform/oci/main.tf @@ -1,7 +1,12 @@ +data "oci_identity_availability_domain" "kdevops_av_domain" { + ad_number = var.oci_ad_number + compartment_id = var.oci_tenancy_ocid +} + resource "oci_core_instance" "kdevops_instance" { count = local.kdevops_num_boxes - availability_domain = var.oci_availablity_domain + availability_domain = data.oci_identity_availability_domain.kdevops_av_domain.name compartment_id = var.oci_compartment_ocid shape = var.oci_shape shape_config { @@ -30,9 +35,8 @@ resource "oci_core_instance" "kdevops_instance" { resource "oci_core_volume" "kdevops_data_disk" { count = var.oci_volumes_enable_extra == "true" ? 0 : local.kdevops_num_boxes + availability_domain = data.oci_identity_availability_domain.kdevops_av_domain.name compartment_id = var.oci_compartment_ocid - - availability_domain = var.oci_availablity_domain display_name = var.oci_data_volume_display_name size_in_gbs = 50 } @@ -40,9 +44,8 @@ resource "oci_core_volume" "kdevops_data_disk" { resource "oci_core_volume" "kdevops_sparse_disk" { count = var.oci_volumes_enable_extra == "true" ? 0 : local.kdevops_num_boxes + availability_domain = data.oci_identity_availability_domain.kdevops_av_domain.name compartment_id = var.oci_compartment_ocid - - availability_domain = var.oci_availablity_domain display_name = var.oci_sparse_volume_display_name size_in_gbs = 120 } @@ -71,7 +74,7 @@ module "volumes" { count = var.oci_volumes_enable_extra == "true" ? local.kdevops_num_boxes : 0 source = "./volumes" - vol_availability_domain = var.oci_availablity_domain + vol_availability_domain = data.oci_identity_availability_domain.kdevops_av_domain.name vol_compartment_ocid = var.oci_compartment_ocid vol_instance_id = element(oci_core_instance.kdevops_instance.*.id, count.index) vol_instance_name = element(var.kdevops_nodes, count.index) diff --git a/terraform/oci/vars.tf b/terraform/oci/vars.tf index 4c6383d9b231..05c3f3769e94 100644 --- a/terraform/oci/vars.tf +++ b/terraform/oci/vars.tf @@ -1,3 +1,8 @@ +variable "oci_ad_number" { + description = "Suffix number of availability domain" + type = number +} + variable "oci_region" { description = "An OCI region" type = string @@ -23,11 +28,6 @@ variable "oci_user_fingerprint" { type = string } -variable "oci_availablity_domain" { - description = "Name of availability domain" - type = string -} - variable "oci_compartment_ocid" { description = "OCID of compartment" type = string -- 2.48.1