Skip to content

Commit 6808a34

Browse files
committed
Clean up remainders of USE_SYSTEMD and logging setup
We dropped the ability to override USE_SYSTEMD to False when we deleted screen support in [0], so we can also clean up any conditionals based on it. Also clean up the logging setup functions, dropping local vars for parameters that we don't actually support anymore. [0] I8c27182f60b0f5310b3a8bf5feb02beb7ffbb26a Change-Id: I5cbce9f2c42e111761e8689447b3f8cbb7ea2eb5
1 parent 46fd644 commit 6808a34

File tree

4 files changed

+31
-51
lines changed

4 files changed

+31
-51
lines changed

clean.sh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,10 @@ if [[ -n "$LOGDIR" ]] && [[ -d "$LOGDIR" ]]; then
123123
sudo rm -rf $LOGDIR
124124
fi
125125

126-
# Clean out the systemd user unit files if systemd was used.
127-
if [[ "$USE_SYSTEMD" = "True" ]]; then
128-
sudo find $SYSTEMD_DIR -type f -name '*devstack@*service' -delete
129-
# Make systemd aware of the deletion.
130-
$SYSTEMCTL daemon-reload
131-
fi
126+
# Clean out the systemd unit files.
127+
sudo find $SYSTEMD_DIR -type f -name '*devstack@*service' -delete
128+
# Make systemd aware of the deletion.
129+
$SYSTEMCTL daemon-reload
132130

133131
# Clean up venvs
134132
DIRS_TO_CLEAN="$WHEELHOUSE ${PROJECT_VENV[@]} .config/openstack"

functions

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -635,57 +635,46 @@ function vercmp {
635635
# This sets up defaults we like in devstack for logging for tracking
636636
# down issues, and makes sure everything is done the same between
637637
# projects.
638+
# NOTE(jh): Historically this function switched between three different
639+
# functions: setup_systemd_logging, setup_colorized_logging and
640+
# setup_standard_logging_identity. Since we always run with systemd now,
641+
# this could be cleaned up, but the other functions may still be in use
642+
# by plugins. Since deprecations haven't worked in the past, we'll just
643+
# leave them in place.
638644
function setup_logging {
639-
local conf_file=$1
640-
local other_cond=${2:-"False"}
641-
if [[ "$USE_SYSTEMD" == "True" ]]; then
642-
setup_systemd_logging $conf_file
643-
elif [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ] && [ "$other_cond" == "False" ]; then
644-
setup_colorized_logging $conf_file
645-
else
646-
setup_standard_logging_identity $conf_file
647-
fi
645+
setup_systemd_logging $1
648646
}
649647

650648
# This function sets log formatting options for colorizing log
651649
# output to stdout. It is meant to be called by lib modules.
652-
# The last two parameters are optional and can be used to specify
653-
# non-default value for project and user format variables.
654-
# Defaults are respectively 'project_name' and 'user_name'
655-
#
656-
# setup_colorized_logging something.conf SOMESECTION
657650
function setup_colorized_logging {
658651
local conf_file=$1
659-
local conf_section="DEFAULT"
660-
local project_var="project_name"
661-
local user_var="user_name"
662652
# Add color to logging output
663-
iniset $conf_file $conf_section logging_context_format_string "%(asctime)s.%(msecs)03d %(color)s%(levelname)s %(name)s [[01;36m%(request_id)s [00;36m%("$project_var")s %("$user_var")s%(color)s] [01;35m%(instance)s%(color)s%(message)s[00m"
664-
iniset $conf_file $conf_section logging_default_format_string "%(asctime)s.%(msecs)03d %(color)s%(levelname)s %(name)s [[00;36m-%(color)s] [01;35m%(instance)s%(color)s%(message)s[00m"
665-
iniset $conf_file $conf_section logging_debug_format_suffix "[00;33mfrom (pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d[00m"
666-
iniset $conf_file $conf_section logging_exception_prefix "%(color)s%(asctime)s.%(msecs)03d TRACE %(name)s [01;35m%(instance)s[00m"
653+
iniset $conf_file DEFAULT logging_context_format_string "%(asctime)s.%(msecs)03d %(color)s%(levelname)s %(name)s [[01;36m%(request_id)s [00;36m%(project_name)s %(user_name)s%(color)s] [01;35m%(instance)s%(color)s%(message)s[00m"
654+
iniset $conf_file DEFAULT logging_default_format_string "%(asctime)s.%(msecs)03d %(color)s%(levelname)s %(name)s [[00;36m-%(color)s] [01;35m%(instance)s%(color)s%(message)s[00m"
655+
iniset $conf_file DEFAULT logging_debug_format_suffix "[00;33mfrom (pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d[00m"
656+
iniset $conf_file DEFAULT logging_exception_prefix "%(color)s%(asctime)s.%(msecs)03d TRACE %(name)s [01;35m%(instance)s[00m"
667657
}
668658

669659
function setup_systemd_logging {
670660
local conf_file=$1
671-
local conf_section="DEFAULT"
672661
# NOTE(sdague): this is a nice to have, and means we're using the
673662
# native systemd path, which provides for things like search on
674663
# request-id. However, there may be an eventlet interaction here,
675664
# so going off for now.
676665
USE_JOURNAL=$(trueorfalse False USE_JOURNAL)
677666
local pidstr=""
678667
if [[ "$USE_JOURNAL" == "True" ]]; then
679-
iniset $conf_file $conf_section use_journal "True"
668+
iniset $conf_file DEFAULT use_journal "True"
680669
# if we are using the journal directly, our process id is already correct
681670
else
682671
pidstr="(pid=%(process)d) "
683672
fi
684-
iniset $conf_file $conf_section logging_debug_format_suffix "[00;33m{{${pidstr}%(funcName)s %(pathname)s:%(lineno)d}}[00m"
673+
iniset $conf_file DEFAULT logging_debug_format_suffix "[00;33m{{${pidstr}%(funcName)s %(pathname)s:%(lineno)d}}[00m"
685674

686-
iniset $conf_file $conf_section logging_context_format_string "%(color)s%(levelname)s %(name)s [[01;36m%(global_request_id)s %(request_id)s [00;36m%(project_name)s %(user_name)s%(color)s] [01;35m%(instance)s%(color)s%(message)s[00m"
687-
iniset $conf_file $conf_section logging_default_format_string "%(color)s%(levelname)s %(name)s [[00;36m-%(color)s] [01;35m%(instance)s%(color)s%(message)s[00m"
688-
iniset $conf_file $conf_section logging_exception_prefix "ERROR %(name)s [01;35m%(instance)s[00m"
675+
iniset $conf_file DEFAULT logging_context_format_string "%(color)s%(levelname)s %(name)s [[01;36m%(global_request_id)s %(request_id)s [00;36m%(project_name)s %(user_name)s%(color)s] [01;35m%(instance)s%(color)s%(message)s[00m"
676+
iniset $conf_file DEFAULT logging_default_format_string "%(color)s%(levelname)s %(name)s [[00;36m-%(color)s] [01;35m%(instance)s%(color)s%(message)s[00m"
677+
iniset $conf_file DEFAULT logging_exception_prefix "ERROR %(name)s [01;35m%(instance)s[00m"
689678
}
690679

691680
function setup_standard_logging_identity {

stack.sh

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -803,13 +803,11 @@ fixup_all
803803
# Install subunit for the subunit output stream
804804
pip_install -U os-testr
805805

806-
if [[ "$USE_SYSTEMD" == "True" ]]; then
807-
pip_install_gr systemd-python
808-
# the default rate limit of 1000 messages / 30 seconds is not
809-
# sufficient given how verbose our logging is.
810-
iniset -sudo /etc/systemd/journald.conf "Journal" "RateLimitBurst" "0"
811-
sudo systemctl restart systemd-journald
812-
fi
806+
pip_install_gr systemd-python
807+
# the default rate limit of 1000 messages / 30 seconds is not
808+
# sufficient given how verbose our logging is.
809+
iniset -sudo /etc/systemd/journald.conf "Journal" "RateLimitBurst" "0"
810+
sudo systemctl restart systemd-journald
813811

814812
# Virtual Environment
815813
# -------------------
@@ -1521,14 +1519,11 @@ if [[ -n "$DEPRECATED_TEXT" ]]; then
15211519
echo
15221520
fi
15231521

1524-
# If USE_SYSTEMD is enabled, tell the user about using it.
1525-
if [[ "$USE_SYSTEMD" == "True" ]]; then
1526-
echo
1527-
echo "Services are running under systemd unit files."
1528-
echo "For more information see: "
1529-
echo "https://docs.openstack.org/devstack/latest/systemd.html"
1530-
echo
1531-
fi
1522+
echo
1523+
echo "Services are running under systemd unit files."
1524+
echo "For more information see: "
1525+
echo "https://docs.openstack.org/devstack/latest/systemd.html"
1526+
echo
15321527

15331528
# Useful info on current state
15341529
cat /etc/devstack-version

stackrc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,7 @@ CELLSV2_SETUP=${CELLSV2_SETUP:-"superconductor"}
109109
# Set the root URL for Horizon
110110
HORIZON_APACHE_ROOT="/dashboard"
111111

112-
# Whether to use SYSTEMD to manage services, we only do this from
113-
# Queens forward.
114-
USE_SYSTEMD="True"
112+
# Whether to use user specific units for running services or global ones.
115113
USER_UNITS=$(trueorfalse False USER_UNITS)
116114
if [[ "$USER_UNITS" == "True" ]]; then
117115
SYSTEMD_DIR="$HOME/.local/share/systemd/user"

0 commit comments

Comments
 (0)