]> git.apps.os.sepia.ceph.com Git - ceph-build.git/commitdiff
build_utils: fix collect_ceph_logs function 2073/head
authorGuillaume Abrioux <gabrioux@redhat.com>
Fri, 16 Sep 2022 08:36:08 +0000 (10:36 +0200)
committerGuillaume Abrioux <gabrioux@redhat.com>
Fri, 16 Sep 2022 08:41:21 +0000 (10:41 +0200)
typical error from ceph-volume tests:

```
ERROR! the playbook: /home/jenkins-build/build/workspace/ceph-volume-prs-lvm-centos8-bluestore-dmcrypt/tests/functional/collect-logs.yml could not be found
```

Since `collect-logs.yml` is maintained in ceph-ansible repository,
when `collect_ceph_logs` is called from a job different from
ceph-ansible, the path is incorrect.
The idea is to make ceph-volume jobs override this path.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
ceph-volume-ansible-prs/build/teardown
ceph-volume-nightly/build/teardown
ceph-volume-scenario/build/teardown
scripts/build_utils.sh

index 11e3bbcf1eda32b02edf154020ad985598f03db6..b817bee828120b307f09cfbd7d271fa6282dbcf3 100644 (file)
@@ -10,7 +10,9 @@ install_python_packages $TEMPVENV "pkgs[@]"
 
 GITHUB_STATUS_STATE="failure" $VENV/github-status create
 
-cd $WORKSPACE/src/ceph-volume/ceph_volume/tests/functional
+CEPH_VOLUME_FUNCTIONAL_TESTS_PATH=$WORKSPACE/src/ceph-volume/ceph_volume/tests/functional
+COLLECT_LOGS_PLAYBOOK_PATH="$CEPH_VOLUME_FUNCTIONAL_TESTS_PATH/$SUBCOMMAND/.tox/${DISTRO}-${OBJECTSTORE}-${SCENARIO}/tmp/ceph-ansible/tests/functional/collect-logs.yml"
+cd "$CEPH_VOLUME_FUNCTIONAL_TESTS_PATH"
 
 # the method exists in scripts/build_utils.sh
-teardown_vagrant_tests $VENV
+teardown_vagrant_tests "$VENV" "$COLLECT_LOGS_PLAYBOOK_PATH"
index 4735815d6cfa3ddaa27ce0c32a82eb533521c2d3..205bd349a0d9a5b3fcfd5c59e9669d6e0b54869a 100644 (file)
@@ -3,9 +3,11 @@
 # for every Vagrantfile in scenarios and then just destroys whatever is left.
 
 
-cd $WORKSPACE/src/ceph-volume/ceph_volume/tests/functional
+CEPH_VOLUME_FUNCTIONAL_TESTS_PATH=$WORKSPACE/src/ceph-volume/ceph_volume/tests/functional
+COLLECT_LOGS_PLAYBOOK_PATH="$CEPH_VOLUME_FUNCTIONAL_TESTS_PATH/$SUBCOMMAND/.tox/${DISTRO}-${OBJECTSTORE}-${SCENARIO}/tmp/ceph-ansible/tests/functional/collect-logs.yml"
+cd "$CEPH_VOLUME_FUNCTIONAL_TESTS_PATH"
 
 TEMPVENV=$(create_venv_dir)
 VENV=${TEMPVENV}/bin
 # the method exists in scripts/build_utils.sh
-teardown_vagrant_tests $VENV
+teardown_vagrant_tests "$VENV" "$COLLECT_LOGS_PLAYBOOK_PATH"
\ No newline at end of file
index 793b3aab34dcdf33e7660d7b27b56f8ee74f919d..dbd8c4943ff7dc18fa9a32f2b27cdc700a1492ac 100644 (file)
@@ -1,8 +1,10 @@
 #!/bin/bash
 
-cd $WORKSPACE/src/ceph-volume/ceph_volume/tests/functional
+CEPH_VOLUME_FUNCTIONAL_TESTS_PATH=$WORKSPACE/src/ceph-volume/ceph_volume/tests/functional
+COLLECT_LOGS_PLAYBOOK_PATH="$CEPH_VOLUME_FUNCTIONAL_TESTS_PATH/$SUBCOMMAND/.tox/${DISTRO}-${OBJECTSTORE}-${SCENARIO}/tmp/ceph-ansible/tests/functional/collect-logs.yml"
+cd "$CEPH_VOLUME_FUNCTIONAL_TESTS_PATH"
 
 TEMPVENV=$(create_venv_dir)
 VENV=${TEMPVENV}/bin
 # the method exists in scripts/build_utils.sh
-teardown_vagrant_tests $VENV
+teardown_vagrant_tests "$VENV" "$COLLECT_LOGS_PLAYBOOK_PATH"
index 3b5b90853c5ba1a82ecc2bafa1107f79736d3769..39156818dec3217f5425be1a4d61a5595ddffa63 100755 (executable)
@@ -1280,13 +1280,19 @@ github_status_setup() {
 
 collect_ceph_logs() {
     local venv=$1
-    shift
     # this is meant to be run in a testing scenario directory
     # with running vagrant vms. the ansible playbook will connect
     # to your test nodes and fetch any ceph logs that are present
     # in /var/log/ceph and store them on the jenkins builder.
     # these logs can then be archived using the JJB archive publisher
-    limit=$1
+
+    if [ -n "$2" ]; then
+        # set playbook path to overridden path
+        COLLECT_LOGS_PLAYBOOK_PATH="$2"
+    else
+        # set playbook path to default path
+        COLLECT_LOGS_PLAYBOOK_PATH="$WORKSPACE/tests/functional/collect-logs.yml"
+    fi
 
     if [ -f "./vagrant_ssh_config" ]; then
         mkdir -p $WORKSPACE/logs
@@ -1297,13 +1303,13 @@ collect_ceph_logs() {
         export ANSIBLE_SSH_ARGS='-F ./vagrant_ssh_config'
         export ANSIBLE_STDOUT_CALLBACK='debug'
         export ANSIBLE_ROLES_PATH=$WORKSPACE/roles
-        $venv/ansible-playbook -vv -i hosts --limit $limit --extra-vars "archive_path=$WORKSPACE/logs" "$WORKSPACE/tests/functional/collect-logs.yml" || true
+        $venv/ansible-playbook -vv -i hosts --limit all --extra-vars "archive_path=$WORKSPACE/logs" "${COLLECT_LOGS_PLAYBOOK_PATH}" || true
     fi
 }
 
 teardown_vagrant_tests() {
     local venv=$1
-    shift
+    local collect_logs_playbook_path=$2
 
     # collect ceph logs and teardown any running vagrant vms
     # this also cleans up any lingering livirt networks
@@ -1312,7 +1318,7 @@ teardown_vagrant_tests() {
     for scenario in $scenarios; do
         cd $scenario
         # collect all ceph logs from all test nodes
-        collect_ceph_logs $venv all
+        collect_ceph_logs "$venv" "$collect_logs_playbook_path"
         vagrant destroy -f
         stat ./fetch > /dev/null 2>&1 && rm -rf ./fetch
         cd -