From: cel@kernel.org
To: Luis Chamberlain <mcgrof@kernel.org>,
Chandan Babu R <chandanbabu@kernel.org>,
Jeff Layton <jlayton@kernel.org>
Cc: <kdevops@lists.linux.dev>, Chuck Lever <chuck.lever@oracle.com>
Subject: [PATCH v1 04/13] terraform/OCI: Create a set of multiple generic block devices
Date: Mon, 10 Mar 2025 10:18:04 -0400 [thread overview]
Message-ID: <20250310141813.969325-5-cel@kernel.org> (raw)
In-Reply-To: <20250310141813.969325-1-cel@kernel.org>
From: Chuck Lever <chuck.lever@oracle.com>
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 <chuck.lever@oracle.com>
---
.../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"
--
2.48.1
next prev parent reply other threads:[~2025-03-10 14:18 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-10 14:18 [PATCH v1 00/13] Block device provisioning for storage nodes cel
2025-03-10 14:18 ` [PATCH v1 01/13] terraform/AWS: Upgrade the EBS volume type to "gp3" cel
2025-03-10 14:18 ` [PATCH v1 02/13] terraform/Azure: Remove managed_disk_type selection cel
2025-03-10 14:18 ` [PATCH v1 03/13] terraform/Azure: Create a set of multiple generic block devices cel
2025-03-10 14:18 ` cel [this message]
2025-03-13 5:56 ` [PATCH v1 04/13] terraform/OCI: " Chandan Babu R
2025-03-10 14:18 ` [PATCH v1 05/13] guestfs: Set storage options consistently cel
2025-03-10 14:18 ` [PATCH v1 06/13] playbooks: Add a role to create an LVM volume group cel
2025-03-10 14:18 ` [PATCH v1 07/13] volume_group: Detect the /data partition directly cel
2025-03-10 14:18 ` [PATCH v1 08/13] volume_group: Prepare to support cloud providers cel
2025-03-10 14:18 ` [PATCH v1 09/13] volume_group: Create volume group on terraform/AWS nodes cel
2025-03-10 14:18 ` [PATCH v1 10/13] volume_group: Create a volume group on Azure nodes cel
2025-03-10 14:18 ` [PATCH v1 11/13] volume_group: Create a volume group on GCE nodes cel
2025-03-10 14:18 ` [PATCH v1 12/13] volume_group: Create a volume group on OCI nodes cel
2025-03-13 6:29 ` Chandan Babu R
2025-03-10 14:18 ` [PATCH v1 13/13] volume_group: Create a volume group on OpenStack public clouds cel
2025-03-11 3:29 ` [PATCH v1 00/13] Block device provisioning for storage nodes Luis Chamberlain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250310141813.969325-5-cel@kernel.org \
--to=cel@kernel.org \
--cc=chandanbabu@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=jlayton@kernel.org \
--cc=kdevops@lists.linux.dev \
--cc=mcgrof@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox