Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPENSHIFTP-145: cluster network mtu can be externally configured #59

Merged
merged 8 commits into from
Jul 4, 2024
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
37 changes: 34 additions & 3 deletions modules/4_pvs_support/pvs_support.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [<<EOF
export HTTPS_PROXY="http://${var.vpc_support_server_ip}:3128"
oc patch Network.operator.openshift.io cluster --type=merge --patch \
'{"spec": { "migration": { "mtu": { "network": { "from": 1400, "to": 1350 } , "machine": { "to" : 9100} } } } }'

EXISTING_MTU=$(oc get network cluster -o yaml | grep -i clusterNetworkMTU | awk '{print $2}')
Chandan-Abhyankar marked this conversation as resolved.
Show resolved Hide resolved

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"
Chandan-Abhyankar marked this conversation as resolved.
Show resolved Hide resolved

Chandan-Abhyankar marked this conversation as resolved.
Show resolved Hide resolved
else
echo "clusterNetworkMTU is already set to ${var.cluster_network_mtu}"
fi

Chandan-Abhyankar marked this conversation as resolved.
Show resolved Hide resolved
EOF
]
}
Expand Down Expand Up @@ -309,6 +321,25 @@ do
sleep 30
done

# Check clusterNetworkMTU
cl_network_mtu=$(oc get network cluster -o yaml | grep -i clusterNetworkMTU | awk '{print $2}')
Chandan-Abhyankar marked this conversation as resolved.
Show resolved Hide resolved
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}" ]]
Chandan-Abhyankar marked this conversation as resolved.
Show resolved Hide resolved
do
echo "waiting for clusterNetworkMTU to be ${var.cluster_network_mtu}"
sleep 30

start_counter=$(expr $start_counter + 1)

# Break the loop if timeout occurs
if [ $start_counter -gt $timeout_counter ]
then
break
Chandan-Abhyankar marked this conversation as resolved.
Show resolved Hide resolved
fi
done

RENDERED_CONFIG=$(oc get mcp/worker -o json | jq -r '.spec.configuration.name')
CHECK_CONFIG=$(oc get mc $${RENDERED_CONFIG} -ojson 2>&1 | grep TARGET_MTU=9100)
while [ -z "$${CHECK_CONFIG}" ]
Expand Down
1 change: 1 addition & 0 deletions modules/4_pvs_support/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
################################################################
Expand Down
Loading