From e75d86ff021d6e0871c071a43ebb5a92ccc335cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= <valtri@civ.zcu.cz> Date: Sat, 24 Sep 2022 20:41:49 +0200 Subject: [PATCH] gitLab CI: cache the latest floating IP to improve robustness --- .gitlab-ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ac40a98..5d271fa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -44,12 +44,14 @@ test-single: - touch ./secure.yml # better to init terraform before allocating public floating IP address (the state could be locked) - terraform init -input=false - - ip=`openstack floating ip create -c floating_ip_address -f value public-muni-147-251-21-GROUP` + - if test -f ip.txt; then ip=$(cat ip.txt); openstack floating ip show "$ip" >/dev/null || ip=''; fi + - if test -z "$ip"; then ip=$(openstack floating ip create -c floating_ip_address -f value public-muni-147-251-21-GROUP); echo "$ip" > ip.txt; fi cache: when: always key: single paths: - ".terraform/" + - "ip.txt" script: - args="-auto-approve -var type=hadoop-single -var flavor=standard.large -var n=0 -var domain=terra1 -var image_name=$IMAGE_NAME -var image_visibility=$IMAGE_VISIBILITY -var floating_ip=$ip" - terraform apply $args @@ -58,6 +60,7 @@ test-single: - ssh -o PreferredAuthentications=publickey deployadm@$ip "sudo -u debian sh -c 'cd; ~deployadm/terraform/image/tests/run-tests.sh'" - terraform destroy $args - openstack floating ip delete $ip + - rm -fv ip.txt rules: - if: '$JOB =~ /all|test-single/' artifacts: &artifacts @@ -73,6 +76,7 @@ test-cluster: key: cluster paths: - ".terraform/" + - "ip.txt" script: - args="-auto-approve -var type=hadoop -var domain=terra2 -var image_name=$IMAGE_NAME -var image_visibility=$IMAGE_VISIBILITY -var floating_ip=$ip" - terraform apply $args @@ -81,6 +85,7 @@ test-cluster: - ssh -o PreferredAuthentications=publickey deployadm@$ip "sudo -u debian sh -c 'cd; ~deployadm/terraform/image/tests/run-tests.sh'" - terraform destroy $args - openstack floating ip delete $ip + - rm -fv ip.txt rules: - if: '$JOB =~ /all|test-cluster/' artifacts: *artifacts -- GitLab