Skip to content

Commit

Permalink
OpenShiftP-237: fix path to 98-master-lib-etcd-mc.yaml and make the a…
Browse files Browse the repository at this point in the history
…ttachment idempotent

Signed-off-by: Paul Bastide <[email protected]>
  • Loading branch information
prb112 committed Nov 8, 2024
1 parent 4a6225d commit 95342e2
Showing 1 changed file with 33 additions and 27 deletions.
60 changes: 33 additions & 27 deletions ansible/post/files/mount_etcd_ext_volume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,45 @@ vsi_out=$(ibmcloud is instances | grep ${var_vpc_prefix} | grep master | awk -vO

arr=( $(sed 's/:/ /g' <<<"$vsi_out") )
i=0;
for count in 0 1 2; do
id=${arr[i]};
name=${arr[i+1]};
region=${arr[i+2]};
vol_create_command="ibmcloud is volume-create auto-etcd-vol-${var_rand_id}-${count} ${var_tier} ${region} --capacity 20 --resource-group-id ${var_rg} --output JSON --tags ${var_tag}"

VOLUME_ID=$(ibmcloud is volume-create auto-etcd-vol-${var_rand_id}-${count} ${var_tier} ${region} --capacity 20 --resource-group-id ${var_rg} --output JSON --tags ${var_tag} | jq .id | tr -d "'\"")
VOL_STATUS=$(ibmcloud is volumes | grep ${VOLUME_ID} | awk '{print $3}' );
while [ "$VOL_STATUS" != "available" ]
do
VOL_STATUS=$(ibmcloud is volumes | grep ${VOLUME_ID} | awk '{print $3}' );
done
if [ ! -f ~/ocp4-upi-compute-powervs/etcd-attachment-done ]
then
for count in 0 1 2; do
id=${arr[i]};
name=${arr[i+1]};
region=${arr[i+2]};
vol_create_command="ibmcloud is volume-create auto-etcd-vol-${var_rand_id}-${count} ${var_tier} ${region} --capacity 20 --resource-group-id ${var_rg} --output JSON --tags ${var_tag}"

VOLUME_ID=$(ibmcloud is volume-create auto-etcd-vol-${var_rand_id}-${count} ${var_tier} ${region} --capacity 20 --resource-group-id ${var_rg} --output JSON --tags ${var_tag} | jq .id | tr -d "'\"")
VOL_STATUS=$(ibmcloud is volumes | grep ${VOLUME_ID} | awk '{print $3}' );
while [ "$VOL_STATUS" != "available" ]
do
VOL_STATUS=$(ibmcloud is volumes | grep ${VOLUME_ID} | awk '{print $3}' );
done

vol_attach_command="ibmcloud is instance-volume-attachment-add auto-attach-vol${count} ${id} ${VOLUME_ID} --auto-delete true --output JSON --tags ${var_tag}"
echo ${vol_attach_command};
ATTACH_COMMAND=$(ibmcloud is instance-volume-attachment-add auto-attach-vol${count} ${id} ${VOLUME_ID} --auto-delete true --output JSON --tags ${var_tag});
echo "Volume Attached Successfully to the Master Node : ${name}"
echo "Waiting while the attachment is activated"
sleep 10
chk_query="ibmcloud is instance-volume-attachments ${name}"
echo ${chk_query}
if [ -z "$(ibmcloud is instance-volume-attachments ${name} --output json | jq -r '.[] | select(.status != "attached")')" ]
then
echo "Delaying as not all volumes are finished attaching to instance"
sleep 60
fi
i=$((i+3));
done
fi
touch ~/ocp4-upi-compute-powervs/etcd-attachment-done

vol_attach_command="ibmcloud is instance-volume-attachment-add auto-attach-vol${count} ${id} ${VOLUME_ID} --auto-delete true --output JSON --tags ${var_tag}"
echo ${vol_attach_command};
ATTACH_COMMAND=$(ibmcloud is instance-volume-attachment-add auto-attach-vol${count} ${id} ${VOLUME_ID} --auto-delete true --output JSON --tags ${var_tag});
echo "Volume Attached Successfully to the Master Node : ${name}"
echo "Waiting while the attachment is activated"
sleep 10
chk_query="ibmcloud is instance-volume-attachments ${name}"
echo ${chk_query}
if [ -z "$(ibmcloud is instance-volume-attachments ${name} --output json | jq -r '.[] | select(.status != "attached")')" ]
then
echo "Delaying as not all volumes are finished attaching to instance"
sleep 60
fi
i=$((i+3));
done

#Volume Attachment done. Time for etcd migration
sleep 30s
echo "Going for mc-update-file"
oc apply -f 98-master-lib-etcd-mc.yaml
oc apply -f ~/ocp4-upi-compute-powervs/post/files/98-master-lib-etcd-mc.yaml
# adding a sleep 30 here is not harmful or causing unnecessary delays.
sleep 30
echo "Waiting on the mcp/master to update"
Expand Down

0 comments on commit 95342e2

Please sign in to comment.