From patchwork Mon Mar 10 14:18:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 14010079 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 7A71D1A314B for ; Mon, 10 Mar 2025 14:18:19 +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=1741616299; cv=none; b=sYuxjr68aAEiV3gQcESn8FIO/LPMVt5c4y7d2p5UWlwHqo/f3D3Ofv315gZ4j+0zCSWvU3aMwC04gKSsGQivettkoJdesH+fjGPXAN6BY/kaMtOVpQjheduimDpgQolxf6mRzFBUa8nJU1ToS4zKiJNlL7TE8YZeewz776PqyfA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741616299; c=relaxed/simple; bh=ZYJTFJZFOedU9M9pG5Ajp5MUldJUm6wMV11uSX4bpps=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sVYSPulcAx9+AaZ+MP6aKQ8PcBMUOgcP4uzkEEMluqV+fWLZM0+06BOjksDHMnNOMuXFly5YEO+YvVHNbE/QAcS4xEQ+uT0Ly7jolBvVBio64TirwuQ1j4nMQp/8Bm7Vpyz+TeOpNsMZVe4uFXE5QehQonVFID4m1l+8VTUFhe0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EHKTLYiS; 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="EHKTLYiS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2B03C4CEED; Mon, 10 Mar 2025 14:18:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741616299; bh=ZYJTFJZFOedU9M9pG5Ajp5MUldJUm6wMV11uSX4bpps=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EHKTLYiS9dVjQteb20AgAX1u5JyAlPcugyA32lNLfENVTkaWmHOl1dS7UzJbq9TjH yoemy0LACxy3V8T8MD2W3PC9uvsZo+ZCriu7SCV1WMNP2qzSDv6S5sC1swPRxcq8Fe FpwR/dRGmXd9ZseaG1XV6eKWlCMdRCab9XZSoURIGDeJEm5aIEDwPqueK6n0c3W7aD 6PWv8xURytLRrMDzjK8lvYTG7YjB0m6f0jvN1Krz9fISOtphWAwX9qxDyaNFfo8SyO d3qzgKkQNNeESL9TbBfzmvqAwp/ukxDYKNo6fqO+slsTv9uriEMPYvynBdt488pF3i sDz8NnjEF4zVQ== From: cel@kernel.org To: Luis Chamberlain , Chandan Babu R , Jeff Layton Cc: , Chuck Lever Subject: [PATCH v1 04/13] terraform/OCI: Create a set of multiple generic block devices Date: Mon, 10 Mar 2025 10:18:04 -0400 Message-ID: <20250310141813.969325-5-cel@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250310141813.969325-1-cel@kernel.org> References: <20250310141813.969325-1-cel@kernel.org> 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 + scripts/terraform.Makefile | 9 +- terraform/oci/Kconfig | 153 ++++++++++++++++++ terraform/oci/main.tf | 28 +++- terraform/oci/vars.tf | 17 ++ 5 files changed, 208 insertions(+), 5 deletions(-) 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/scripts/terraform.Makefile b/scripts/terraform.Makefile index 19c2384fb2ad..e3d8c6b003ce 100644 --- a/scripts/terraform.Makefile +++ b/scripts/terraform.Makefile @@ -104,10 +104,17 @@ else TERRAFORM_EXTRA_VARS += terraform_oci_assign_public_ip=false endif TERRAFORM_EXTRA_VARS += terraform_oci_subnet_ocid=$(subst ",,$(CONFIG_TERRAFORM_OCI_SUBNET_OCID)) + +ifeq (y, $(CONFIG_TERRAFORM_OCI_VOLUMES_ENABLE_EXTRA)) +TERRAFORM_EXTRA_VARS += terraform_oci_volumes_enable_extra=true +else +TERRAFORM_EXTRA_VARS += terraform_oci_volumes_enable_extra=false TERRAFORM_EXTRA_VARS += terraform_oci_data_volume_display_name=$(subst ",,$(CONFIG_TERRAFORM_OCI_DATA_VOLUME_DISPLAY_NAME)) -TERRAFORM_EXTRA_VARS += terraform_oci_data_volume_device_file_name=$(subst ",,$(CONFIG_TERRAFORM_OCI_DATA_VOLUME_DEVICE_FILE_NAME)) TERRAFORM_EXTRA_VARS += terraform_oci_sparse_volume_display_name=$(subst ",,$(CONFIG_TERRAFORM_OCI_SPARSE_VOLUME_DISPLAY_NAME)) +endif +TERRAFORM_EXTRA_VARS += terraform_oci_data_volume_device_file_name=$(subst ",,$(CONFIG_TERRAFORM_OCI_DATA_VOLUME_DEVICE_FILE_NAME)) TERRAFORM_EXTRA_VARS += terraform_oci_sparse_volume_device_file_name=$(subst ",,$(CONFIG_TERRAFORM_OCI_SPARSE_VOLUME_DEVICE_FILE_NAME)) + endif ifeq (y,$(CONFIG_TERRAFORM_OPENSTACK)) diff --git a/terraform/oci/Kconfig b/terraform/oci/Kconfig index 4b37ad91d4b9..00f03163ed83 100644 --- a/terraform/oci/Kconfig +++ b/terraform/oci/Kconfig @@ -90,6 +90,153 @@ 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" + 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_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 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 +245,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 +255,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 +265,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..c3c477a6b4bd 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,23 @@ 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 +} + +locals { + volume_name_suffixes = [ "b", "c", "d", "e", "f", "g", "h", "i", "j", "k" ] +} + +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) + device = format("/dev/oracleoci/oraclevd%s", element(local.volume_name_suffixes, count.index)) +} diff --git a/terraform/oci/vars.tf b/terraform/oci/vars.tf index b02e79c597ec..077a9a4afdaa 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 = 0 +} + +variable "oci_volumes_size" { + description = "The size of additional block volumes, in gibibytes" + type = number + default = 0 +} + variable "oci_data_volume_display_name" { description = "Display name to use for the data volume" default = "data"