diff options
author | Matt Riedemann <mriedem.os@gmail.com> | 2018-01-27 15:41:14 -0500 |
---|---|---|
committer | Matt Riedemann <mriedem.os@gmail.com> | 2018-02-24 02:27:38 +0000 |
commit | e8e8941d25dadf78e27ae0f93fe4c07ace44378c (patch) | |
tree | 3b5ece86246ff663f25078a5be2cbf0e9db434ef /gate | |
parent | b325882c6c7e042e2d62ef9d3b1dedcbafddb690 (diff) | |
download | nova-e8e8941d25dadf78e27ae0f93fe4c07ace44378c.tar.gz |
Check for leaked server resource allocations in post_test_hook
The post_test_hook.sh runs in the nova-next CI job. The 1.0.0
version of the osc-placement plugin adds the CLIs to show consumer
resource allocations.
This adds some sanity check code to the post_test_hook.sh script
to look for any resource provider (compute nodes) that have allocations
against them, which shouldn't be the case for successful test runs
where servers are cleaned up properly.
Change-Id: I9801ad04eedf2fede24f3eb104715dcc8e20063d
Diffstat (limited to 'gate')
-rwxr-xr-x | gate/post_test_hook.sh | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/gate/post_test_hook.sh b/gate/post_test_hook.sh index 5f72eb378d..e696b795cd 100755 --- a/gate/post_test_hook.sh +++ b/gate/post_test_hook.sh @@ -19,3 +19,36 @@ function archive_deleted_rows { } archive_deleted_rows + +set -e +# We need to get the admin credentials to run the OSC CLIs for Placement. +set +x +BASE=${BASE:-/opt/stack} +source $BASE/new/devstack/openrc admin +set -x + +# TODO(mriedem): Consider checking for instances in ERROR state because +# if there are any, we would expect them to retain allocations in Placement +# and therefore we don't really need to check for leaked allocations. + +# Check for orphaned instance allocations in Placement which could mean +# something failed during a test run and isn't getting cleaned up properly. +echo "Looking for leaked resource provider allocations in Placement" +LEAKED_ALLOCATIONS=0 +for provider in $(openstack resource provider list -c uuid -f value); do + echo "Looking for allocations for provider $provider" + allocations=$(openstack resource provider show --allocations $provider \ + -c allocations -f value) + if [[ "$allocations" != "{}" ]]; then + echo "Resource provider has allocations:" + openstack resource provider show --allocations $provider + LEAKED_ALLOCATIONS=1 + fi +done + +# Fail if there were any leaked allocations. +if [[ $LEAKED_ALLOCATIONS -eq 1 ]]; then + echo "There were leaked allocations; failing." + exit 1 +fi +echo "Resource provider allocations were cleaned up properly." |