Ensure the OpenStack gate has access to the logs

When the gate fails, for any reason, its possible the logs generated
by the services are not accessible by the jenkins worker which does
cause problems when the logs are uploaded for analysis. To ensure the
gate always has access to the logs a trap was added to the gate script
which is used to guarantee the gate has access to the logs by recursively
setting the mode to 0777 on all files within the "/openstack/logs"
directory.

The function "gate_job_exit_tasks" has been added to the
script-libraries.sh file

Change-Id: I3eece015060dd99aceb7a39ca62c5cb1a0162421
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter 2016-03-30 13:22:10 -05:00 committed by Jesse Pretorius (odyssey4me)
parent 458a67535a
commit 6eb3c34a17
2 changed files with 14 additions and 10 deletions

View File

@ -24,11 +24,16 @@ export TESTR_OPTS=${TESTR_OPTS:-''}
export PYTHONUNBUFFERED=1
# Extra options to pass to the AIO bootstrap process
export BOOTSTRAP_OPTS=${BOOTSTRAP_OPTS:-''}
# This variable is being added to ensure the gate job executes an exit
# function at the end of the run.
export OSA_GATE_JOB=true
## Functions -----------------------------------------------------------------
info_block "Checking for required libraries." 2> /dev/null || source $(dirname ${0})/scripts-library.sh
## Main ----------------------------------------------------------------------
# Set gate job exit traps, this is run regardless of exit state when the job finishes.
trap gate_job_exit_tasks EXIT
# Log some data about the instance and the rest of the system
log_instance_info
@ -80,8 +85,10 @@ pushd $(dirname ${0})/../tests
bootstrap-aio.yml
popd
# Implement the log directory link for openstack-infra log publishing
# Implement the log directory
mkdir -p /openstack/log
# Implement the log directory link for openstack-infra log publishing
ln -sf /openstack/log $(dirname ${0})/../logs
pushd $(dirname ${0})/../playbooks

View File

@ -97,14 +97,6 @@ function ssh_key_create {
function exit_state {
set +x
# Check if the logs link is in place. This will only be true when the
# environment was built by the gate-check-commit script.
if [ -h $(dirname ${0})/../logs ]; then
# Ensure that all directories may be traversed by all users, and that
# all files are readable by all users.
chmod --recursive o+rX $(dirname ${0})/../logs
fi
TOTALSECONDS="$(( $(date +%s) - STARTTIME ))"
info_block "Run Time = ${TOTALSECONDS} seconds || $((TOTALSECONDS / 60)) minutes"
if [ "${1}" == 0 ];then
@ -117,6 +109,7 @@ function exit_state {
function exit_success {
set +x
[[ "${OSA_GATE_JOB:-false}" = true ]] && gate_job_exit_tasks
exit_state 0
}
@ -125,9 +118,14 @@ function exit_fail {
log_instance_info
cat ${INFO_FILENAME}
info_block "Error Info - $@"
[[ "${OSA_GATE_JOB:-false}" = true ]] && gate_job_exit_tasks
exit_state 1
}
function gate_job_exit_tasks {
[[ -d "/openstack/log" ]] && chmod -R 0777 /openstack/log
}
function print_info {
PROC_NAME="- [ $@ ] -"
printf "\n%s%s\n" "$PROC_NAME" "${LINE:${#PROC_NAME}}"
@ -258,7 +256,6 @@ function get_pip {
fi
}
## Signal traps --------------------------------------------------------------
# Trap all Death Signals and Errors
trap "exit_fail ${LINENO} $? 'Received STOP Signal'" SIGHUP SIGINT SIGTERM