Skip to content
Snippets Groups Projects
Commit abdd6773 authored by Christian Boettcher's avatar Christian Boettcher
Browse files

add proper testing deployment

parent c37eec53
No related branches found
No related tags found
No related merge requests found
...@@ -17,6 +17,11 @@ variables: ...@@ -17,6 +17,11 @@ variables:
DAG_GIT_URL: https://github.com/eflows4hpc/dls-dags DAG_GIT_URL: https://github.com/eflows4hpc/dls-dags
VOLUME_ID: 6b58c3a6-691b-496a-8afd-153637c2de48 VOLUME_ID: 6b58c3a6-691b-496a-8afd-153637c2de48
DOCKER_TLS_CERTDIR: "" DOCKER_TLS_CERTDIR: ""
TESTING_IP: 134.94.199.115
OLD_TEST_NAME: old-airflow-testing
TESTING_NAME: airflow-testing
TESTING_URL: https://zam10115.zam.kfa-juelich.de
TESTING_DOMAIN: zam10115.zam.kfa-juelich.de
# before script copied from gitlab docs # before script copied from gitlab docs
...@@ -77,15 +82,53 @@ build-custom-image: ...@@ -77,15 +82,53 @@ build-custom-image:
- docker tag $IMAGE_COMMIT_TAG $IMAGE_LATEST_TAG - docker tag $IMAGE_COMMIT_TAG $IMAGE_LATEST_TAG
- docker push $IMAGE_LATEST_TAG - docker push $IMAGE_LATEST_TAG
full-deploy-testing:
stage: deploy
environment: Testing
rules:
- if: ($CI_COMMIT_BRANCH == "master" && $MANUAL_FULL_DEPLOY_TESTING == "true")
<<: *ssh_setup
script:
- echo "Starting the full testing deployment of airflows."
- pip install python-openstackclient
- 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
# ssh -oStrictHostKeyChecking=accept-new airflow@$TESTING_IP "sudo docker-compose -f /home/airflow/data-logistics-service/dockers/docker-compose.yaml --project-directory /home/airflow/eflows-airflow down"
# openstack server set --name $OLD_TEST_NAME $OLD_ID;
# fi
- openstack server remove volume $OLD_ID $VOLUME_ID
- INSTANCE_ID=`openstack server create -f value -c id --prefix IMAGE_ --flavor l2 --image 149a65b5-aeb8-499f-aaa6-ec966bd28dd6 --user-data scripts/cloudinit.yml --security-group ssh --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
- sleep 10 # ensure that next command reaches the new server, prevents host key problems
- ssh -oStrictHostKeyChecking=accept-new airflow@$TESTING_IP "sudo mkdir -p /persistent_data"
- until ssh -oStrictHostKeyChecking=accept-new airflow@$TESTING_IP ls /finished_cloudinit >/dev/null 2>&1; do sleep 30; done # wait until cloudinit script is complete
- ssh -oStrictHostKeyChecking=accept-new airflow@$TESTING_IP "sudo service docker restart" # to use the configured docker data path
- ssh -oStrictHostKeyChecking=accept-new airflow@$PTESTING_IP "sudo /home/airflow/data-logistics-service/scripts/deployment.sh /home/airflow /home/airflow/data-logistics-service $TESTING_DOMAIN $AIRFLOW__SECRETS__BACKEND $AIRFLOW__SECRETS__BACKEND_KWARGS $AIRFLOW_FERNET_KEY $DAG_GIT_URL"
- echo "Done"
light-deploy-testing:
stage: deploy
rules:
- if: $MANUAL_FULL_DEPLOY_TESTING == "" || $MANUAL_FULL_DEPLOY_TESTING == "false"
when: tags
<<: *ssh_setup
environment: Testing
script:
- ssh -oStrictHostKeyChecking=accept-new airflow@$TESTING_IP "cd /home/airflow/data-logistics-service && git stash && git stash clear && git checkout main && git checkout -f $CI_COMMIT_TAG && git pull --all"
- ssh -oStrictHostKeyChecking=accept-new airflow@$TESTING_IP "sudo /home/airflow/data-logistics-service/scripts/deployment.sh /home/airflow /home/airflow/data-logistics-service $TESTING_DOMAIN $AIRFLOW__SECRETS__BACKEND $AIRFLOW__SECRETS__BACKEND_KWARGS $AIRFLOW_FERNET_KEY $DAG_GIT_URL"
full-deploy-production: full-deploy-production:
stage: deploy stage: deploy
environment: Production environment: Production
only: rules:
- web - if: $MANUAL_FULL_DEPLOY_PRODUCTION == "true"
when: tags
<<: *ssh_setup <<: *ssh_setup
script: script:
- echo "Starting the full testing deployment of airflows example." - echo "Starting the full production deployment of airflows."
- pip install python-openstackclient - pip install python-openstackclient
- OLD_ID=`openstack server show $PRODUCTION_NAME -f value -c id` && server_exists=true || echo "No production server found. It might be a first time deployment" - OLD_ID=`openstack server show $PRODUCTION_NAME -f value -c id` && server_exists=true || echo "No production server found. It might be a first time deployment"
# - if [ "$server_exists" = true ] ; then # - if [ "$server_exists" = true ] ; then
...@@ -110,12 +153,9 @@ full-deploy-production: ...@@ -110,12 +153,9 @@ full-deploy-production:
# TODO Add proper tests # TODO Add proper tests
light-deploy-production: light-deploy-production:
stage: deploy stage: deploy
# only run when master is updated, unless the pipeline was triggered via the web UI rules:
only: - if: $MANUAL_FULL_DEPLOY_PRODUCTION == "" || $MANUAL_FULL_DEPLOY_PRODUCTION == "false"
- main when: tags
except:
- tags
- web
<<: *ssh_setup <<: *ssh_setup
environment: Production environment: Production
script: script:
...@@ -126,8 +166,6 @@ test-production-webserver: ...@@ -126,8 +166,6 @@ test-production-webserver:
cache: {} cache: {}
stage: test-deployment stage: test-deployment
only: only:
- web # and master
except:
- tags - tags
script: script:
- apt update && apt -y install curl - apt update && apt -y install curl
...@@ -144,8 +182,9 @@ cleanup-successful-full-deployment: ...@@ -144,8 +182,9 @@ cleanup-successful-full-deployment:
# check if there is an old prod or test instance, and delete it if present # check if there is an old prod or test instance, and delete it if present
stage: cleanup stage: cleanup
when: on_success when: on_success
only: rules:
- web - if: $MANUAL_FULL_DEPLOY_PRODUCTION == "true"
when: tags
script: script:
- echo "This is the cleanup for the full-redeployment of the testing or production servers" - echo "This is the cleanup for the full-redeployment of the testing or production servers"
- echo "if this job is reached, all earlier jobs were successful, and any lingering old instances need to be removed" - echo "if this job is reached, all earlier jobs were successful, and any lingering old instances need to be removed"
...@@ -158,8 +197,9 @@ cleanup-failed-full-deployment: ...@@ -158,8 +197,9 @@ cleanup-failed-full-deployment:
# this does not guarantee a successful rollback, but unless the old instance was faulty, this should work # this does not guarantee a successful rollback, but unless the old instance was faulty, this should work
stage: cleanup stage: cleanup
when: on_failure when: on_failure
only: rules:
- web - if: $MANUAL_FULL_DEPLOY_PRODUCTION == "true"
when: tags
<<: *ssh_setup <<: *ssh_setup
script: script:
- echo "This is the cleanup for the full-redeployment of the testing or production servers" - echo "This is the cleanup for the full-redeployment of the testing or production servers"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment