Skip to content

Commit

Permalink
Increased timeout for helm install for mariadb
Browse files Browse the repository at this point in the history
Adjusted deployment to better handle existing or missing components
  • Loading branch information
warrenchristian1telus committed Dec 11, 2024
1 parent 3f1a062 commit 175bd05
Showing 1 changed file with 41 additions and 29 deletions.
70 changes: 41 additions & 29 deletions openshift/scripts/deploy-mariadb-galera.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,44 +91,56 @@ else
--set lifecycle.preStop.exec.command[2]="/usr/local/bin/prestop.sh" \
--atomic \
--wait \
--timeout 10m \
-f ./config/mariadb/galera-values.yaml
fi

# Handle graceful shutdown, and introduce some testing parameters
oc create configmap $DB_DEPLOYMENT_NAME-prestop-script --from-file=./openshift/scripts/mariadb-prestop.sh
# Create or update the ConfigMap from the prestop.sh script
if oc get configmap ${DB_DEPLOYMENT_NAME}-prestop-script &> /dev/null; then
echo "ConfigMap ${DB_DEPLOYMENT_NAME}-prestop-script already exists. Updating..."
oc create configmap ${DB_DEPLOYMENT_NAME}-prestop-script --from-file=./openshift/scripts/mariadb-prestop.sh -o yaml --dry-run=client | oc apply -f -
else
echo "Creating ConfigMap ${DB_DEPLOYMENT_NAME}-prestop-script..."
oc create configmap ${DB_DEPLOYMENT_NAME}-prestop-script --from-file=./openshift/scripts/mariadb-prestop.sh
fi

# Add the ConfigMap as a volume and mount it to each container.
# Also, add the preStop hook to use the script
# oc patch statefulset $DB_DEPLOYMENT_NAME --type=json -p '[{"op": "add", "path": "/spec/template/spec/volumes", "value": [{"name": "prestop-script", "configMap": {"name": "$DB_DEPLOYMENT_NAME-prestop-script"}}]}, {"op": "add", "path": "/spec/template/spec/containers/0/volumeMounts", "value": [{"name": "prestop-script", "mountPath": "/usr/local/bin/prestop.sh", "subPath": "mariadb-prestop.sh"}]}, {"op": "add", "path": "/spec/template/spec/containers/0/lifecycle", "value": {"preStop": {"exec": {"command": ["/bin/sh", "-c", "/usr/local/bin/prestop.sh"]}}}}]'

# Patch the StatefulSet to add the preStop hook to every container
oc patch statefulset $DB_DEPLOYMENT_NAME --type=json -p '[
{
"op": "add",
"path": "/spec/template/spec/volumes/-",
"value": {
"name": "prestop-script",
"configMap": {
"name": "'"$DB_DEPLOYMENT_NAME"'-prestop-script"
if oc get statefulset $DB_DEPLOYMENT_NAME &> /dev/null; then
oc patch statefulset $DB_DEPLOYMENT_NAME --type=json -p '[
{
"op": "add",
"path": "/spec/template/spec/volumes/-",
"value": {
"name": "prestop-script",
"configMap": {
"name": "'"$DB_DEPLOYMENT_NAME"'-prestop-script"
}
}
}
},
{
"op": "add",
"path": "/spec/template/spec/containers/0/volumeMounts/-",
"value": {
"name": "prestop-script",
"mountPath": "/usr/local/bin/prestop.sh",
"subPath": "mariadb-prestop.sh"
}
},
{
"op": "add",
"path": "/spec/template/spec/containers/0/lifecycle/preStop",
"value": {
"exec": {
"command": ["/bin/sh", "-c", "/usr/local/bin/prestop.sh"]
},
{
"op": "add",
"path": "/spec/template/spec/containers/0/volumeMounts/-",
"value": {
"name": "prestop-script",
"mountPath": "/usr/local/bin/prestop.sh",
"subPath": "mariadb-prestop.sh"
}
},
{
"op": "add",
"path": "/spec/template/spec/containers/0/lifecycle/preStop",
"value": {
"exec": {
"command": ["/bin/sh", "-c", "/usr/local/bin/prestop.sh"]
}
}
}
}
]'
]'
else
echo "StatefulSet $DB_DEPLOYMENT_NAME not found. Exiting..."
exit 1
fi

0 comments on commit 175bd05

Please sign in to comment.