Browse Source

Add bashate in gate jobs and fix existing errors

Change-Id: I3cbf754ea9c037df8b95eb6f83dbe8ce09bfd717
Signed-off-by: Pablo Iranzo Gómez <Pablo.Iranzo@gmail.com>
changes/57/603057/3
Pablo Iranzo Gómez 3 years ago
parent
commit
79a1a4b275
No known key found for this signature in database GPG Key ID: 34823665BD8E1E4
11 changed files with 110 additions and 99 deletions
  1. +8
    -8
      healthcheck/ironic-pxe
  2. +4
    -4
      healthcheck/ovn-dbs
  3. +1
    -1
      healthcheck/sahara-api
  4. +6
    -6
      scripts/bootstrap_host_exec
  5. +6
    -6
      scripts/bootstrap_host_only_eval
  6. +6
    -6
      scripts/bootstrap_host_only_exec
  7. +55
    -59
      scripts/upload-swift-artifacts
  8. +1
    -0
      test-requirements.txt
  9. +7
    -7
      tools/check_duplicate_jinja_blocks.sh
  10. +1
    -2
      tools/releasenotes_tox.sh
  11. +15
    -0
      tox.ini

+ 8
- 8
healthcheck/ironic-pxe View File

@ -3,14 +3,14 @@
. ${HEALTHCHECK_SCRIPTS:-/usr/share/openstack-tripleo-common/healthcheck}/common.sh
if grep "/httpd " /run_command ; then
bind_host=127.0.0.1
bind_port=$(grep "^Listen " /etc/httpd/conf.d/10-ipxe_vhost.conf | awk '{print $2}')
protocol=http
path=
bind_host=127.0.0.1
bind_port=$(grep "^Listen " /etc/httpd/conf.d/10-ipxe_vhost.conf | awk '{print $2}')
protocol=http
path=
else
bind_host=$(ps -ef | grep -oe '--address \([0-9]\+\.\?\)\+' | awk '{print $2}')
bind_port=69
protocol=tftp
path=map-file
bind_host=$(ps -ef | grep -oe '--address \([0-9]\+\.\?\)\+' | awk '{print $2}')
bind_port=69
protocol=tftp
path=map-file
fi
healthcheck_curl ${protocol}://${bind_host}:${bind_port}/${path}

+ 4
- 4
healthcheck/ovn-dbs View File

@ -6,8 +6,8 @@ process='ovn-northd'
sockets="${@:-/run/openvswitch/ovnnb_db.sock /run/openvswitch/ovnsb_db.sock}"
for sock in sockets; do
if ! healthcheck_socket $process $sock; then
echo "There is no $process process connected to socket $sock running in the container"
exit 1
fi
if ! healthcheck_socket $process $sock; then
echo "There is no $process process connected to socket $sock running in the container"
exit 1
fi
done

+ 1
- 1
healthcheck/sahara-api View File

@ -6,7 +6,7 @@ bind_host=$(get_config_val /etc/sahara/sahara.conf DEFAULT host 127.0.0.1)
bind_port=$(get_config_val /etc/sahara/sahara.conf DEFAULT port 8386)
# Add brackets if IPv6
if [[ $bind_host =~ ":" ]]; then
bind_host="[${bind_host}]"
bind_host="[${bind_host}]"
fi
# sahara-api is still eventlet
healthcheck_curl http://${bind_host}:${bind_port}/

+ 6
- 6
scripts/bootstrap_host_exec View File

@ -2,18 +2,18 @@
set -e
SERVICE_NAME=$1
if [ -z "$SERVICE_NAME" ]; then
echo "Please supply a valid service name."
exit 1
echo "Please supply a valid service name."
exit 1
fi
shift
if [ -z "$*" ]; then
echo "Please supply a valid 'command' to run as an argument."
exit 1
echo "Please supply a valid 'command' to run as an argument."
exit 1
fi
HOSTNAME=$(/bin/hostname -s)
SERVICE_NODEID=$(/bin/hiera -c /etc/puppet/hiera.yaml "${SERVICE_NAME}_short_bootstrap_node_name")
if [[ "${HOSTNAME,,}" == "${SERVICE_NODEID,,}" ]]; then
eval $*
eval $*
else
echo "Skipping execution since this is not the bootstrap node for this service."
echo "Skipping execution since this is not the bootstrap node for this service."
fi

+ 6
- 6
scripts/bootstrap_host_only_eval View File

@ -2,18 +2,18 @@
set -e
SERVICE_NAME=$1
if [ -z "$SERVICE_NAME" ]; then
echo "Please supply a valid service name."
exit 1
echo "Please supply a valid service name."
exit 1
fi
shift
if [ -z "$*" ]; then
echo "Please supply a valid 'command' to run as an argument."
exit 1
echo "Please supply a valid 'command' to run as an argument."
exit 1
fi
HOSTNAME=$(/bin/hostname -s)
SERVICE_NODEID=$(/bin/hiera -c /etc/puppet/hiera.yaml "${SERVICE_NAME}_short_bootstrap_node_name")
if [[ "${HOSTNAME,,}" == "${SERVICE_NODEID,,}" ]]; then
eval $*
eval $*
else
echo "Skipping execution since this is not the bootstrap node for this service."
echo "Skipping execution since this is not the bootstrap node for this service."
fi

+ 6
- 6
scripts/bootstrap_host_only_exec View File

@ -2,18 +2,18 @@
set -e
SERVICE_NAME=$1
if [ -z "$SERVICE_NAME" ]; then
echo "Please supply a valid service name."
exit 1
echo "Please supply a valid service name."
exit 1
fi
shift
if [ -z "$*" ]; then
echo "Please supply a valid 'command' to run as an argument."
exit 1
echo "Please supply a valid 'command' to run as an argument."
exit 1
fi
HOSTNAME=$(/bin/hostname -s)
SERVICE_NODEID=$(/bin/hiera -c /etc/puppet/hiera.yaml "${SERVICE_NAME}_short_bootstrap_node_name")
if [[ "${HOSTNAME,,}" == "${SERVICE_NODEID,,}" ]]; then
exec "$@"
exec "$@"
else
echo "Skipping execution since this is not the bootstrap node for this service."
echo "Skipping execution since this is not the bootstrap node for this service."
fi

+ 55
- 59
scripts/upload-swift-artifacts View File

@ -43,31 +43,27 @@ function show_options {
exit $1
}
function check_file
{
local FILE=$1
supported_files=(" RPM " "gzip compressed data")
array_length=${#supported_files[@]}
local test_type=`file $FILE`
local i=0
local matched=0
while [ $i -ne $array_length -a $matched -eq 0 ]
do
if [[ "$test_type" =~ ${supported_files[$i]} ]]
then
matched=1
function check_file {
local FILE=$1
supported_files=(" RPM " "gzip compressed data")
array_length=${#supported_files[@]}
local test_type=`file $FILE`
local i=0
local matched=0
while [ $i -ne $array_length -a $matched -eq 0 ]; do
if [[ "$test_type" =~ ${supported_files[$i]} ]]; then
matched=1
fi
i=$((i+1))
done
if [ $matched -eq 0 ]; then
echo "Not a supported file type: $FILE"
exit 1
fi
i=$((i+1))
done
if [ $matched -eq 0 ]
then
echo "Not a supported file type: $FILE"
exit 1
fi
}
@ -99,22 +95,22 @@ while true ; do
done
if [ -z "${FILES:-}" ]; then
echo "Error: No files were specified."
exit 1
echo "Error: No files were specified."
exit 1
fi
if [ -z "${CONTAINER_NAME:-}" ]; then
echo "Error: No Swift --container was specified."
exit 1
echo "Error: No Swift --container was specified."
exit 1
fi
function create_heat_env() {
local heat_env_file=$1
mkdir -p $(dirname "$heat_env_file")
cat > "$heat_env_file" <<-EOF_CAT
function create_heat_env {
local heat_env_file=$1
mkdir -p $(dirname "$heat_env_file")
cat > "$heat_env_file" <<-EOF_CAT
# Heat environment to deploy artifacts via Swift Temp URL(s)
parameter_defaults:
DeployArtifactURLs:
DeployArtifactURLs:
EOF_CAT
}
@ -126,53 +122,53 @@ SWIFT_ACCOUNT=$(openstack container create $CONTAINER_NAME -f value -c account)
SWIFT_INTERNAL_URL=$(openstack endpoint list | grep swift | grep internal | sed -e "s|.*\(http.*\)://\([^/]*\)/.*|\1://\2|" || true)
if [ -z "$SWIFT_INTERNAL_URL" ]; then
# fallback to old openstack client 'show' which displays all the URLs
SWIFT_INTERNAL_URL=$(openstack endpoint show swift | grep internalurl | sed -e "s|.*\(http.*\)://\([^/]*\)/.*|\1://\2|")
# fallback to old openstack client 'show' which displays all the URLs
SWIFT_INTERNAL_URL=$(openstack endpoint show swift | grep internalurl | sed -e "s|.*\(http.*\)://\([^/]*\)/.*|\1://\2|")
fi
# Does the Temp-URL-Key exist on this container?
# If not set it...
KEY_SET=$(openstack container show $CONTAINER_NAME -c properties -f value 2>/dev/null | tr ',' '\n' | grep Temp-Url-Key || true)
if [ -z $KEY_SET ]; then
echo "Creating new Swift Temp-URL-Key for container: $CONTAINER_NAME"
SWIFT_TEMP_URL_KEY=$(uuidgen | sha1sum | awk '{print $1}')
openstack container set --property "Temp-URL-Key=$SWIFT_TEMP_URL_KEY" "${CONTAINER_NAME}"
echo "Creating new Swift Temp-URL-Key for container: $CONTAINER_NAME"
SWIFT_TEMP_URL_KEY=$(uuidgen | sha1sum | awk '{print $1}')
openstack container set --property "Temp-URL-Key=$SWIFT_TEMP_URL_KEY" "${CONTAINER_NAME}"
else
SWIFT_TEMP_URL_KEY=$(echo -n $KEY_SET | sed -rn "s/[[:space:]]*Temp-Url-Key='([[:alnum:]]+)'.*/\1/p")
SWIFT_TEMP_URL_KEY=$(echo -n $KEY_SET | sed -rn "s/[[:space:]]*Temp-Url-Key='([[:alnum:]]+)'.*/\1/p")
fi
if [ -n "${ENVIRONMENT_FILE:-}" ]; then
echo "Creating heat environment file: $ENVIRONMENT_FILE"
create_heat_env "$ENVIRONMENT_FILE"
echo "Creating heat environment file: $ENVIRONMENT_FILE"
create_heat_env "$ENVIRONMENT_FILE"
else
echo "No environment file specified... skipping creation of Heat environment."
echo "No environment file specified... skipping creation of Heat environment."
fi
function get_tempurl {
# https://docs.openstack.org/swift/latest/api/temporary_url_middleware.html#hmac-sha1-signature-for-temporary-urls
local FILE="$1"
local SWIFT_METHOD='GET'
local SWIFT_PATH="/v1/${SWIFT_ACCOUNT}/${CONTAINER_NAME}/$(basename $FILE)"
local SWIFT_EXPIRES=$(( $(date '+%s') + $SECONDS ))
local SWIFT_SIG=$(printf '%s\n%s\n%s' $SWIFT_METHOD $SWIFT_EXPIRES $SWIFT_PATH | openssl sha1 -hmac $SWIFT_TEMP_URL_KEY | sed 's/^.* //')
echo -n "${SWIFT_PATH}?temp_url_sig=${SWIFT_SIG}&temp_url_expires=${SWIFT_EXPIRES}"
# https://docs.openstack.org/swift/latest/api/temporary_url_middleware.html#hmac-sha1-signature-for-temporary-urls
local FILE="$1"
local SWIFT_METHOD='GET'
local SWIFT_PATH="/v1/${SWIFT_ACCOUNT}/${CONTAINER_NAME}/$(basename $FILE)"
local SWIFT_EXPIRES=$(( $(date '+%s') + $SECONDS ))
local SWIFT_SIG=$(printf '%s\n%s\n%s' $SWIFT_METHOD $SWIFT_EXPIRES $SWIFT_PATH | openssl sha1 -hmac $SWIFT_TEMP_URL_KEY | sed 's/^.* //')
echo -n "${SWIFT_PATH}?temp_url_sig=${SWIFT_SIG}&temp_url_expires=${SWIFT_EXPIRES}"
}
function upload_file {
local FILE="$1"
echo "Uploading file to swift: $1"
pushd $(dirname $FILE) &>/dev/null
openstack object create "$CONTAINER_NAME" $(basename $FILE)
popd &>/dev/null
echo "Upload complete."
local FILE="$1"
echo "Uploading file to swift: $1"
pushd $(dirname $FILE) &>/dev/null
openstack object create "$CONTAINER_NAME" $(basename $FILE)
popd &>/dev/null
echo "Upload complete."
local URL=$(get_tempurl "$FILE")
echo " - '${SWIFT_INTERNAL_URL}$URL'" >> $ENVIRONMENT_FILE
local URL=$(get_tempurl "$FILE")
echo " - '${SWIFT_INTERNAL_URL}$URL'" >> $ENVIRONMENT_FILE
}
for FILE in ${FILES[@]}; do
check_file "$FILE"
upload_file "$FILE"
check_file "$FILE"
upload_file "$FILE"
done

+ 1
- 0
test-requirements.txt View File

@ -17,3 +17,4 @@ testtools>=2.2.0 # MIT
PyYAML>=3.12 # MIT
reno>=2.5.0 # Apache-2.0
urllib3>=1.21.1 # MIT
bashate>=0.2 # Apache-2.0

+ 7
- 7
tools/check_duplicate_jinja_blocks.sh View File

@ -7,15 +7,15 @@ grep '{% block' $path |
sort |
uniq -c |
awk -v myname=$myname '
$1 == 2 {
printf "%s: found duplicate block for %s\n", myname, $4
retval=1
}
$1 == 2 {
printf "%s: found duplicate block for %s\n", myname, $4
retval=1
}
END {exit retval}
END {exit retval}
'
if [ $? -ne 0 ]; then
echo "$myname: duplicate jinja block declarations found in $path" >&2
exit 1
echo "$myname: duplicate jinja block declarations found in $path" >&2
exit 1
fi

+ 1
- 2
tools/releasenotes_tox.sh View File

@ -11,8 +11,7 @@ BUILD_RESULT=$?
UNCOMMITTED_NOTES=$(git status --porcelain | \
awk '$1 == "M" && $2 ~ /releasenotes\/notes/ {print $2}')
if [ "${UNCOMMITTED_NOTES}" ]
then
if [ "${UNCOMMITTED_NOTES}" ]; then
cat <<EOF
REMINDER: The following changes to release notes have not been committed:


+ 15
- 0
tox.ini View File

@ -34,6 +34,21 @@ commands = python setup.py build_sphinx
basepython = python3
commands = oslo_debug_helper {posargs}
[testenv:bashate]
commands =
# Run bashate check for all bash scripts
# Ignores the following rules:
# E006: Line longer than 79 columns (as many scripts use jinja
# templating, this is very difficult)
# E040: Syntax error determined using `bash -n` (as many scripts
# use jinja templating, this will often fail and the syntax
# error will be discovered in execution anyway)
bash -c "git ls-files | xargs grep --binary-files=without-match \
--files-with-match '^.!.*\(ba\)\?sh$' \
--exclude-dir .tox \
--exclude-dir .git \
| xargs bashate --error . --verbose --ignore=E006,E040,E042"
[flake8]
# E123, E125 skipped as they are invalid PEP-8.


Loading…
Cancel
Save