devstack: Make sentry _IRONIC_DEVSTACK_LIB a global variable

Make the sentry variable _IRONIC_DEVSTACK_LIB a global variable so
that it will work as expected.

When variables use the 'declare' directive, it is by default a local
variable. While other variables have global scope.

For example:
   declare -A AN_ARRAY   # local in scope
   foo=1                 # global in scope
   declare -A -g SPAM    # global in scope because of -g

This causes errors to occur as some of the variables will be local only
and others will be global.

The issue that can occur is that when sourcing devstack/lib/ironic a
second time the sentry _IRONIC_DEVSTACK_LIB will not be set but all
the other variables from devstack/lib/ironic will already have been
set as they are by default global variables. And the purpose of
_IRONIC_DEVSTACK_LIB is to prevent the file from being sourced twice.

Change-Id: I24b6ebb89f3d950d39b0665346b4c17bf05d0a0b
This commit is contained in:
John L. Villalovos 2017-03-07 14:39:49 -08:00
parent e2e5340981
commit 1e560b182f

View File

@ -22,7 +22,7 @@
# ensure we don't re-source this in the same environment
[[ -z "$_IRONIC_DEVSTACK_LIB" ]] || return 0
declare -r _IRONIC_DEVSTACK_LIB=1
declare -r -g _IRONIC_DEVSTACK_LIB=1
# Save xtrace and pipefail settings
_XTRACE_IRONIC=$(set +o | grep xtrace)