From patchwork Wed Mar 5 21:12:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 14003383 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 B895D155342 for ; Wed, 5 Mar 2025 21:12:10 +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=1741209130; cv=none; b=tp5cfvINpmMhK8PnluG8f83sgFazNoTnrnoiWsqCzL2y0eO1yIyLW2h9E14+RkojH9izM5emuR3EnzE8Jnb+j6weAr0pB1whWIhu2I/R0yQA/I5ErUHFt9BKs+jZSV8uHt6JhRwCl10Mpn+GZuj+368/h9mJcFFHsfZYgwVmRto= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741209130; c=relaxed/simple; bh=5FqteES2O5qB4oi35bvBoxBi/MPK/1W/RFjAkH1Lufo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=RI56Vwdzn6plTBER49PACpUasJO+8BAEN80nnPcs9E3ytHmYRNUND646vBi1vt85NPmd8P0hmQDCRqdUD84bHaoNaiqJm/TdgxbyYbjP71yJdRcU2KTCn3ff9p0F0xVYgtSN5ZVksD4eu5KM7MO1WK1iaGGb2RH7OeECxu/1xLY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dm9Lj2r7; 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="dm9Lj2r7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B1B0C4CED1; Wed, 5 Mar 2025 21:12:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741209130; bh=5FqteES2O5qB4oi35bvBoxBi/MPK/1W/RFjAkH1Lufo=; h=From:To:Cc:Subject:Date:From; b=dm9Lj2r7MlSmzGFmYkKxOU7djH6ASConaMmFo9WuWrPrnGWingWy3O+1Ne+yAMQhB tTn/23yd5nSbXwmziTT5tcio5Hv5WunimmnkP4EMG2Nz2Zh/DFEgI4jP5kVPjTg2Yo sRJeJO9a5OWwFhtJgvnsG/8riMJSSy2mC7sNxeGS8Zwlhmk8/3l1RpsoBvRGO7zJ80 J1R7rIPFdMsGkaTaRSb/AyWmHTPwdrX2M0WmcSaGqVgB3QR/83tbI+Tr0IvLsKAPXr QrhCdA33v5Bf3rZXLcOxX20EIhViW6mlr7nSh/xMJTPj3a4gSAhtux1825NjNkigiv /Z6Dh3Gpq+Ndg== From: cel@kernel.org To: Luis Chamberlain , chandanbabu@kernel.org Cc: , Chuck Lever Subject: [RFC PATCH] terraform/OCI: Create a set of multiple generic block devices Date: Wed, 5 Mar 2025 16:12:07 -0500 Message-ID: <20250305211207.243174-1-cel@kernel.org> X-Mailer: git-send-email 2.48.1 Precedence: bulk X-Mailing-List: kdevops@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Chuck Lever When provisioning on OCI, terraform creates one block device for the /data file system, and one for sparse files. This is unlike other provisioning methods (guestfs and AWS being the primary examples) which instead create a set of generic block devices and then set up the sparse files or /data file system on one of those. Luis and Chandan have agreed to changing OCI to work like the other terraform providers and guestfs. Signed-off-by: Chuck Lever Reviewed-by: Chandan Babu R --- .../templates/oci/terraform.tfvars.j2 | 6 + terraform/oci/Kconfig | 160 ++++++++++++++++++ terraform/oci/main.tf | 23 ++- terraform/oci/vars.tf | 17 ++ 4 files changed, 202 insertions(+), 4 deletions(-) This seems to do what we want. For the moment, this facility is gated behind a Kconfig boolean so you can revert back to the old data/sparse configuratino quickly. Testing will confirm if we need to keep this revert setting. diff --git a/playbooks/roles/gen_tfvars/templates/oci/terraform.tfvars.j2 b/playbooks/roles/gen_tfvars/templates/oci/terraform.tfvars.j2 index 6429c7289f52..2d45fd77d510 100644 --- a/playbooks/roles/gen_tfvars/templates/oci/terraform.tfvars.j2 +++ b/playbooks/roles/gen_tfvars/templates/oci/terraform.tfvars.j2 @@ -12,10 +12,16 @@ oci_os_image_ocid = "{{ terraform_oci_os_image_ocid }}" oci_assign_public_ip = "{{ terraform_oci_assign_public_ip | lower }}" oci_instance_display_name = "{{ terraform_oci_instance_display_name }}" oci_subnet_ocid = "{{ terraform_oci_subnet_ocid }}" +oci_volumes_enable_extra = "{{ terraform_oci_volumes_enable_extra | lower }}" +{% if terraform_oci_volumes_enable_extra %} +oci_volumes_per_instance = {{ terraform_oci_volumes_per_instance }} +oci_volumes_size = {{ terraform_oci_volumes_size }} +{% else %} oci_data_volume_display_name = "{{ terraform_oci_data_volume_display_name }}" oci_data_volume_device_file_name = "{{ terraform_oci_data_volume_device_file_name }}" oci_sparse_volume_display_name = "{{ terraform_oci_sparse_volume_display_name }}" oci_sparse_volume_device_file_name = "{{ terraform_oci_sparse_volume_device_file_name }}" +{% endif %} ssh_config_pubkey_file = "{{ kdevops_terraform_ssh_config_pubkey_file }}" ssh_config_user = "{{ kdevops_terraform_ssh_config_user }}" diff --git a/terraform/oci/Kconfig b/terraform/oci/Kconfig index 4b37ad91d4b9..08eb239fcc5c 100644 --- a/terraform/oci/Kconfig +++ b/terraform/oci/Kconfig @@ -90,6 +90,160 @@ config TERRAFORM_OCI_SUBNET_OCID Read this: https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/terraformproviderconfiguration.htm +config TERRAFORM_OCI_VOLUMES_ENABLE_EXTRA + bool "Enable additional block devices" + output yaml + default n + help + Enable this to provision up to 10 extra block devices + on each target node. + +if TERRAFORM_OCI_VOLUMES_ENABLE_EXTRA + +choice + prompt "Count of extra block volumes" + default TERRAFORM_OCI_VOLUMES_PER_INSTANCE_4 + help + The count of extra block devices attached to each target + node. + +config TERRAFORM_OCI_VOLUMES_PER_INSTANCE_1 + bool "1" + help + Provision 1 extra volume per target node. + +config TERRAFORM_OCI_VOLUMES_PER_INSTANCE_2 + bool "2" + help + Provision 2 extra volumes per target node. + +config TERRAFORM_OCI_VOLUMES_PER_INSTANCE_3 + bool "3" + help + Provision 3 extra volumes per target node. + +config TERRAFORM_OCI_VOLUMES_PER_INSTANCE_4 + bool "4" + help + Provision 4 extra volumes per target node. + +config TERRAFORM_OCI_VOLUMES_PER_INSTANCE_5 + bool "5" + help + Provision 5 extra volumes per target node. + +config TERRAFORM_OCI_VOLUMES_PER_INSTANCE_6 + bool "6" + help + Provision 6 extra volumes per target node. + +config TERRAFORM_OCI_VOLUMES_PER_INSTANCE_7 + bool "7" + help + Provision 7 extra volumes per target node. + +config TERRAFORM_OCI_VOLUMES_PER_INSTANCE_8 + bool "8" + help + Provision 8 extra volumes per target node. + +config TERRAFORM_OCI_VOLUMES_PER_INSTANCE_9 + bool "9" + help + Provision 9 extra volumes per target node. + +config TERRAFORM_OCI_VOLUMES_PER_INSTANCE_10 + bool "10" + help + Provision 10 extra volumes per target node. + +endchoice + +config TERRAFORM_OCI_VOLUMES_PER_INSTANCE + int + output yaml + default 1 if TERRAFORM_OCI_VOLUMES_PER_INSTANCE_1 + default 2 if TERRAFORM_OCI_VOLUMES_PER_INSTANCE_2 + default 3 if TERRAFORM_OCI_VOLUMES_PER_INSTANCE_3 + default 4 if TERRAFORM_OCI_VOLUMES_PER_INSTANCE_4 + default 5 if TERRAFORM_OCI_VOLUMES_PER_INSTANCE_5 + default 6 if TERRAFORM_OCI_VOLUMES_PER_INSTANCE_6 + default 7 if TERRAFORM_OCI_VOLUMES_PER_INSTANCE_7 + default 8 if TERRAFORM_OCI_VOLUMES_PER_INSTANCE_8 + default 9 if TERRAFORM_OCI_VOLUMES_PER_INSTANCE_9 + default 10 if TERRAFORM_OCI_VOLUMES_PER_INSTANCE_10 + +choice + prompt "Volume size for each additional volume" + default TERRAFORM_OCI_VOLUMES_SIZE_50G + help + OCI implements volume sizes between 50G and 32T. In some + cases, 50G volumes are in the free tier. + +config TERRAFORM_OCI_VOLUMES_SIZE_50G + bool "50G" + help + Extra block volumes are 50 GiB in size. + +config TERRAFORM_OCI_VOLUMES_SIZE_64G + bool "64G" + help + Extra block volumes are 64 GiB in size. + +config TERRAFORM_OCI_VOLUMES_SIZE_128G + bool "128G" + help + Extra block volumes are 128 GiB in size. + +config TERRAFORM_OCI_VOLUMES_SIZE_256G + bool "256G" + help + Extra block volumes are 256 GiB in size. + +config TERRAFORM_OCI_VOLUMES_SIZE_512G + bool "512G" + help + Extra block volumes are 512 GiB in size. + +config TERRAFORM_OCI_VOLUMES_SIZE_1024G + bool "1024G" + help + Extra block volumes are 1024 GiB in size. + +config TERRAFORM_OCI_VOLUMES_SIZE_2048G + bool "2048G" + help + Extra block volumes are 2048 GiB in size. + +config TERRAFORM_OCI_VOLUMES_SIZE_4096G + bool "4096G" + help + Extra block volumes are 4096 GiB in size. + +config TERRAFORM_OCI_VOLUMES_SIZE_8192G + bool "8192G" + help + Extra block volumes are 8192 GiB in size. + +endchoice + +config TERRAFORM_OCI_VOLUMES_SIZE + int + output yaml + default 50 if TERRAFORM_OCI_VOLUMES_SIZE_50G + default 64 if TERRAFORM_OCI_VOLUMES_SIZE_64G + default 128 if TERRAFORM_OCI_VOLUMES_SIZE_128G + default 256 if TERRAFORM_OCI_VOLUMES_SIZE_256G + default 512 if TERRAFORM_OCI_VOLUMES_SIZE_512G + default 1024 if TERRAFORM_OCI_VOLUMES_SIZE_1024G + default 2048 if TERRAFORM_OCI_VOLUMES_SIZE_2048G + default 4096 if TERRAFORM_OCI_VOLUMES_SIZE_4096G + default 8192 if TERRAFORM_OCI_VOLUMES_SIZE_8192G + +endif # TERRAFORM_OCI_VOLUMES_ENABLE_EXTRA + +if !TERRAFORM_OCI_VOLUMES_ENABLE_EXTRA + config TERRAFORM_OCI_DATA_VOLUME_DISPLAY_NAME string "Display name to use for the data volume" default "data" @@ -98,6 +252,8 @@ config TERRAFORM_OCI_DATA_VOLUME_DISPLAY_NAME Read this: https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/terraformproviderconfiguration.htm +endif # !TERRAFORM_OCI_VOLUMES_ENABLE_EXTRA + config TERRAFORM_OCI_DATA_VOLUME_DEVICE_FILE_NAME string "Data volume's device file name" default "/dev/oracleoci/oraclevdb" @@ -106,6 +262,8 @@ config TERRAFORM_OCI_DATA_VOLUME_DEVICE_FILE_NAME Read this: https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/terraformproviderconfiguration.htm +if !TERRAFORM_OCI_VOLUMES_ENABLE_EXTRA + config TERRAFORM_OCI_SPARSE_VOLUME_DISPLAY_NAME string "Display name to use for the sparse volume" default "sparse" @@ -114,6 +272,8 @@ config TERRAFORM_OCI_SPARSE_VOLUME_DISPLAY_NAME Read this: https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/terraformproviderconfiguration.htm +endif # !TERRAFORM_OCI_VOLUMES_ENABLE_EXTRA + config TERRAFORM_OCI_SPARSE_VOLUME_DEVICE_FILE_NAME string "Sparse volume's device file name" default "/dev/oracleoci/oraclevdc" diff --git a/terraform/oci/main.tf b/terraform/oci/main.tf index 033f821d9502..05e51d6bef89 100644 --- a/terraform/oci/main.tf +++ b/terraform/oci/main.tf @@ -28,7 +28,7 @@ resource "oci_core_instance" "kdevops_instance" { } resource "oci_core_volume" "kdevops_data_disk" { - count = local.kdevops_num_boxes + count = var.oci_volumes_enable_extra == "true" ? 0 : local.kdevops_num_boxes compartment_id = var.oci_compartment_ocid @@ -38,7 +38,7 @@ resource "oci_core_volume" "kdevops_data_disk" { } resource "oci_core_volume" "kdevops_sparse_disk" { - count = local.kdevops_num_boxes + count = var.oci_volumes_enable_extra == "true" ? 0 : local.kdevops_num_boxes compartment_id = var.oci_compartment_ocid @@ -48,7 +48,7 @@ resource "oci_core_volume" "kdevops_sparse_disk" { } resource "oci_core_volume_attachment" "kdevops_data_volume_attachment" { - count = local.kdevops_num_boxes + count = var.oci_volumes_enable_extra == "true" ? 0 : local.kdevops_num_boxes attachment_type = "paravirtualized" instance_id = element(oci_core_instance.kdevops_instance.*.id, count.index) @@ -58,7 +58,7 @@ resource "oci_core_volume_attachment" "kdevops_data_volume_attachment" { } resource "oci_core_volume_attachment" "kdevops_sparse_disk_attachment" { - count = local.kdevops_num_boxes + count = var.oci_volumes_enable_extra == "true" ? 0 : local.kdevops_num_boxes attachment_type = "paravirtualized" instance_id = element(oci_core_instance.kdevops_instance.*.id, count.index) @@ -66,3 +66,18 @@ resource "oci_core_volume_attachment" "kdevops_sparse_disk_attachment" { device = var.oci_sparse_volume_device_file_name } + +resource "oci_core_volume" "kdevops_volume_extra" { + count = var.oci_volumes_enable_extra == "false" ? 0 : local.kdevops_num_boxes * var.oci_volumes_per_instance + availability_domain = var.oci_availablity_domain + display_name = format("kdevops_volume-%02d", count.index + 1) + compartment_id = var.oci_compartment_ocid + size_in_gbs = var.oci_volumes_size +} + +resource "oci_core_volume_attachment" "kdevops_volume_extra_att" { + count = var.oci_volumes_enable_extra == "false" ? 0 : local.kdevops_num_boxes * var.oci_volumes_per_instance + attachment_type = "paravirtualized" + instance_id = element(oci_core_instance.kdevops_instance.*.id, count.index) + volume_id = element(oci_core_volume.kdevops_volume_extra.*.id, count.index) +} diff --git a/terraform/oci/vars.tf b/terraform/oci/vars.tf index b02e79c597ec..5642bd7d5f63 100644 --- a/terraform/oci/vars.tf +++ b/terraform/oci/vars.tf @@ -70,6 +70,23 @@ variable "oci_subnet_ocid" { default = "" } +variable "oci_volumes_enable_extra" { + description = "Create additional block volumes per instance" + default = false +} + +variable "oci_volumes_per_instance" { + description = "The count of additional block volumes per instance" + type = number + default = null +} + +variable "oci_volumes_size" { + description = "The size of additional block volumes, in gibibytes" + type = number + default = null +} + variable "oci_data_volume_display_name" { description = "Display name to use for the data volume" default = "data"