From c4dace6b3c71ffad6219096b1524c63fcd94d4e1 Mon Sep 17 00:00:00 2001 From: Chandan Abhyankar Date: Tue, 2 Jul 2024 04:20:08 -0700 Subject: [PATCH 1/8] OPENSHIFTP-145: cluster network mtu can be externally configured Signed-off-by: Chandan Abhyankar --- main.tf | 1 + modules/4_pvs_support/pvs_support.tf | 37 +++++++++++++++++++++++++--- modules/4_pvs_support/variables.tf | 1 + variables.tf | 5 ++++ 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/main.tf b/main.tf index c3e8ce5..d3c1ae7 100644 --- a/main.tf +++ b/main.tf @@ -152,6 +152,7 @@ module "support" { worker = var.worker nfs_server = module.vpc_support.vpc_support_server_ip nfs_path = var.nfs_path + cluster_network_mtu = var.cluster_network_mtu } module "worker" { diff --git a/modules/4_pvs_support/pvs_support.tf b/modules/4_pvs_support/pvs_support.tf index 0613437..05d2ad0 100644 --- a/modules/4_pvs_support/pvs_support.tf +++ b/modules/4_pvs_support/pvs_support.tf @@ -196,13 +196,25 @@ resource "null_resource" "adjust_mtu" { timeout = "${var.connection_timeout}m" } - # The mtu.network.to was originally targetting 9000, and has been moved to 1350 based on the VPC/IBM Cloud configurations. + # The mtu.network.to was originally targetting 9000, and has been moved to ${var.cluster_network_mtu} (Default 1350) based on the VPC/IBM Cloud configurations. User can override it by setting desired value in var.tfvars file # we previously supported OpenShiftSDN since it's deprecation we have removed it from automation. provisioner "remote-exec" { inline = [<&1 | grep TARGET_MTU=9100) while [ -z "$${CHECK_CONFIG}" ] diff --git a/modules/4_pvs_support/variables.tf b/modules/4_pvs_support/variables.tf index b06841f..ee3e532 100644 --- a/modules/4_pvs_support/variables.tf +++ b/modules/4_pvs_support/variables.tf @@ -19,6 +19,7 @@ variable "powervs_machine_cidr" {} variable "keep_dns" {} variable "nfs_server" {} variable "nfs_path" {} +variable "cluster_network_mtu" {} variable "worker" { type = object({ count = number, memory = string, processors = string }) default = { diff --git a/variables.tf b/variables.tf index cac29b5..c6f0f47 100644 --- a/variables.tf +++ b/variables.tf @@ -317,6 +317,11 @@ variable "use_zone_info_for_names" { description = "Add zone info to instance name or not" } +variable "cluster_network_mtu" { + type = number + description = "MTU value for the OCP cluster network" + default = 1350 +} ################################################################ # Additional Settings ################################################################ From bc8ff901fca8c85804d4d47bc7b64ac5733d8241 Mon Sep 17 00:00:00 2001 From: Chandan Abhyankar Date: Thu, 4 Jul 2024 10:50:55 +0530 Subject: [PATCH 2/8] Update modules/4_pvs_support/pvs_support.tf Co-authored-by: Paul Bastide --- modules/4_pvs_support/pvs_support.tf | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/4_pvs_support/pvs_support.tf b/modules/4_pvs_support/pvs_support.tf index 05d2ad0..2efba32 100644 --- a/modules/4_pvs_support/pvs_support.tf +++ b/modules/4_pvs_support/pvs_support.tf @@ -336,6 +336,7 @@ do # Break the loop if timeout occurs if [ $start_counter -gt $timeout_counter ] then + echo "exceeding the loop timeout: $${start_counter}" break fi done From 637910760ec265578f752e32557e9577145ad66f Mon Sep 17 00:00:00 2001 From: Chandan Abhyankar Date: Thu, 4 Jul 2024 10:51:11 +0530 Subject: [PATCH 3/8] Update modules/4_pvs_support/pvs_support.tf Co-authored-by: Paul Bastide --- modules/4_pvs_support/pvs_support.tf | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/4_pvs_support/pvs_support.tf b/modules/4_pvs_support/pvs_support.tf index 2efba32..2b92522 100644 --- a/modules/4_pvs_support/pvs_support.tf +++ b/modules/4_pvs_support/pvs_support.tf @@ -214,7 +214,6 @@ then else echo "clusterNetworkMTU is already set to ${var.cluster_network_mtu}" fi - EOF ] } From 59bd63c378dc07848e7f758876c89a3b6b1f7698 Mon Sep 17 00:00:00 2001 From: Chandan Abhyankar Date: Thu, 4 Jul 2024 13:48:58 +0530 Subject: [PATCH 4/8] Update modules/4_pvs_support/pvs_support.tf Co-authored-by: Paul Bastide --- modules/4_pvs_support/pvs_support.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/4_pvs_support/pvs_support.tf b/modules/4_pvs_support/pvs_support.tf index 2b92522..44a5804 100644 --- a/modules/4_pvs_support/pvs_support.tf +++ b/modules/4_pvs_support/pvs_support.tf @@ -202,7 +202,7 @@ resource "null_resource" "adjust_mtu" { inline = [< Date: Thu, 4 Jul 2024 13:49:44 +0530 Subject: [PATCH 5/8] Update modules/4_pvs_support/pvs_support.tf Co-authored-by: Paul Bastide --- modules/4_pvs_support/pvs_support.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/4_pvs_support/pvs_support.tf b/modules/4_pvs_support/pvs_support.tf index 44a5804..c4f078d 100644 --- a/modules/4_pvs_support/pvs_support.tf +++ b/modules/4_pvs_support/pvs_support.tf @@ -325,7 +325,7 @@ cl_network_mtu=$(oc get network cluster -o yaml | grep -i clusterNetworkMTU | aw echo "(DEBUG) clusterNetworkMTU FOUND?: $${cl_network_mtu}" # While loop waits for clusterNetworkMTU=var.cluster_network_mtu (Default 1350) till timeout has not reached -while [[ "$(oc get network cluster -o yaml | grep -i clusterNetworkMTU | awk '{print $2}')" != "${var.cluster_network_mtu}" ]] +while [[ "$(oc get network cluster -o json | jq -r .status.clusterNetworkMTU)" != "${var.cluster_network_mtu}" ]] do echo "waiting for clusterNetworkMTU to be ${var.cluster_network_mtu}" sleep 30 From 3a7ade93e6982611330a6060c37fc980ae13a1a6 Mon Sep 17 00:00:00 2001 From: Chandan Abhyankar Date: Thu, 4 Jul 2024 13:50:20 +0530 Subject: [PATCH 6/8] Update modules/4_pvs_support/pvs_support.tf Co-authored-by: Paul Bastide --- modules/4_pvs_support/pvs_support.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/4_pvs_support/pvs_support.tf b/modules/4_pvs_support/pvs_support.tf index c4f078d..aca824c 100644 --- a/modules/4_pvs_support/pvs_support.tf +++ b/modules/4_pvs_support/pvs_support.tf @@ -321,7 +321,7 @@ do done # Check clusterNetworkMTU -cl_network_mtu=$(oc get network cluster -o yaml | grep -i clusterNetworkMTU | awk '{print $2}') +cl_network_mtu=$(oc get network cluster -o json | jq -r .status.clusterNetworkMTU) echo "(DEBUG) clusterNetworkMTU FOUND?: $${cl_network_mtu}" # While loop waits for clusterNetworkMTU=var.cluster_network_mtu (Default 1350) till timeout has not reached From b266790325d9255fe85fbff0755538f89c486842 Mon Sep 17 00:00:00 2001 From: Chandan Abhyankar Date: Thu, 4 Jul 2024 13:53:31 +0530 Subject: [PATCH 7/8] Update modules/4_pvs_support/pvs_support.tf Co-authored-by: Paul Bastide --- modules/4_pvs_support/pvs_support.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/4_pvs_support/pvs_support.tf b/modules/4_pvs_support/pvs_support.tf index aca824c..f1b5b0a 100644 --- a/modules/4_pvs_support/pvs_support.tf +++ b/modules/4_pvs_support/pvs_support.tf @@ -207,9 +207,9 @@ EXISTING_MTU=$(oc get network cluster -o json | jq -r .status.clusterNetworkMTU) if [ $EXISTING_MTU != ${var.cluster_network_mtu} ] then echo "Setting clusterNetworkMTU to ${var.cluster_network_mtu}" - output=$(oc patch Network.operator.openshift.io cluster --type=merge --patch \ - '{"spec": { "migration": { "mtu": { "network": { "from": '$EXISTING_MTU', "to": ${var.cluster_network_mtu} } , "machine": { "to" : 9100} } } } }') - echo "Patch command output is $output" + echo "Patch command output is:" + oc patch Network.operator.openshift.io cluster --type=merge --patch \ + '{"spec": { "migration": { "mtu": { "network": { "from": '$EXISTING_MTU', "to": ${var.cluster_network_mtu} } , "machine": { "to" : 9100} } } } }' else echo "clusterNetworkMTU is already set to ${var.cluster_network_mtu}" From d08e58e373a32d37df1ffce0e90f9fea339ab091 Mon Sep 17 00:00:00 2001 From: Chandan Abhyankar Date: Thu, 4 Jul 2024 13:53:40 +0530 Subject: [PATCH 8/8] Update modules/4_pvs_support/pvs_support.tf Co-authored-by: Paul Bastide --- modules/4_pvs_support/pvs_support.tf | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/4_pvs_support/pvs_support.tf b/modules/4_pvs_support/pvs_support.tf index f1b5b0a..1b9ebce 100644 --- a/modules/4_pvs_support/pvs_support.tf +++ b/modules/4_pvs_support/pvs_support.tf @@ -210,7 +210,6 @@ then echo "Patch command output is:" oc patch Network.operator.openshift.io cluster --type=merge --patch \ '{"spec": { "migration": { "mtu": { "network": { "from": '$EXISTING_MTU', "to": ${var.cluster_network_mtu} } , "machine": { "to" : 9100} } } } }' - else echo "clusterNetworkMTU is already set to ${var.cluster_network_mtu}" fi