Skip to content

Commit fd1050f

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Perform additional disable_service checks"
2 parents 611cab4 + c6d4701 commit fd1050f

2 files changed

Lines changed: 27 additions & 8 deletions

File tree

functions-common

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,6 +1729,7 @@ function run_phase {
17291729
# the source phase corresponds to settings loading in plugins
17301730
if [[ "$mode" == "source" ]]; then
17311731
load_plugin_settings
1732+
verify_disabled_services
17321733
elif [[ "$mode" == "override_defaults" ]]; then
17331734
plugin_override_defaults
17341735
else
@@ -1784,25 +1785,26 @@ function disable_negated_services {
17841785
ENABLED_SERVICES=$(remove_disabled_services "$remaining" "$to_remove")
17851786
}
17861787

1787-
# disable_service() removes the services passed as argument to the
1788-
# ``ENABLED_SERVICES`` list, if they are present.
1788+
# disable_service() prepares the services passed as argument to be
1789+
# removed from the ``ENABLED_SERVICES`` list, if they are present.
17891790
#
17901791
# For example:
17911792
# disable_service rabbit
17921793
#
1793-
# This function does not know about the special cases
1794-
# for nova, glance, and neutron built into is_service_enabled().
1795-
# Uses global ``ENABLED_SERVICES``
1794+
# Uses global ``DISABLED_SERVICES``
17961795
# disable_service service [service ...]
17971796
function disable_service {
1798-
local tmpsvcs=",${ENABLED_SERVICES},"
1797+
local disabled_svcs="${DISABLED_SERVICES}"
1798+
local enabled_svcs=",${ENABLED_SERVICES},"
17991799
local service
18001800
for service in $@; do
1801+
disabled_svcs+=",$service"
18011802
if is_service_enabled $service; then
1802-
tmpsvcs=${tmpsvcs//,$service,/,}
1803+
enabled_svcs=${enabled_svcs//,$service,/,}
18031804
fi
18041805
done
1805-
ENABLED_SERVICES=$(_cleanup_service_list "$tmpsvcs")
1806+
DISABLED_SERVICES=$(_cleanup_service_list "$disabled_svcs")
1807+
ENABLED_SERVICES=$(_cleanup_service_list "$enabled_svcs")
18061808
}
18071809

18081810
# enable_service() adds the services passed as argument to the
@@ -1819,6 +1821,10 @@ function enable_service {
18191821
local tmpsvcs="${ENABLED_SERVICES}"
18201822
local service
18211823
for service in $@; do
1824+
if [[ ,${DISABLED_SERVICES}, =~ ,${service}, ]]; then
1825+
warn $LINENO "Attempt to enable_service ${service} when it has been disabled"
1826+
continue
1827+
fi
18221828
if ! is_service_enabled $service; then
18231829
tmpsvcs+=",$service"
18241830
fi
@@ -1923,6 +1929,18 @@ function use_exclusive_service {
19231929
return 0
19241930
}
19251931

1932+
# Make sure that nothing has manipulated ENABLED_SERVICES in a way
1933+
# that conflicts with prior calls to disable_service.
1934+
# Uses global ``ENABLED_SERVICES``
1935+
function verify_disabled_services {
1936+
local service
1937+
for service in ${ENABLED_SERVICES//,/ }; do
1938+
if [[ ,${DISABLED_SERVICES}, =~ ,${service}, ]]; then
1939+
die $LINENO "ENABLED_SERVICES directly modified to overcome 'disable_service ${service}'"
1940+
fi
1941+
done
1942+
}
1943+
19261944

19271945
# System Functions
19281946
# ================

stack.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ source $TOP_DIR/lib/dstat
553553
# Phase: source
554554
run_phase source
555555

556+
556557
# Interactive Configuration
557558
# -------------------------
558559

0 commit comments

Comments
 (0)