Skip to content
Snippets Groups Projects
Commit be4ed63f authored by Maria Petrova-El Sayed's avatar Maria Petrova-El Sayed
Browse files

Fix CI/CD failing when a testing server doesn\'t exist

parent 079170bf
Branches
Tags
No related merge requests found
Pipeline #92099 failed
......@@ -77,7 +77,7 @@ build-custom-image:
- docker push $IMAGE_LATEST_TAG
deploy-testing:
full-deploy-testing:
stage: deploy
environment: Testing
only:
......@@ -85,8 +85,10 @@ deploy-testing:
script:
- echo "Starting the full testing deployment of airflows example."
- pip install python-openstackclient
- OLD_ID=`openstack server show $TESTING_NAME -f value -c id`
- openstack server set --name $OLD_TEST_NAME $OLD_ID
- OLD_ID=`openstack server show $TESTING_NAME -f value -c id` && server_exists=true || echo "No testing server found. It might be a first time deployment"
- if [ "$server_exists" = true ] ; then
openstack server set --name $OLD_TEST_NAME $OLD_ID
fi
- INSTANCE_ID=`openstack server create -f value -c id --prefix IMAGE_ --flavor m4 --image 149a65b5-aeb8-499f-aaa6-ec966bd28dd6 --user-data scripts/cloudinit.yml --security-group ssh --security-group airflows --security-group www --security-group https $TESTING_NAME`
- while [ "`openstack server show $INSTANCE_ID -c addresses -f value`" = "{}" ]; do sleep 5; done # wait until an address is available to attach the floating ip
- openstack server add floating ip $INSTANCE_ID $TESTING_IP
......@@ -159,11 +161,13 @@ cleanup-failed-full-deployment:
- OLD_TEST_ID=`openstack server show $OLD_TEST_NAME -f value -c id` && rollback_test=true || echo "No old testing server found."
# if applicable: rollback test server
- if [ "$rollback_test" = true ] ; then
REMOVE_ID=`openstack server show $TESTING_NAME -f value -c id`;
REMOVE_ID=`openstack server show $TESTING_NAME -f value -c id` && new_deployment_exists=true|| echo "No new testing server has been created.";
openstack server set --name $TESTING_NAME $OLD_TEST_ID;
openstack server add floating ip $OLD_TEST_ID $TESTING_IP;
if [ "$new_deployment_exists" = true ] ; then
openstack server delete $REMOVE_ID && echo "Deleted faulty testing server.";
fi
fi
# gitlab should automatically alert the devs about this failure
publishgit-do:
stage: publish
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment