From 81d75bc032e637ce26461c4dc2d1937322fbe3c8 Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Tue, 5 Jun 2018 14:16:34 -0500 Subject: [PATCH] Change check_uptodate.sh to not call tox Base nodepool images now no longer include tox. This causes a failure in our pep8 jobs because the tools/config/check_uptodate.sh script had been calling "tox -e genopts" to look for config file changes. This is a partial backport of a change that switched our default basepython to python3. That part of the change was removed from tox.ini, so the only other part was an update to the check_uptodate.sh script that refactored things to be more reliable, including the removal of calling tox. The part from the original commit included is: There was also a difference in behavior with the genopts job where it ends up trying to recreate the venv under which it is currently running under, resulting in a corrupted venv and a failure. This cleans up that script and changes it so rather than a tox job calling a tox job it just runs the script. Change-Id: Ie79528b33070e6c60f9f5e1f2219084a2f0cb039 (cherry picked from commit 37510ac03478704bafba89e8c4f4e0e9041d661d) --- tools/config/check_uptodate.sh | 80 +++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 30 deletions(-) diff --git a/tools/config/check_uptodate.sh b/tools/config/check_uptodate.sh index cff68bd99b7..2fbe29ff2e7 100755 --- a/tools/config/check_uptodate.sh +++ b/tools/config/check_uptodate.sh @@ -1,35 +1,55 @@ #!/usr/bin/env bash +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +# This script is used to check if there have been configuration changes that +# have not been checked in. + +# The opts file needs to be present in order to compare it if [ ! -e cinder/opts.py ]; then - echo -en "\n\n#################################################" - echo -en "\nERROR: cinder/opts.py file is missing." - echo -en "\n#################################################\n" + echo "" + echo "#################################################" + echo "ERROR: cinder/opts.py file is missing." + echo "#################################################" exit 1 -else - mv cinder/opts.py cinder/opts.py.orig - tox -e genopts &> tox-genops.log - if [ $? -ne 0 ]; then - cat tox-genops.log >&2 - echo -en "\n\n#################################################" - echo -en "\nERROR: Non-zero exit from generate_cinder_opts.py." - echo -en "\n See output above for details.\n" - echo -en "#################################################\n" - mv cinder/opts.py.orig cinder/opts.py - exit 1 - else - diff cinder/opts.py.orig cinder/opts.py - if [ $? -ne 0 ]; then - echo -en "\n\n########################################################" - echo -en "\nERROR: Configuration options change detected." - echo -en "\n A new cinder/opts.py file must be generated." - echo -en "\n Run 'tox -e genopts' from the base directory" - echo -en "\n and add the result to your commit." - echo -en "\n########################################################\n\n" - rm cinder/opts.py - mv cinder/opts.py.orig cinder/opts.py - exit 1 - else - rm cinder/opts.py.orig - fi - fi fi + +# Rename the existing file so we can generate a new one to compare +mv cinder/opts.py cinder/opts.py.orig +python tools/config/generate_cinder_opts.py &> tox-genops.log +if [ $? -ne 0 ]; then + cat tox-genops.log >&2 + echo "" + echo "#################################################" + echo "ERROR: Non-zero exit from generate_cinder_opts.py." + echo " See output above for details." + echo "#################################################" + mv cinder/opts.py.orig cinder/opts.py + exit 1 +fi + +diff cinder/opts.py.orig cinder/opts.py +if [ $? -ne 0 ]; then + echo "" + echo "########################################################" + echo "ERROR: Configuration options change detected." + echo " A new cinder/opts.py file must be generated." + echo " Run 'tox -e genopts' from the base directory" + echo " and add the result to your commit." + echo "########################################################" + rm cinder/opts.py + mv cinder/opts.py.orig cinder/opts.py + exit 1 +fi + +rm cinder/opts.py.orig