From: Vladimir Khlyunev Date: Mon, 29 Jul 2019 10:37:32 +0000 (+0400) Subject: Add job for checking slave connection to jenkins X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F98%2F41398%2F1;p=tools%2Fsustaining.git Add job for checking slave connection to jenkins During unexpected errors jenkins slaves can disconnect from master node. This job will allow to check it quickly. Change-Id: I0024498ca9ac924f0a0fac5a13a90cd793f38af5 --- diff --git a/maintenance-ci/common/jobs/check_slave_connection.yaml b/maintenance-ci/common/jobs/check_slave_connection.yaml new file mode 100644 index 0000000..6d96e94 --- /dev/null +++ b/maintenance-ci/common/jobs/check_slave_connection.yaml @@ -0,0 +1,26 @@ +- job: + name: 'check-slave-connection' + description: | + Verify that all slaves with given prefix are registered in jenkins + + concurrent: false + node: 'jenkins-master' + + parameters: + - openstack-cloud-selector + - string: + name: STACK_PREFIX + description: "Stack prefix" + default: "swarm-slave" + + wrappers: + - timestamps + - openstack-creds + - timeout: + fail: true + timeout: 30 + + builders: + - openrc-source-file-selector + - shell: + !include-raw: common/scripts/check_slave_conn.sh diff --git a/maintenance-ci/common/scripts/check_slave_conn.sh b/maintenance-ci/common/scripts/check_slave_conn.sh new file mode 100755 index 0000000..24ff3b9 --- /dev/null +++ b/maintenance-ci/common/scripts/check_slave_conn.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +set -e + +OPENSTACK_CLIENTS_VENV="${OPENSTACK_CLIENTS_VENV:-/home/jenkins/venv-openstack-clients}" + +if [[ ! -d "${OPENSTACK_CLIENTS_VENV}" ]] ; then + virtualenv "${OPENSTACK_CLIENTS_VENV}" + source "${OPENSTACK_CLIENTS_VENV}"/bin/activate + pip install openstackclient + deactivate +fi + +source "${OPENSTACK_CLIENTS_VENV}"/bin/activate + +export os_nodes=$(openstack server list --format value -c Name | grep "${STACK_PREFIX}") +export jenkins_nodes=$(curl http://maintenance-ci.scc.mirantis.net/computer/api/json 2>/dev/null | python -c "import sys, json; data = json.load(sys.stdin) ; node_names = [node['displayName'] for node in data['computer']] ; print '\n'.join(node_names)" | grep "${STACK_PREFIX}") + +python -c "import os; +result = set(os.environ.get('os_nodes').split('\n')) - set(os.environ.get('jenkins_nodes').split('\n')[1:]); +print '\n'.join(result) ; +exit(len(result))" + +deactivate \ No newline at end of file