Skip to content
Snippets Groups Projects
Commit afe9ee93 authored by Krish Moodbidri's avatar Krish Moodbidri
Browse files

add floating IP validation and error handling

- Added validation to check if `PROXY_IP` is set before attempting to assign it
parent 6e5953d1
No related branches found
No related tags found
1 merge request!2Add OOD proxy node deployment to CI/CD pipeline
...@@ -60,11 +60,25 @@ deploy_ood_proxy_node: ...@@ -60,11 +60,25 @@ deploy_ood_proxy_node:
--column id \ --column id \
$OOD_PROXY_NAME) $OOD_PROXY_NAME)
# Log the created instance ID for debugging
echo "Created PROXY_INSTANCE_ID: $PROXY_INSTANCE_ID" echo "Created PROXY_INSTANCE_ID: $PROXY_INSTANCE_ID"
# Add a floating IP to the created server # Check if the PROXY_IP is set and exists
openstack server add floating ip $OOD_PROXY_NAME $PROXY_IP if [ -z "$PROXY_IP" ]; then
echo "ERROR: PROXY_IP variable is not set"
exit 1
fi
# Check if the floating IP is available
FLOATING_IP=$(openstack floating ip list --format value --column Floating_IP_Address | grep -w "$PROXY_IP")
if [ -z "$FLOATING_IP" ]; then
echo "ERROR: No Floating IP found for ${PROXY_IP}"
exit 1
else
# Add the floating IP to the created server
openstack server add floating ip $OOD_PROXY_NAME $PROXY_IP
echo "Successfully assigned Floating IP: $PROXY_IP to the server"
fi
# Store the instance ID in variables.env for later use # Store the instance ID in variables.env for later use
echo "PROXY_INSTANCE_ID=$PROXY_INSTANCE_ID" >> $CI_PROJECT_DIR/variables.env echo "PROXY_INSTANCE_ID=$PROXY_INSTANCE_ID" >> $CI_PROJECT_DIR/variables.env
...@@ -72,3 +86,4 @@ deploy_ood_proxy_node: ...@@ -72,3 +86,4 @@ deploy_ood_proxy_node:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'schedule' - if: $CI_PIPELINE_SOURCE == 'schedule'
- when: manual - when: manual
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment