Add nodepool-launcher support

We now have the ability to scale out nodepool-launcher, on a single
instance.

Change-Id: Ib7792ea591c7e1ce953730791884566f77fcbd33
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
Paul Belanger 2016-10-08 15:11:30 -04:00
parent 470bbd7908
commit 7ae472381d
13 changed files with 434 additions and 4 deletions

View File

@ -66,6 +66,12 @@ nodepool_file_deleter_logging_conf_mode: 0644
nodepool_file_deleter_logging_conf_owner: "{{ nodepool_user_name }}"
nodepool_file_deleter_logging_conf_src: etc/nodepool/deleter-logging.conf
nodepool_file_launcher_logging_conf_dest: /etc/nodepool/launcher-logging.conf
nodepool_file_launcher_logging_conf_group: "{{ nodepool_user_group }}"
nodepool_file_launcher_logging_conf_mode: 0644
nodepool_file_launcher_logging_conf_owner: "{{ nodepool_user_name }}"
nodepool_file_launcher_logging_conf_src: etc/nodepool/launcher-logging.conf
# tasks/install.yaml
nodepool_git_dest: /opt/ansible-role-nodepool/git/openstack-infra/nodepool
nodepool_git_uri: https://git.openstack.org/openstack-infra/nodepool
@ -97,6 +103,12 @@ nodepool_file_nodepool_deleter_service_owner: root
nodepool_file_nodepool_deleter_service_config_group: root
nodepool_file_nodepool_deleter_service_config_owner: root
nodepool_file_nodepool_launcher_service_group: root
nodepool_file_nodepool_launcher_service_owner: root
nodepool_file_nodepool_launcher_service_config_group: root
nodepool_file_nodepool_launcher_service_config_owner: root
nodepool_service_nodepool_enabled: yes
nodepool_service_nodepool_manage: true
nodepool_service_nodepool_name: nodepool
@ -111,3 +123,8 @@ nodepool_service_nodepool_deleter_enabled: yes
nodepool_service_nodepool_deleter_manage: true
nodepool_service_nodepool_deleter_name: nodepool-deleter
nodepool_service_nodepool_deleter_state: started
nodepool_service_nodepool_launcher_enabled: yes
nodepool_service_nodepool_launcher_manage: true
nodepool_service_nodepool_launcher_name: nodepool-launcher
nodepool_service_nodepool_launcher_state: started

View File

@ -7,6 +7,6 @@
PREFIX=/usr/local
# Options to pass to nodepoold.
ARGS="-l /etc/nodepool/logging.conf --no-builder --no-deletes"
ARGS="-l /etc/nodepool/logging.conf --no-builder --no-deletes --no-launches"
DIB_IMAGE_CACHE=/opt/nodepool/cache

View File

@ -0,0 +1,12 @@
# This file is generated by Ansible
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
#
# The prefix used when nodepool-launcher was installed. Be sure to update this
# value if you are using a virtualenv.
PREFIX=/usr/local
# Options to pass to nodepool-launcher.
ARGS="-l /etc/nodepool/launcher-logging.conf --no-builder --no-deletes --no-images --no-webapp"
DIB_IMAGE_CACHE=/opt/nodepool/cache

View File

@ -0,0 +1,155 @@
#! /bin/sh
### BEGIN INIT INFO
# Provides: nodepool-launcher
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Nodepool
# Description: Trunk gating system
### END INIT INFO
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
DESC="Nodepool Launcher"
NAME=nodepool-launcher
PIDFILE=/var/run/$NAME/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
USER=nodepool
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
DAEMON=$PREFIX/bin/nodepoold
# Exit if the package is not installed
[ -x "$DAEMON" ] || (echo "$DAEMON: command not found" && exit 5)
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
#
# Function that starts the daemon/service
#
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
mkdir -p /var/run/$NAME
chown $USER /var/run/$NAME
chown $USER /var/run/$NAME
start-stop-daemon --start --quiet --pidfile $PIDFILE -c $USER \
--exec $DAEMON --test > /dev/null || return 1
start-stop-daemon --start --quiet --pidfile $PIDFILE -c $USER \
--exec $DAEMON -- $ARGS || return 2
# Add code here, if necessary, that waits for the process to be ready
# to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some time.
}
#
# Function that stops the daemon/service
#
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --signal 9 --pidfile $PIDFILE
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
rm -f /var/run/$NAME/*
return "$RETVAL"
}
#
# Function that stops the daemon/service
#
do_graceful_stop()
{
PID=`cat $PIDFILE`
kill -INT $PID
# wait until really stopped
if [ -n "${PID:-}" ]; then
i=0
while kill -0 "${PID:-}" 2> /dev/null; do
if [ $i -eq '0' ]; then
echo -n " ... waiting "
else
echo -n "."
fi
i=$(($i+1))
sleep 1
done
fi
rm -f /var/run/$NAME/*
}
#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
#
# If the daemon can reload its configuration without
# restarting (for example, when it is sent a SIGHUP),
# then implement that here.
#
start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
return 0
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
reload|force-reload)
#
# If do_reload() is not implemented then leave this commented out
# and leave 'force-reload' as an alias for 'restart'.
#
log_daemon_msg "Reloading $DESC" "$NAME"
do_reload
log_end_msg $?
;;
restart)
#
# If the "reload" option is implemented then remove the
# 'force-reload' alias
#
log_daemon_msg "Restarting $DESC" "$NAME"
do_graceful_stop
do_start
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac
:

View File

@ -0,0 +1,49 @@
[loggers]
keys=root,nodepool,requests,shade
[handlers]
keys=console,debug,normal
[formatters]
keys=simple
[logger_root]
level=WARNING
handlers=console
[logger_requests]
level=WARNING
handlers=debug,normal
qualname=requests
[logger_shade]
level=DEBUG
handlers=debug,normal
qualname=shade
[logger_nodepool]
level=DEBUG
handlers=debug,normal
qualname=nodepool
[handler_console]
level=WARNING
class=StreamHandler
formatter=simple
args=(sys.stdout,)
[handler_debug]
level=DEBUG
class=logging.handlers.WatchedFileHandler
formatter=simple
args=('/var/log/nodepool/launcher-debug.log',)
[handler_normal]
level=INFO
class=logging.handlers.WatchedFileHandler
formatter=simple
args=('/var/log/nodepool/nodepool-launcher.log',)
[formatter_simple]
format=%(asctime)s %(levelname)s %(name)s: %(message)s
datefmt=

View File

@ -7,6 +7,6 @@
PREFIX=/usr
# Options to pass to nodepoold.
ARGS="-l /etc/nodepool/logging.conf --no-builder --no-deletes"
ARGS="-l /etc/nodepool/logging.conf --no-builder --no-deletes --no-launches"
DIB_IMAGE_CACHE=/opt/nodepool/cache

View File

@ -0,0 +1,12 @@
# This file is generated by Ansible
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
#
# The prefix used when nodepool-launcher was installed. Be sure to update this
# value if you are using a virtualenv.
PREFIX=/usr
# Options to pass to nodepool-launcher.
ARGS="-l /etc/nodepool/launcher-logging.conf --no-builder --no-deletes --no-images --no-webapp"
DIB_IMAGE_CACHE=/opt/nodepool/cache

View File

@ -0,0 +1,13 @@
[Unit]
Description=Nodepool Launcher Service
After=syslog.target network.target
[Service]
Type=simple
User=nodepool
Group=nodepool
EnvironmentFile=-/etc/sysconfig/nodepool-launcher
ExecStart=/bin/sh -c "${PREFIX}/bin/nodepoold -d ${ARGS}"
[Install]
WantedBy=multi-user.target

View File

@ -73,6 +73,16 @@
src: "{{ nodepool_file_deleter_logging_conf_src }}"
register: nodepool_file_deleter_logging_conf
- name: Copy launcher logging configuration file.
become: yes
copy:
dest: "{{ nodepool_file_launcher_logging_conf_dest }}"
group: "{{ nodepool_file_launcher_logging_conf_group }}"
mode: "{{ nodepool_file_launcher_logging_conf_mode }}"
owner: "{{nodepool_file_launcher_logging_conf_owner }}"
src: "{{ nodepool_file_launcher_logging_conf_src }}"
register: nodepool_file_launcher_logging_conf
- name: Copy nodepool elements directory.
become: yes
copy:

View File

@ -102,6 +102,36 @@
nodepool_file_nodepool_deleter_service_config_src: "{{ __nodepool_file_nodepool_deleter_service_config_src }}"
when: nodepool_file_nodepool_deleter_service_config_src is not defined
- name: Define nodepool_file_nodepool_launcher_service_dest.
set_fact:
nodepool_file_nodepool_launcher_service_dest: "{{ __nodepool_file_nodepool_launcher_service_dest }}"
when: nodepool_file_nodepool_launcher_service_dest is not defined
- name: Define nodepool_file_nodepool_launcher_service_mode.
set_fact:
nodepool_file_nodepool_launcher_service_mode: "{{ __nodepool_file_nodepool_launcher_service_mode }}"
when: nodepool_file_nodepool_launcher_service_mode is not defined
- name: Define nodepool_file_nodepool_launcher_service_src.
set_fact:
nodepool_file_nodepool_launcher_service_src: "{{ __nodepool_file_nodepool_launcher_service_src }}"
when: nodepool_file_nodepool_launcher_service_src is not defined
- name: Define nodepool_file_nodepool_launcher_service_config_dest.
set_fact:
nodepool_file_nodepool_launcher_service_config_dest: "{{ __nodepool_file_nodepool_launcher_service_config_dest }}"
when: nodepool_file_nodepool_launcher_service_config_dest is not defined
- name: Define nodepool_file_nodepool_launcher_service_config_mode.
set_fact:
nodepool_file_nodepool_launcher_service_config_mode: "{{ __nodepool_file_nodepool_launcher_service_config_mode }}"
when: nodepool_file_nodepool_launcher_service_config_mode is not defined
- name: Define nodepool_file_nodepool_launcher_service_config_src.
set_fact:
nodepool_file_nodepool_launcher_service_config_src: "{{ __nodepool_file_nodepool_launcher_service_config_src }}"
when: nodepool_file_nodepool_launcher_service_config_src is not defined
- name: Copy nodepool services scripts into place.
become: yes
copy:
@ -132,7 +162,7 @@
src: "{{ nodepool_file_nodepool_builder_service_src }}"
register: nodepool_file_nodepool_builder_service
- name: Copy nodepool service config into place.
- name: Copy nodepool-builder service config into place.
become: yes
copy:
dest: "{{ nodepool_file_nodepool_builder_service_config_dest }}"
@ -152,7 +182,7 @@
src: "{{ nodepool_file_nodepool_deleter_service_src }}"
register: nodepool_file_nodepool_deleter_service
- name: Copy nodepool service config into place.
- name: Copy nodepool-deleter service config into place.
become: yes
copy:
dest: "{{ nodepool_file_nodepool_deleter_service_config_dest }}"
@ -162,6 +192,26 @@
src: "{{ nodepool_file_nodepool_deleter_service_config_src }}"
register: nodepool_file_nodepool_deleter_service_config
- name: Copy nodepool-launcher services scripts into place.
become: yes
copy:
dest: "{{ nodepool_file_nodepool_launcher_service_dest }}"
group: "{{ nodepool_file_nodepool_launcher_service_group }}"
mode: "{{ nodepool_file_nodepool_launcher_service_mode }}"
owner: "{{ nodepool_file_nodepool_launcher_service_owner }}"
src: "{{ nodepool_file_nodepool_launcher_service_src }}"
register: nodepool_file_nodepool_launcher_service
- name: Copy nodepool-launcher service config into place.
become: yes
copy:
dest: "{{ nodepool_file_nodepool_launcher_service_config_dest }}"
group: "{{ nodepool_file_nodepool_launcher_service_config_group }}"
mode: "{{ nodepool_file_nodepool_launcher_service_config_mode }}"
owner: "{{ nodepool_file_nodepool_launcher_service_config_owner }}"
src: "{{ nodepool_file_nodepool_launcher_service_config_src }}"
register: nodepool_file_nodepool_launcher_service_config
- name: Enable nodepool service.
become: yes
service:
@ -188,3 +238,12 @@
state: "{{ nodepool_service_nodepool_deleter_state }}"
register: nodepool_service_nodepool_deleter
when: nodepool_service_nodepool_deleter_manage
- name: Enable nodepool-launcher service.
become: yes
service:
enabled: "{{ nodepool_service_nodepool_launcher_enabled }}"
name: "{{ nodepool_service_nodepool_launcher_name }}"
state: "{{ nodepool_service_nodepool_launcher_state }}"
register: nodepool_service_nodepool_launcher
when: nodepool_service_nodepool_launcher_manage

View File

@ -35,6 +35,7 @@
- nodepool_file_logging_conf
- nodepool_file_builder_logging_conf
- nodepool_file_deleter_logging_conf
- nodepool_file_launcher_logging_conf
- nodepool_file_nodepool_elements
- nodepool_file_nodepool_scripts
- nodepool_file_nodepool_service
@ -43,9 +44,12 @@
- nodepool_file_nodepool_builder_service_config
- nodepool_file_nodepool_deleter_service
- nodepool_file_nodepool_deleter_service_config
- nodepool_file_nodepool_launcher_service
- nodepool_file_nodepool_launcher_service_config
- nodepool_service_nodepool
- nodepool_service_nodepool_builder
- nodepool_service_nodepool_deleter
- nodepool_service_nodepool_launcher
- name: Ensure nodepool_user_name is nodepool.
shell: /usr/bin/getent passwd nodepool
@ -121,6 +125,20 @@
- deleter_logging_conf_stat.stat.gr_name == 'nodepool'
- deleter_logging_conf_stat.stat.mode == '0644'
- name: Register /etc/nodepool/launcher-logging.conf
stat:
path: /etc/nodepool/launcher-logging.conf
register: launcher_logging_conf_stat
- name: Assert buidler_logging_conf_stat tests.
assert:
that:
- launcher_logging_conf_stat.stat.exists
- launcher_logging_conf_stat.stat.isreg
- launcher_logging_conf_stat.stat.pw_name == 'nodepool'
- launcher_logging_conf_stat.stat.gr_name == 'nodepool'
- launcher_logging_conf_stat.stat.mode == '0644'
- name: Register /etc/nodepool/secure.conf
stat:
path: /etc/nodepool/secure.conf
@ -391,3 +409,72 @@
become: yes
shell: /usr/sbin/service nodepool-deleter status
tags: skip_ansible_lint
- name: Register /etc/default/nodepool-launcher
stat:
path: /etc/default/nodepool
register: debian_nodepool_launcher_sysconfig_stat
when: ansible_os_family == 'Debian'
- name: Assert debian_nodepool_launcher_sysconfig_stat tests.
assert:
that:
- debian_nodepool_launcher_sysconfig_stat.stat.exists
- debian_nodepool_launcher_sysconfig_stat.stat.isreg
- debian_nodepool_launcher_sysconfig_stat.stat.pw_name == 'root'
- debian_nodepool_launcher_sysconfig_stat.stat.gr_name == 'root'
- debian_nodepool_launcher_sysconfig_stat.stat.mode == '0644'
when: ansible_os_family == 'Debian'
- name: Register /etc/sysconfig/nodepool-launcher
stat:
path: /etc/sysconfig/nodepool-launcher
register: redhat_nodepool_launcher_sysconfig_stat
when: ansible_os_family == 'RedHat'
- name: Assert redhat_nodepool_launcher_sysconfig_stat tests.
assert:
that:
- redhat_nodepool_launcher_sysconfig_stat.stat.exists
- redhat_nodepool_launcher_sysconfig_stat.stat.isreg
- redhat_nodepool_launcher_sysconfig_stat.stat.pw_name == 'root'
- redhat_nodepool_launcher_sysconfig_stat.stat.gr_name == 'root'
- redhat_nodepool_launcher_sysconfig_stat.stat.mode == '0644'
when: ansible_os_family == 'RedHat'
- name: Register /etc/init.d/nodepool-launcher
stat:
path: /etc/init.d/nodepool-launcher
register: debian_nodepool_launcher_service_stat
when: ansible_os_family == 'Debian'
- name: Assert debian_nodepool_launcher_service_stat tests.
assert:
that:
- debian_nodepool_launcher_service_stat.stat.exists
- debian_nodepool_launcher_service_stat.stat.isreg
- debian_nodepool_launcher_service_stat.stat.pw_name == 'root'
- debian_nodepool_launcher_service_stat.stat.gr_name == 'root'
- debian_nodepool_launcher_service_stat.stat.mode == '0755'
when: ansible_os_family == 'Debian'
- name: Register /etc/systemd/system/nodepool-launcher.service
stat:
path: /etc/systemd/system/nodepool-launcher.service
register: redhat_nodepool_launcher_service_stat
when: ansible_os_family == 'RedHat'
- name: Assert redhat_nodepool_launcher_service_stat tests.
assert:
that:
- redhat_nodepool_launcher_service_stat.stat.exists
- redhat_nodepool_launcher_service_stat.stat.isreg
- redhat_nodepool_launcher_service_stat.stat.pw_name == 'root'
- redhat_nodepool_launcher_service_stat.stat.gr_name == 'root'
- redhat_nodepool_launcher_service_stat.stat.mode == '0644'
when: ansible_os_family == 'RedHat'
- name: Ensure nodepool-launcher is running.
become: yes
shell: /usr/sbin/service nodepool-launcher status
tags: skip_ansible_lint

View File

@ -57,3 +57,11 @@ __nodepool_file_nodepool_deleter_service_src: etc/init.d/nodepool-deleter
__nodepool_file_nodepool_deleter_service_config_dest: /etc/default/nodepool-deleter
__nodepool_file_nodepool_deleter_service_config_mode: 0644
__nodepool_file_nodepool_deleter_service_config_src: etc/default/nodepool-deleter
__nodepool_file_nodepool_launcher_service_dest: /etc/init.d/nodepool-launcher
__nodepool_file_nodepool_launcher_service_mode: 0755
__nodepool_file_nodepool_launcher_service_src: etc/init.d/nodepool-launcher
__nodepool_file_nodepool_launcher_service_config_dest: /etc/default/nodepool-launcher
__nodepool_file_nodepool_launcher_service_config_mode: 0644
__nodepool_file_nodepool_launcher_service_config_src: etc/default/nodepool-launcher

View File

@ -46,3 +46,11 @@ __nodepool_file_nodepool_deleter_service_src: etc/systemd/system/nodepool-delete
__nodepool_file_nodepool_deleter_service_config_dest: /etc/sysconfig/nodepool-deleter
__nodepool_file_nodepool_deleter_service_config_mode: 0644
__nodepool_file_nodepool_deleter_service_config_src: etc/sysconfig/nodepool-deleter
__nodepool_file_nodepool_launcher_service_dest: /etc/systemd/system/nodepool-launcher.service
__nodepool_file_nodepool_launcher_service_mode: 0644
__nodepool_file_nodepool_launcher_service_src: etc/systemd/system/nodepool-launcher.service
__nodepool_file_nodepool_launcher_service_config_dest: /etc/sysconfig/nodepool-launcher
__nodepool_file_nodepool_launcher_service_config_mode: 0644
__nodepool_file_nodepool_launcher_service_config_src: etc/sysconfig/nodepool-launcher