This tears out the alternative path of using screen, so that we only
use systemd enabled paths. This simplifies the number of ways that
devstack can be run, and provides a much more reliable process
launcher than the screen based approach.
Change-Id: I8c27182f60b0f5310b3a8bf5feb02beb7ffbb26a
... | ... |
@@ -1380,62 +1380,6 @@ function zypper_install { |
1380 | 1380 |
zypper --non-interactive install --auto-agree-with-licenses "$@" |
1381 | 1381 |
} |
1382 | 1382 |
|
1383 |
- |
|
1384 |
-# Process Functions |
|
1385 |
-# ================= |
|
1386 |
- |
|
1387 |
-# _run_process() is designed to be backgrounded by run_process() to simulate a |
|
1388 |
-# fork. It includes the dirty work of closing extra filehandles and preparing log |
|
1389 |
-# files to produce the same logs as screen_it(). The log filename is derived |
|
1390 |
-# from the service name. |
|
1391 |
-# Uses globals ``CURRENT_LOG_TIME``, ``LOGDIR``, ``SCREEN_LOGDIR``, ``SCREEN_NAME``, ``SERVICE_DIR`` |
|
1392 |
-# If an optional group is provided sg will be used to set the group of |
|
1393 |
-# the command. |
|
1394 |
-# _run_process service "command-line" [group] |
|
1395 |
-function _run_process { |
|
1396 |
- # disable tracing through the exec redirects, it's just confusing in the logs. |
|
1397 |
- xtrace=$(set +o | grep xtrace) |
|
1398 |
- set +o xtrace |
|
1399 |
- |
|
1400 |
- local service=$1 |
|
1401 |
- local command="$2" |
|
1402 |
- local group=$3 |
|
1403 |
- |
|
1404 |
- # Undo logging redirections and close the extra descriptors |
|
1405 |
- exec 1>&3 |
|
1406 |
- exec 2>&3 |
|
1407 |
- exec 3>&- |
|
1408 |
- exec 6>&- |
|
1409 |
- |
|
1410 |
- local logfile="${service}.log.${CURRENT_LOG_TIME}" |
|
1411 |
- local real_logfile="${LOGDIR}/${logfile}" |
|
1412 |
- if [[ -n ${LOGDIR} ]]; then |
|
1413 |
- exec 1>&"$real_logfile" 2>&1 |
|
1414 |
- bash -c "cd '$LOGDIR' && ln -sf '$logfile' ${service}.log" |
|
1415 |
- if [[ -n ${SCREEN_LOGDIR} ]]; then |
|
1416 |
- # Drop the backward-compat symlink |
|
1417 |
- ln -sf "$real_logfile" ${SCREEN_LOGDIR}/screen-${service}.log |
|
1418 |
- fi |
|
1419 |
- |
|
1420 |
- # TODO(dtroyer): Hack to get stdout from the Python interpreter for the logs. |
|
1421 |
- export PYTHONUNBUFFERED=1 |
|
1422 |
- fi |
|
1423 |
- |
|
1424 |
- # reenable xtrace before we do *real* work |
|
1425 |
- $xtrace |
|
1426 |
- |
|
1427 |
- # Run under ``setsid`` to force the process to become a session and group leader. |
|
1428 |
- # The pid saved can be used with pkill -g to get the entire process group. |
|
1429 |
- if [[ -n "$group" ]]; then |
|
1430 |
- setsid sg $group "$command" & echo $! >$SERVICE_DIR/$SCREEN_NAME/$service.pid |
|
1431 |
- else |
|
1432 |
- setsid $command & echo $! >$SERVICE_DIR/$SCREEN_NAME/$service.pid |
|
1433 |
- fi |
|
1434 |
- |
|
1435 |
- # Just silently exit this process |
|
1436 |
- exit 0 |
|
1437 |
-} |
|
1438 |
- |
|
1439 | 1383 |
function write_user_unit_file { |
1440 | 1384 |
local service=$1 |
1441 | 1385 |
local command="$2" |
... | ... |
@@ -1535,21 +1479,6 @@ function _run_under_systemd { |
1535 | 1535 |
$SYSTEMCTL start $systemd_service |
1536 | 1536 |
} |
1537 | 1537 |
|
1538 |
-# Helper to remove the ``*.failure`` files under ``$SERVICE_DIR/$SCREEN_NAME``. |
|
1539 |
-# This is used for ``service_check`` when all the ``screen_it`` are called finished |
|
1540 |
-# Uses globals ``SCREEN_NAME``, ``SERVICE_DIR`` |
|
1541 |
-# init_service_check |
|
1542 |
-function init_service_check { |
|
1543 |
- SCREEN_NAME=${SCREEN_NAME:-stack} |
|
1544 |
- SERVICE_DIR=${SERVICE_DIR:-${DEST}/status} |
|
1545 |
- |
|
1546 |
- if [[ ! -d "$SERVICE_DIR/$SCREEN_NAME" ]]; then |
|
1547 |
- mkdir -p "$SERVICE_DIR/$SCREEN_NAME" |
|
1548 |
- fi |
|
1549 |
- |
|
1550 |
- rm -f "$SERVICE_DIR/$SCREEN_NAME"/*.failure |
|
1551 |
-} |
|
1552 |
- |
|
1553 | 1538 |
# Find out if a process exists by partial name. |
1554 | 1539 |
# is_running name |
1555 | 1540 |
function is_running { |
... | ... |
@@ -1576,135 +1505,11 @@ function run_process { |
1576 | 1576 |
|
1577 | 1577 |
time_start "run_process" |
1578 | 1578 |
if is_service_enabled $service; then |
1579 |
- if [[ "$USE_SYSTEMD" = "True" ]]; then |
|
1580 |
- _run_under_systemd "$name" "$command" "$group" "$user" |
|
1581 |
- elif [[ "$USE_SCREEN" = "True" ]]; then |
|
1582 |
- if [[ "$user" == "root" ]]; then |
|
1583 |
- command="sudo $command" |
|
1584 |
- fi |
|
1585 |
- screen_process "$name" "$command" "$group" |
|
1586 |
- else |
|
1587 |
- # Spawn directly without screen |
|
1588 |
- if [[ "$user" == "root" ]]; then |
|
1589 |
- command="sudo $command" |
|
1590 |
- fi |
|
1591 |
- _run_process "$name" "$command" "$group" & |
|
1592 |
- fi |
|
1579 |
+ _run_under_systemd "$name" "$command" "$group" "$user" |
|
1593 | 1580 |
fi |
1594 | 1581 |
time_stop "run_process" |
1595 | 1582 |
} |
1596 | 1583 |
|
1597 |
-# Helper to launch a process in a named screen |
|
1598 |
-# Uses globals ``CURRENT_LOG_TIME``, ```LOGDIR``, ``SCREEN_LOGDIR``, `SCREEN_NAME``, |
|
1599 |
-# ``SERVICE_DIR``, ``SCREEN_IS_LOGGING`` |
|
1600 |
-# screen_process name "command-line" [group] |
|
1601 |
-# Run a command in a shell in a screen window, if an optional group |
|
1602 |
-# is provided, use sg to set the group of the command. |
|
1603 |
-function screen_process { |
|
1604 |
- local name=$1 |
|
1605 |
- local command="$2" |
|
1606 |
- local group=$3 |
|
1607 |
- |
|
1608 |
- SCREEN_NAME=${SCREEN_NAME:-stack} |
|
1609 |
- SERVICE_DIR=${SERVICE_DIR:-${DEST}/status} |
|
1610 |
- |
|
1611 |
- screen -S $SCREEN_NAME -X screen -t $name |
|
1612 |
- |
|
1613 |
- local logfile="${name}.log.${CURRENT_LOG_TIME}" |
|
1614 |
- local real_logfile="${LOGDIR}/${logfile}" |
|
1615 |
- echo "LOGDIR: $LOGDIR" |
|
1616 |
- echo "SCREEN_LOGDIR: $SCREEN_LOGDIR" |
|
1617 |
- echo "log: $real_logfile" |
|
1618 |
- if [[ -n ${LOGDIR} ]]; then |
|
1619 |
- if [[ "$SCREEN_IS_LOGGING" == "True" ]]; then |
|
1620 |
- screen -S $SCREEN_NAME -p $name -X logfile "$real_logfile" |
|
1621 |
- screen -S $SCREEN_NAME -p $name -X log on |
|
1622 |
- fi |
|
1623 |
- # If logging isn't active then avoid a broken symlink |
|
1624 |
- touch "$real_logfile" |
|
1625 |
- bash -c "cd '$LOGDIR' && ln -sf '$logfile' ${name}.log" |
|
1626 |
- if [[ -n ${SCREEN_LOGDIR} ]]; then |
|
1627 |
- # Drop the backward-compat symlink |
|
1628 |
- ln -sf "$real_logfile" ${SCREEN_LOGDIR}/screen-${1}.log |
|
1629 |
- fi |
|
1630 |
- fi |
|
1631 |
- |
|
1632 |
- # sleep to allow bash to be ready to be send the command - we are |
|
1633 |
- # creating a new window in screen and then sends characters, so if |
|
1634 |
- # bash isn't running by the time we send the command, nothing |
|
1635 |
- # happens. This sleep was added originally to handle gate runs |
|
1636 |
- # where we needed this to be at least 3 seconds to pass |
|
1637 |
- # consistently on slow clouds. Now this is configurable so that we |
|
1638 |
- # can determine a reasonable value for the local case which should |
|
1639 |
- # be much smaller. |
|
1640 |
- sleep ${SCREEN_SLEEP:-3} |
|
1641 |
- |
|
1642 |
- NL=`echo -ne '\015'` |
|
1643 |
- # This fun command does the following: |
|
1644 |
- # - the passed server command is backgrounded |
|
1645 |
- # - the pid of the background process is saved in the usual place |
|
1646 |
- # - the server process is brought back to the foreground |
|
1647 |
- # - if the server process exits prematurely the fg command errors |
|
1648 |
- # and a message is written to stdout and the process failure file |
|
1649 |
- # |
|
1650 |
- # The pid saved can be used in stop_process() as a process group |
|
1651 |
- # id to kill off all child processes |
|
1652 |
- if [[ -n "$group" ]]; then |
|
1653 |
- command="sg $group '$command'" |
|
1654 |
- fi |
|
1655 |
- |
|
1656 |
- # Append the process to the screen rc file |
|
1657 |
- screen_rc "$name" "$command" |
|
1658 |
- |
|
1659 |
- screen -S $SCREEN_NAME -p $name -X stuff "$command & echo \$! >$SERVICE_DIR/$SCREEN_NAME/${name}.pid; fg || echo \"$name failed to start. Exit code: \$?\" | tee \"$SERVICE_DIR/$SCREEN_NAME/${name}.failure\"$NL" |
|
1660 |
-} |
|
1661 |
- |
|
1662 |
-# Screen rc file builder |
|
1663 |
-# Uses globals ``SCREEN_NAME``, ``SCREENRC``, ``SCREEN_IS_LOGGING`` |
|
1664 |
-# screen_rc service "command-line" |
|
1665 |
-function screen_rc { |
|
1666 |
- SCREEN_NAME=${SCREEN_NAME:-stack} |
|
1667 |
- SCREENRC=$TOP_DIR/$SCREEN_NAME-screenrc |
|
1668 |
- if [[ ! -e $SCREENRC ]]; then |
|
1669 |
- # Name the screen session |
|
1670 |
- echo "sessionname $SCREEN_NAME" > $SCREENRC |
|
1671 |
- # Set a reasonable statusbar |
|
1672 |
- echo "hardstatus alwayslastline '$SCREEN_HARDSTATUS'" >> $SCREENRC |
|
1673 |
- # Some distributions override PROMPT_COMMAND for the screen terminal type - turn that off |
|
1674 |
- echo "setenv PROMPT_COMMAND /bin/true" >> $SCREENRC |
|
1675 |
- echo "screen -t shell bash" >> $SCREENRC |
|
1676 |
- fi |
|
1677 |
- # If this service doesn't already exist in the screenrc file |
|
1678 |
- if ! grep $1 $SCREENRC 2>&1 > /dev/null; then |
|
1679 |
- NL=`echo -ne '\015'` |
|
1680 |
- echo "screen -t $1 bash" >> $SCREENRC |
|
1681 |
- echo "stuff \"$2$NL\"" >> $SCREENRC |
|
1682 |
- |
|
1683 |
- if [[ -n ${LOGDIR} ]] && [[ "$SCREEN_IS_LOGGING" == "True" ]]; then |
|
1684 |
- echo "logfile ${LOGDIR}/${1}.log.${CURRENT_LOG_TIME}" >>$SCREENRC |
|
1685 |
- echo "log on" >>$SCREENRC |
|
1686 |
- fi |
|
1687 |
- fi |
|
1688 |
-} |
|
1689 |
- |
|
1690 |
-# Stop a service in screen |
|
1691 |
-# If a PID is available use it, kill the whole process group via TERM |
|
1692 |
-# If screen is being used kill the screen window; this will catch processes |
|
1693 |
-# that did not leave a PID behind |
|
1694 |
-# Uses globals ``SCREEN_NAME``, ``SERVICE_DIR`` |
|
1695 |
-# screen_stop_service service |
|
1696 |
-function screen_stop_service { |
|
1697 |
- local service=$1 |
|
1698 |
- |
|
1699 |
- SCREEN_NAME=${SCREEN_NAME:-stack} |
|
1700 |
- SERVICE_DIR=${SERVICE_DIR:-${DEST}/status} |
|
1701 |
- |
|
1702 |
- if is_service_enabled $service; then |
|
1703 |
- # Clean up the screen window |
|
1704 |
- screen -S $SCREEN_NAME -p $service -X kill || true |
|
1705 |
- fi |
|
1706 |
-} |
|
1707 |
- |
|
1708 | 1584 |
# Stop a service process |
1709 | 1585 |
# If a PID is available use it, kill the whole process group via TERM |
1710 | 1586 |
# If screen is being used kill the screen window; this will catch processes |
... | ... |
@@ -1724,150 +1529,28 @@ function stop_process { |
1724 | 1724 |
$SYSTEMCTL stop devstack@$service.service |
1725 | 1725 |
$SYSTEMCTL disable devstack@$service.service |
1726 | 1726 |
fi |
1727 |
- |
|
1728 |
- if [[ -r $SERVICE_DIR/$SCREEN_NAME/$service.pid ]]; then |
|
1729 |
- pkill -g $(cat $SERVICE_DIR/$SCREEN_NAME/$service.pid) |
|
1730 |
- # oslo.service tends to stop actually shutting down |
|
1731 |
- # reliably in between releases because someone believes it |
|
1732 |
- # is dying too early due to some inflight work they |
|
1733 |
- # have. This is a tension. It happens often enough we're |
|
1734 |
- # going to just account for it in devstack and assume it |
|
1735 |
- # doesn't work. |
|
1736 |
- # |
|
1737 |
- # Set OSLO_SERVICE_WORKS=True to skip this block |
|
1738 |
- if [[ -z "$OSLO_SERVICE_WORKS" ]]; then |
|
1739 |
- # TODO(danms): Remove this double-kill when we have |
|
1740 |
- # this fixed in all services: |
|
1741 |
- # https://bugs.launchpad.net/oslo-incubator/+bug/1446583 |
|
1742 |
- sleep 1 |
|
1743 |
- # /bin/true because pkill on a non existent process returns an error |
|
1744 |
- pkill -g $(cat $SERVICE_DIR/$SCREEN_NAME/$service.pid) || /bin/true |
|
1745 |
- fi |
|
1746 |
- rm $SERVICE_DIR/$SCREEN_NAME/$service.pid |
|
1747 |
- fi |
|
1748 |
- if [[ "$USE_SCREEN" = "True" ]]; then |
|
1749 |
- # Clean up the screen window |
|
1750 |
- screen_stop_service $service |
|
1751 |
- fi |
|
1752 | 1727 |
fi |
1753 | 1728 |
} |
1754 | 1729 |
|
1755 |
-# Helper to get the status of each running service |
|
1756 |
-# Uses globals ``SCREEN_NAME``, ``SERVICE_DIR`` |
|
1757 |
-# service_check |
|
1730 |
+# use systemctl to check service status |
|
1758 | 1731 |
function service_check { |
1759 | 1732 |
local service |
1760 |
- local failures |
|
1761 |
- SCREEN_NAME=${SCREEN_NAME:-stack} |
|
1762 |
- SERVICE_DIR=${SERVICE_DIR:-${DEST}/status} |
|
1763 |
- |
|
1764 |
- |
|
1765 |
- if [[ ! -d "$SERVICE_DIR/$SCREEN_NAME" ]]; then |
|
1766 |
- echo "No service status directory found" |
|
1767 |
- return |
|
1768 |
- fi |
|
1769 |
- |
|
1770 |
- # Check if there is any failure flag file under $SERVICE_DIR/$SCREEN_NAME |
|
1771 |
- # make this -o errexit safe |
|
1772 |
- failures=`ls "$SERVICE_DIR/$SCREEN_NAME"/*.failure 2>/dev/null || /bin/true` |
|
1773 |
- |
|
1774 |
- for service in $failures; do |
|
1775 |
- service=`basename $service` |
|
1776 |
- service=${service%.failure} |
|
1777 |
- echo "Error: Service $service is not running" |
|
1733 |
+ for service in ${ENABLED_SERVICES//,/ }; do |
|
1734 |
+ # because some things got renamed like key => keystone |
|
1735 |
+ if $SYSTEMCTL is-enabled devstack@$service.service; then |
|
1736 |
+ # no-pager is needed because otherwise status dumps to a |
|
1737 |
+ # pager when in interactive mode, which will stop a manual |
|
1738 |
+ # devstack run. |
|
1739 |
+ $SYSTEMCTL status devstack@$service.service --no-pager |
|
1740 |
+ fi |
|
1778 | 1741 |
done |
1779 |
- |
|
1780 |
- if [ -n "$failures" ]; then |
|
1781 |
- die $LINENO "More details about the above errors can be found with screen" |
|
1782 |
- fi |
|
1783 |
-} |
|
1784 |
- |
|
1785 |
-# Tail a log file in a screen if USE_SCREEN is true. |
|
1786 |
-# Uses globals ``USE_SCREEN`` |
|
1787 |
-function tail_log { |
|
1788 |
- local name=$1 |
|
1789 |
- local logfile=$2 |
|
1790 |
- |
|
1791 |
- if [[ "$USE_SCREEN" = "True" ]]; then |
|
1792 |
- screen_process "$name" "sudo tail -f $logfile | sed -u 's/\\\\\\\\x1b/\o033/g'" |
|
1793 |
- fi |
|
1794 |
-} |
|
1795 |
- |
|
1796 |
- |
|
1797 |
-# Deprecated Functions |
|
1798 |
-# -------------------- |
|
1799 |
- |
|
1800 |
-# _old_run_process() is designed to be backgrounded by old_run_process() to simulate a |
|
1801 |
-# fork. It includes the dirty work of closing extra filehandles and preparing log |
|
1802 |
-# files to produce the same logs as screen_it(). The log filename is derived |
|
1803 |
-# from the service name and global-and-now-misnamed ``SCREEN_LOGDIR`` |
|
1804 |
-# Uses globals ``CURRENT_LOG_TIME``, ``SCREEN_LOGDIR``, ``SCREEN_NAME``, ``SERVICE_DIR`` |
|
1805 |
-# _old_run_process service "command-line" |
|
1806 |
-function _old_run_process { |
|
1807 |
- local service=$1 |
|
1808 |
- local command="$2" |
|
1809 |
- |
|
1810 |
- # Undo logging redirections and close the extra descriptors |
|
1811 |
- exec 1>&3 |
|
1812 |
- exec 2>&3 |
|
1813 |
- exec 3>&- |
|
1814 |
- exec 6>&- |
|
1815 |
- |
|
1816 |
- if [[ -n ${SCREEN_LOGDIR} ]]; then |
|
1817 |
- exec 1>&${SCREEN_LOGDIR}/screen-${1}.log.${CURRENT_LOG_TIME} 2>&1 |
|
1818 |
- ln -sf ${SCREEN_LOGDIR}/screen-${1}.log.${CURRENT_LOG_TIME} ${SCREEN_LOGDIR}/screen-${1}.log |
|
1819 |
- |
|
1820 |
- # TODO(dtroyer): Hack to get stdout from the Python interpreter for the logs. |
|
1821 |
- export PYTHONUNBUFFERED=1 |
|
1822 |
- fi |
|
1823 |
- |
|
1824 |
- exec /bin/bash -c "$command" |
|
1825 |
- die "$service exec failure: $command" |
|
1826 |
-} |
|
1827 |
- |
|
1828 |
-# old_run_process() launches a child process that closes all file descriptors and |
|
1829 |
-# then exec's the passed in command. This is meant to duplicate the semantics |
|
1830 |
-# of screen_it() without screen. PIDs are written to |
|
1831 |
-# ``$SERVICE_DIR/$SCREEN_NAME/$service.pid`` by the spawned child process. |
|
1832 |
-# old_run_process service "command-line" |
|
1833 |
-function old_run_process { |
|
1834 |
- local service=$1 |
|
1835 |
- local command="$2" |
|
1836 |
- |
|
1837 |
- # Spawn the child process |
|
1838 |
- _old_run_process "$service" "$command" & |
|
1839 |
- echo $! |
|
1840 | 1742 |
} |
1841 | 1743 |
|
1842 |
-# Compatibility for existing start_XXXX() functions |
|
1843 |
-# Uses global ``USE_SCREEN`` |
|
1844 |
-# screen_it service "command-line" |
|
1845 |
-function screen_it { |
|
1846 |
- if is_service_enabled $1; then |
|
1847 |
- # Append the service to the screen rc file |
|
1848 |
- screen_rc "$1" "$2" |
|
1849 |
- |
|
1850 |
- if [[ "$USE_SCREEN" = "True" ]]; then |
|
1851 |
- screen_process "$1" "$2" |
|
1852 |
- else |
|
1853 |
- # Spawn directly without screen |
|
1854 |
- old_run_process "$1" "$2" >$SERVICE_DIR/$SCREEN_NAME/$1.pid |
|
1855 |
- fi |
|
1856 |
- fi |
|
1857 |
-} |
|
1858 | 1744 |
|
1859 |
-# Compatibility for existing stop_XXXX() functions |
|
1860 |
-# Stop a service in screen |
|
1861 |
-# If a PID is available use it, kill the whole process group via TERM |
|
1862 |
-# If screen is being used kill the screen window; this will catch processes |
|
1863 |
-# that did not leave a PID behind |
|
1864 |
-# screen_stop service |
|
1865 |
-function screen_stop { |
|
1866 |
- # Clean up the screen window |
|
1867 |
- stop_process $1 |
|
1745 |
+function tail_log { |
|
1746 |
+ deprecated "With the removal of screen support, tail_log is deprecated and will be removed after Queens" |
|
1868 | 1747 |
} |
1869 | 1748 |
|
1870 |
- |
|
1871 | 1749 |
# Plugin Functions |
1872 | 1750 |
# ================= |
1873 | 1751 |
|
... | ... |
@@ -573,10 +573,6 @@ function create_nova_conf { |
573 | 573 |
if [[ -n ${LOGDIR} ]]; then |
574 | 574 |
bash -c "cd '$LOGDIR' && ln -sf '$logfile' ${service}.log" |
575 | 575 |
iniset "$NOVA_CONF_DIR/nova-dhcpbridge.conf" DEFAULT log_file "$real_logfile" |
576 |
- if [[ -n ${SCREEN_LOGDIR} ]]; then |
|
577 |
- # Drop the backward-compat symlink |
|
578 |
- ln -sf "$real_logfile" ${SCREEN_LOGDIR}/screen-${service}.log |
|
579 |
- fi |
|
580 | 576 |
fi |
581 | 577 |
|
582 | 578 |
iniset $NOVA_CONF DEFAULT dhcpbridge_flagfile "$NOVA_CONF_DIR/nova-dhcpbridge.conf" |
... | ... |
@@ -228,16 +228,6 @@ if [[ ! ${DISTRO} =~ (xenial|yakkety|zesty|stretch|jessie|f24|f25|f26|opensuse-4 |
228 | 228 |
fi |
229 | 229 |
fi |
230 | 230 |
|
231 |
-# Check to see if we are already running DevStack |
|
232 |
-# Note that this may fail if USE_SCREEN=False |
|
233 |
-if type -p screen > /dev/null && screen -ls | egrep -q "[0-9]\.$SCREEN_NAME"; then |
|
234 |
- echo "You are already running a stack.sh session." |
|
235 |
- echo "To rejoin this session type 'screen -x stack'." |
|
236 |
- echo "To destroy this session, type './unstack.sh'." |
|
237 |
- exit 1 |
|
238 |
-fi |
|
239 |
- |
|
240 |
- |
|
241 | 231 |
# Local Settings |
242 | 232 |
# -------------- |
243 | 233 |
|
... | ... |
@@ -491,24 +481,6 @@ else |
491 | 491 |
exec 6> >( $TOP_DIR/tools/outfilter.py -v >&3 ) |
492 | 492 |
fi |
493 | 493 |
|
494 |
-# Set up logging of screen windows |
|
495 |
-# Set ``SCREEN_LOGDIR`` to turn on logging of screen windows to the |
|
496 |
-# directory specified in ``SCREEN_LOGDIR``, we will log to the file |
|
497 |
-# ``screen-$SERVICE_NAME-$TIMESTAMP.log`` in that dir and have a link |
|
498 |
-# ``screen-$SERVICE_NAME.log`` to the latest log file. |
|
499 |
-# Logs are kept for as long specified in ``LOGDAYS``. |
|
500 |
-# This is deprecated....logs go in ``LOGDIR``, only symlinks will be here now. |
|
501 |
-if [[ -n "$SCREEN_LOGDIR" ]]; then |
|
502 |
- |
|
503 |
- # We make sure the directory is created. |
|
504 |
- if [[ -d "$SCREEN_LOGDIR" ]]; then |
|
505 |
- # We cleanup the old logs |
|
506 |
- find $SCREEN_LOGDIR -maxdepth 1 -name screen-\*.log -mtime +$LOGDAYS -exec rm {} \; |
|
507 |
- else |
|
508 |
- mkdir -p $SCREEN_LOGDIR |
|
509 |
- fi |
|
510 |
-fi |
|
511 |
- |
|
512 | 494 |
# Basic test for ``$DEST`` path permissions (fatal on error unless skipped) |
513 | 495 |
check_path_perm_sanity ${DEST} |
514 | 496 |
|
... | ... |
@@ -1015,38 +987,6 @@ if is_service_enabled $DATABASE_BACKENDS; then |
1015 | 1015 |
configure_database |
1016 | 1016 |
fi |
1017 | 1017 |
|
1018 |
- |
|
1019 |
-# Configure screen |
|
1020 |
-# ---------------- |
|
1021 |
- |
|
1022 |
-USE_SCREEN=$(trueorfalse True USE_SCREEN) |
|
1023 |
-if [[ "$USE_SCREEN" == "True" ]]; then |
|
1024 |
- # Create a new named screen to run processes in |
|
1025 |
- screen -d -m -S $SCREEN_NAME -t shell -s /bin/bash |
|
1026 |
- sleep 1 |
|
1027 |
- |
|
1028 |
- # Set a reasonable status bar |
|
1029 |
- SCREEN_HARDSTATUS=${SCREEN_HARDSTATUS:-} |
|
1030 |
- if [ -z "$SCREEN_HARDSTATUS" ]; then |
|
1031 |
- SCREEN_HARDSTATUS='%{= .} %-Lw%{= .}%> %n%f %t*%{= .}%+Lw%< %-=%{g}(%{d}%H/%l%{g})' |
|
1032 |
- fi |
|
1033 |
- screen -r $SCREEN_NAME -X hardstatus alwayslastline "$SCREEN_HARDSTATUS" |
|
1034 |
- screen -r $SCREEN_NAME -X setenv PROMPT_COMMAND /bin/true |
|
1035 |
- |
|
1036 |
- if is_service_enabled tls-proxy; then |
|
1037 |
- follow_tls_proxy |
|
1038 |
- fi |
|
1039 |
-fi |
|
1040 |
- |
|
1041 |
-# Clear ``screenrc`` file |
|
1042 |
-SCREENRC=$TOP_DIR/$SCREEN_NAME-screenrc |
|
1043 |
-if [[ -e $SCREENRC ]]; then |
|
1044 |
- rm -f $SCREENRC |
|
1045 |
-fi |
|
1046 |
- |
|
1047 |
-# Initialize the directory for service status check |
|
1048 |
-init_service_check |
|
1049 |
- |
|
1050 | 1018 |
# Save configuration values |
1051 | 1019 |
save_stackenv $LINENO |
1052 | 1020 |
|
... | ... |
@@ -88,22 +88,9 @@ CELLSV2_SETUP=${CELLSV2_SETUP:-"superconductor"} |
88 | 88 |
# Set the root URL for Horizon |
89 | 89 |
HORIZON_APACHE_ROOT="/dashboard" |
90 | 90 |
|
91 |
-# TODO(sdague): Queens |
|
92 |
-# |
|
93 |
-# All the non systemd paths should be removed in queens, they only |
|
94 |
-# exist in Pike to support testing from grenade. Ensure that all this |
|
95 |
-# is cleaned up and purged, which should dramatically simplify the |
|
96 |
-# devstack codebase. |
|
97 |
- |
|
98 |
-# Whether to use 'dev mode' for screen windows. Dev mode works by |
|
99 |
-# stuffing text into the screen windows so that a developer can use |
|
100 |
-# ctrl-c, up-arrow, enter to restart the service. Starting services |
|
101 |
-# this way is slightly unreliable, and a bit slower, so this can |
|
102 |
-# be disabled for automated testing by setting this value to False. |
|
103 |
-USE_SCREEN=$(trueorfalse False USE_SCREEN) |
|
104 |
- |
|
105 |
-# Whether to use SYSTEMD to manage services |
|
106 |
-USE_SYSTEMD=$(trueorfalse False USE_SYSTEMD) |
|
91 |
+# Whether to use SYSTEMD to manage services, we only do this from |
|
92 |
+# Queens forward. |
|
93 |
+USE_SYSTEMD="True" |
|
107 | 94 |
USER_UNITS=$(trueorfalse False USER_UNITS) |
108 | 95 |
if [[ "$USER_UNITS" == "True" ]]; then |
109 | 96 |
SYSTEMD_DIR="$HOME/.local/share/systemd/user" |
... | ... |
@@ -122,16 +109,6 @@ fi |
122 | 122 |
# memory constrained than CPU bound. |
123 | 123 |
ENABLE_KSM=$(trueorfalse True ENABLE_KSM) |
124 | 124 |
|
125 |
-# When using screen, should we keep a log file on disk? You might |
|
126 |
-# want this False if you have a long-running setup where verbose logs |
|
127 |
-# can fill-up the host. |
|
128 |
-# XXX: Ideally screen itself would be configured to log but just not |
|
129 |
-# activate. This isn't possible with the screerc syntax. Temporary |
|
130 |
-# logging can still be used by a developer with: |
|
131 |
-# C-a : logfile foo |
|
132 |
-# C-a : log on |
|
133 |
-SCREEN_IS_LOGGING=$(trueorfalse True SCREEN_IS_LOGGING) |
|
134 |
- |
|
135 | 125 |
# Passwords generated by interactive devstack runs |
136 | 126 |
if [[ -r $RC_DIR/.localrc.password ]]; then |
137 | 127 |
source $RC_DIR/.localrc.password |
... | ... |
@@ -167,16 +144,6 @@ elif [[ -f $RC_DIR/.localrc.auto ]]; then |
167 | 167 |
source $RC_DIR/.localrc.auto |
168 | 168 |
fi |
169 | 169 |
|
170 |
-# TODO(sdague): Delete all this in Queens. |
|
171 |
-if [[ "$USE_SYSTEMD" == "True" ]]; then |
|
172 |
- USE_SCREEN=False |
|
173 |
-fi |
|
174 |
-# if we are forcing off USE_SCREEN (as we do in the gate), force on |
|
175 |
-# systemd. This allows us to drop one of 3 paths through the code. |
|
176 |
-if [[ "$USE_SCREEN" == "False" ]]; then |
|
177 |
- USE_SYSTEMD="True" |
|
178 |
-fi |
|
179 |
- |
|
180 | 170 |
# Default for log coloring is based on interactive-or-not. |
181 | 171 |
# Baseline assumption is that non-interactive invocations are for CI, |
182 | 172 |
# where logs are to be presented as browsable text files; hence color |
... | ... |
@@ -755,9 +722,6 @@ PUBLIC_NETWORK_NAME=${PUBLIC_NETWORK_NAME:-"public"} |
755 | 755 |
|
756 | 756 |
PUBLIC_INTERFACE=${PUBLIC_INTERFACE:-""} |
757 | 757 |
|
758 |
-# Set default screen name |
|
759 |
-SCREEN_NAME=${SCREEN_NAME:-stack} |
|
760 |
- |
|
761 | 758 |
# Allow the use of an alternate protocol (such as https) for service endpoints |
762 | 759 |
SERVICE_PROTOCOL=${SERVICE_PROTOCOL:-http} |
763 | 760 |
|
... | ... |
@@ -877,15 +841,6 @@ RECREATE_KEYSTONE_DB=$(trueorfalse True RECREATE_KEYSTONE_DB) |
877 | 877 |
|
878 | 878 |
# Following entries need to be last items in file |
879 | 879 |
|
880 |
-# Compatibility bits required by other callers like Grenade |
|
881 |
- |
|
882 |
-# Old way was using SCREEN_LOGDIR to locate those logs and LOGFILE for the stack.sh trace log. |
|
883 |
-# LOGFILE SCREEN_LOGDIR output |
|
884 |
-# not set not set no log files |
|
885 |
-# set not set stack.sh log to LOGFILE |
|
886 |
-# not set set screen logs to SCREEN_LOGDIR |
|
887 |
-# set set stack.sh log to LOGFILE, screen logs to SCREEN_LOGDIR |
|
888 |
- |
|
889 | 880 |
# New way is LOGDIR for all logs and LOGFILE for stack.sh trace log, but if not fully-qualified will be in LOGDIR |
890 | 881 |
# LOGFILE LOGDIR output |
891 | 882 |
# not set not set (new) set LOGDIR from default |
... | ... |
@@ -893,9 +848,6 @@ RECREATE_KEYSTONE_DB=$(trueorfalse True RECREATE_KEYSTONE_DB) |
893 | 893 |
# not set set screen logs to LOGDIR |
894 | 894 |
# set set stack.sh log to LOGFILE, screen logs to LOGDIR |
895 | 895 |
|
896 |
-# For compat, if SCREEN_LOGDIR is set, it will be used to create back-compat symlinks to the LOGDIR |
|
897 |
-# symlinks to SCREEN_LOGDIR (compat) |
|
898 |
- |
|
899 | 896 |
# Set up new logging defaults |
900 | 897 |
if [[ -z "${LOGDIR:-}" ]]; then |
901 | 898 |
default_logdir=$DEST/logs |
... | ... |
@@ -910,12 +862,6 @@ if [[ -z "${LOGDIR:-}" ]]; then |
910 | 910 |
# LOGFILE had no path, set a default |
911 | 911 |
LOGDIR="$default_logdir" |
912 | 912 |
fi |
913 |
- |
|
914 |
- # Check for duplication |
|
915 |
- if [[ "${SCREEN_LOGDIR:-}" == "${LOGDIR}" ]]; then |
|
916 |
- # We don't need the symlinks since it's the same directory |
|
917 |
- unset SCREEN_LOGDIR |
|
918 |
- fi |
|
919 | 913 |
fi |
920 | 914 |
unset default_logdir logfile |
921 | 915 |
fi |
922 | 916 |
deleted file mode 100755 |
... | ... |
@@ -1,109 +0,0 @@ |
1 |
-#!/bin/bash |
|
2 |
-# tests/exec.sh - Test DevStack run_process() and stop_process() |
|
3 |
-# |
|
4 |
-# exec.sh start|stop|status |
|
5 |
-# |
|
6 |
-# Set USE_SCREEN True|False to change use of screen. |
|
7 |
-# |
|
8 |
-# This script emulates the basic exec environment in ``stack.sh`` to test |
|
9 |
-# the process spawn and kill operations. |
|
10 |
- |
|
11 |
-if [[ -z $1 ]]; then |
|
12 |
- echo "$0 start|stop" |
|
13 |
- exit 1 |
|
14 |
-fi |
|
15 |
- |
|
16 |
-TOP_DIR=$(cd $(dirname "$0")/.. && pwd) |
|
17 |
-source $TOP_DIR/functions |
|
18 |
- |
|
19 |
-USE_SCREEN=${USE_SCREEN:-False} |
|
20 |
- |
|
21 |
-ENABLED_SERVICES=fake-service |
|
22 |
- |
|
23 |
-SERVICE_DIR=/tmp |
|
24 |
-SCREEN_NAME=test |
|
25 |
-SCREEN_LOGDIR=${SERVICE_DIR}/${SCREEN_NAME} |
|
26 |
- |
|
27 |
- |
|
28 |
-# Kill background processes on exit |
|
29 |
-trap clean EXIT |
|
30 |
-clean() { |
|
31 |
- local r=$? |
|
32 |
- jobs -p |
|
33 |
- kill >/dev/null 2>&1 $(jobs -p) |
|
34 |
- exit $r |
|
35 |
-} |
|
36 |
- |
|
37 |
- |
|
38 |
-# Exit on any errors so that errors don't compound |
|
39 |
-trap failed ERR |
|
40 |
-failed() { |
|
41 |
- local r=$? |
|
42 |
- jobs -p |
|
43 |
- kill >/dev/null 2>&1 $(jobs -p) |
|
44 |
- set +o xtrace |
|
45 |
- [ -n "$LOGFILE" ] && echo "${0##*/} failed: full log in $LOGFILE" |
|
46 |
- exit $r |
|
47 |
-} |
|
48 |
- |
|
49 |
-function status { |
|
50 |
- if [[ -r $SERVICE_DIR/$SCREEN_NAME/fake-service.pid ]]; then |
|
51 |
- pstree -pg $(cat $SERVICE_DIR/$SCREEN_NAME/fake-service.pid) |
|
52 |
- fi |
|
53 |
- ps -ef | grep fake |
|
54 |
-} |
|
55 |
- |
|
56 |
-function setup_screen { |
|
57 |
-if [[ ! -d $SERVICE_DIR/$SCREEN_NAME ]]; then |
|
58 |
- rm -rf $SERVICE_DIR/$SCREEN_NAME |
|
59 |
- mkdir -p $SERVICE_DIR/$SCREEN_NAME |
|
60 |
-fi |
|
61 |
- |
|
62 |
-if [[ "$USE_SCREEN" == "True" ]]; then |
|
63 |
- # Create a new named screen to run processes in |
|
64 |
- screen -d -m -S $SCREEN_NAME -t shell -s /bin/bash |
|
65 |
- sleep 1 |
|
66 |
- |
|
67 |
- # Set a reasonable status bar |
|
68 |
- if [ -z "$SCREEN_HARDSTATUS" ]; then |
|
69 |
- SCREEN_HARDSTATUS='%{= .} %-Lw%{= .}%> %n%f %t*%{= .}%+Lw%< %-=%{g}(%{d}%H/%l%{g})' |
|
70 |
- fi |
|
71 |
- screen -r $SCREEN_NAME -X hardstatus alwayslastline "$SCREEN_HARDSTATUS" |
|
72 |
-fi |
|
73 |
- |
|
74 |
-# Clear screen rc file |
|
75 |
-SCREENRC=$TOP_DIR/tests/$SCREEN_NAME-screenrc |
|
76 |
-if [[ -e $SCREENRC ]]; then |
|
77 |
- echo -n > $SCREENRC |
|
78 |
-fi |
|
79 |
-} |
|
80 |
- |
|
81 |
-# Mimic logging |
|
82 |
- # Set up output redirection without log files |
|
83 |
- # Copy stdout to fd 3 |
|
84 |
- exec 3>&1 |
|
85 |
- if [[ "$VERBOSE" != "True" ]]; then |
|
86 |
- # Throw away stdout and stderr |
|
87 |
- #exec 1>/dev/null 2>&1 |
|
88 |
- : |
|
89 |
- fi |
|
90 |
- # Always send summary fd to original stdout |
|
91 |
- exec 6>&3 |
|
92 |
- |
|
93 |
- |
|
94 |
-if [[ "$1" == "start" ]]; then |
|
95 |
- echo "Start service" |
|
96 |
- setup_screen |
|
97 |
- run_process fake-service "$TOP_DIR/tests/fake-service.sh" |
|
98 |
- sleep 1 |
|
99 |
- status |
|
100 |
-elif [[ "$1" == "stop" ]]; then |
|
101 |
- echo "Stop service" |
|
102 |
- stop_process fake-service |
|
103 |
- status |
|
104 |
-elif [[ "$1" == "status" ]]; then |
|
105 |
- status |
|
106 |
-else |
|
107 |
- echo "Unknown command" |
|
108 |
- exit 1 |
|
109 |
-fi |
... | ... |
@@ -171,15 +171,6 @@ if is_service_enabled dstat; then |
171 | 171 |
stop_dstat |
172 | 172 |
fi |
173 | 173 |
|
174 |
-# Clean up the remainder of the screen processes |
|
175 |
-SCREEN=$(which screen) |
|
176 |
-if [[ -n "$SCREEN" ]]; then |
|
177 |
- SESSION=$(screen -ls | awk "/[0-9]+.${SCREEN_NAME}/"'{ print $1 }') |
|
178 |
- if [[ -n "$SESSION" ]]; then |
|
179 |
- screen -X -S $SESSION quit |
|
180 |
- fi |
|
181 |
-fi |
|
182 |
- |
|
183 | 174 |
# NOTE: Cinder automatically installs the lvm2 package, independently of the |
184 | 175 |
# enabled backends. So if Cinder is enabled, and installed successfully we are |
185 | 176 |
# sure lvm2 (lvremove, /etc/lvm/lvm.conf, etc.) is here. |