From 128804f13e363e62e3ef9e3ecb63bdf893001f09 Mon Sep 17 00:00:00 2001 From: Daniel Juarez Gonzalez Date: Wed, 18 Dec 2019 10:04:02 +0000 Subject: [PATCH 1/3] anchor merging + extends combination for printing vm details --- .gitlab-ci.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 05e5968..7b664a7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -55,6 +55,15 @@ stages: exit $FAIL } +# YAML Anchor for after_scripts. It needs to retrieve details again as after_script runs in a different shell. Watch out for char escaping +.vm_details_retrieval: &vm_details_retrieval + after_script: + - source upload.txt + - vm_name="test"-$id + - vm_id=$(openstack server show "${vm_name}" -c id --format value) + - vm_ip=$( openstack server show "${vm_id}" -c addresses --format value | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" ) + - printf "NAME $vm_name\nVM ID $vm_id\nIPv4 $vm_ip\nImage ID $id\nPlease note this VM does not wait for DNS registration.\nYou can connect to it with KRBR5 or SSH if you were added to gitlab.cern.ch/linuxsupport/rpms/cern-linuxsupport-access" + .upload_test_image: extends: .openstack stage: test @@ -166,6 +175,8 @@ stages: - ssh -o 'ConnectionAttempts 300' -oStrictHostKeyChecking=no -i imageci.pem root@"${vm_ip}" "bash -s" < ./upstreamcentostests.sh - t_CheckExitStatus $? - echo "Upstream tests ran successfully" + # Merge with details printinf in after_script + <<: *vm_details_retrieval .cern_test_image: extends: .openstack @@ -192,6 +203,8 @@ stages: # We need to pass our CI service account for retrieving a valid KRBR5 ticket - ssh -o 'ConnectionAttempts 60' -oStrictHostKeyChecking=no -i imageci.pem root@"${vm_ip}" "IMAGECI_USER='$IMAGECI_USER' IMAGECI_PWD='$IMAGECI_PWD' exec sh" < ./cerncentostests.sh - t_CheckExitStatus $? + # Merge with details printinf in after_script + <<: *vm_details_retrieval .vm_cleanup: extends: .openstack -- GitLab From babbdc7b1469e62af3a694a152d481df805a7716 Mon Sep 17 00:00:00 2001 From: Daniel Juarez Gonzalez Date: Wed, 18 Dec 2019 11:02:56 +0000 Subject: [PATCH 2/3] after_script did not have access to OS env vars, will extract to merge later --- .gitlab-ci.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7b664a7..38d0512 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -58,6 +58,20 @@ stages: # YAML Anchor for after_scripts. It needs to retrieve details again as after_script runs in a different shell. Watch out for char escaping .vm_details_retrieval: &vm_details_retrieval after_script: + - echo "${IMAGECI_PWD}" | kinit ${IMAGECI_USER}@CERN.CH + - export OS_PROJECT_NAME="IT Linux Support - Images" + - export OS_USERNAME=${IMAGECI_USER} + - export OS_PASSWORD=${IMAGECI_PWD} + - export OS_TENANT_ID=8e35e961-f888-4622-bf7d-5fe9eb8cf563 + - export OS_AUTH_TYPE=v3fedkerb + - export OS_AUTH_URL=https://keystone.cern.ch/v3 + - export OS_IDENTITY_API_VERSION=3 + - export OS_IDENTITY_PROVIDER=sssd + - export OS_MUTUAL_AUTH=disabled + - export OS_PROJECT_DOMAIN_ID=default + - export OS_PROTOCOL=kerberos + - export OS_REGION_NAME=cern + - export OS_VOLUME_API_VERSION=2 - source upload.txt - vm_name="test"-$id - vm_id=$(openstack server show "${vm_name}" -c id --format value) -- GitLab From 4ced782b5983b1c265e43098b43803780c762f9e Mon Sep 17 00:00:00 2001 From: Daniel Juarez Gonzalez Date: Wed, 18 Dec 2019 12:34:59 +0000 Subject: [PATCH 3/3] Extract tenant id as a variable for convenience --- .gitlab-ci.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 38d0512..9d4042f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,6 +8,9 @@ stages: - publish_test - prod +variables: + OS_TENANT_ID: 8e35e961-f888-4622-bf7d-5fe9eb8cf563 + .build_image: stage: build image: 'gitlab-registry.cern.ch/linuxsupport/rpmci/kojicli' @@ -35,7 +38,7 @@ stages: export OS_PROJECT_NAME="IT Linux Support - Images" export OS_USERNAME=${IMAGECI_USER} export OS_PASSWORD=${IMAGECI_PWD} - export OS_TENANT_ID=8e35e961-f888-4622-bf7d-5fe9eb8cf563 + export OS_TENANT_ID=${OS_TENANT_ID} export OS_AUTH_TYPE=v3fedkerb export OS_AUTH_URL=https://keystone.cern.ch/v3 export OS_IDENTITY_API_VERSION=3 @@ -56,13 +59,14 @@ stages: } # YAML Anchor for after_scripts. It needs to retrieve details again as after_script runs in a different shell. Watch out for char escaping +# after_script script must be an array of commands, cannot use code blocks .vm_details_retrieval: &vm_details_retrieval after_script: - echo "${IMAGECI_PWD}" | kinit ${IMAGECI_USER}@CERN.CH - export OS_PROJECT_NAME="IT Linux Support - Images" - export OS_USERNAME=${IMAGECI_USER} - export OS_PASSWORD=${IMAGECI_PWD} - - export OS_TENANT_ID=8e35e961-f888-4622-bf7d-5fe9eb8cf563 + - export OS_TENANT_ID=${OS_TENANT_ID} - export OS_AUTH_TYPE=v3fedkerb - export OS_AUTH_URL=https://keystone.cern.ch/v3 - export OS_IDENTITY_API_VERSION=3 @@ -76,7 +80,7 @@ stages: - vm_name="test"-$id - vm_id=$(openstack server show "${vm_name}" -c id --format value) - vm_ip=$( openstack server show "${vm_id}" -c addresses --format value | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" ) - - printf "NAME $vm_name\nVM ID $vm_id\nIPv4 $vm_ip\nImage ID $id\nPlease note this VM does not wait for DNS registration.\nYou can connect to it with KRBR5 or SSH if you were added to gitlab.cern.ch/linuxsupport/rpms/cern-linuxsupport-access" + - printf "NAME $vm_name\nVM ID $vm_id\nIPv4 $vm_ip\nImage ID $id\nPlease note this VM does not wait for DNS registration.\nYou can connect as root with KRBR5 or SSH if you were added to gitlab.cern.ch/linuxsupport/rpms/cern-linuxsupport-access" .upload_test_image: extends: .openstack @@ -183,7 +187,7 @@ stages: IPv4: $vm_ip Image ID: $id Please note this VM does not wait for DNS registration. - You can connect to it with KRBR5 or SSH if you were added to https://gitlab.cern.ch/linuxsupport/rpms/cern-linuxsupport-access + You can connect as root with KRBR5 or SSH if you were added to https://gitlab.cern.ch/linuxsupport/rpms/cern-linuxsupport-access EOF # Try to ssh for 300seconds until ready, then run test script using https://gitlab.cern.ch/linuxsupport/testing/centos_functional_tests - ssh -o 'ConnectionAttempts 300' -oStrictHostKeyChecking=no -i imageci.pem root@"${vm_ip}" "bash -s" < ./upstreamcentostests.sh -- GitLab