Cell Support

Yagi-workers are now created per cell. One rabbit per cell.
Also renamed the common role to stv3-common to prevent conflicts
with other playbooks.

Take note of ansible/roles/stv3-workers/defaults/main.yaml to
see an example of the expected format of the calling facts file.
Each entry in this list-of-dictionaries represents a rabbit server
and Swift container for that cell.

Also, multiple pipeline_workers are created based on the value
of num_pipeline_workers (defaults to 2). This is so a machine
can better utilize multi-core architectures.

Change-Id: I09c4d364878493546d6e23e019f01f5f4f38c37c
This commit is contained in:
Sandy Walsh 2014-12-19 11:05:28 -08:00
parent 51bfd3f12a
commit 618cdcdd63
16 changed files with 61 additions and 39 deletions

View File

@ -17,5 +17,5 @@
- ["vars/local_settings.yaml"]
roles:
- common
- stv3-common
- stv3-api

View File

@ -1,14 +1,29 @@
## Lowest level config defaults for the stv3-worker role
# used in yagi.conf
rabbit_host: localhost
rabbit_user: guest
rabbit_password: password
rabbit_port: 5672
rabbit_vhost: /
rabbit_exchange: nova
# shoebox credentials ...
swift_region: DFW
swift_username: my_username
rax_api_key: my_api_key
num_pipeline_workers: 2
# Each dictionary results in a separate yagi_{{cell}}.conf
cells:
- cell: cell-1
rabbit_host: localhost
rabbit_user: guest
rabbit_password: password
rabbit_port: 5672
rabbit_vhost: /
rabbit_exchange: nova
swift_region: DFW-cell-1
- cell: cell-2
rabbit_host: localhost
rabbit_user: guest
rabbit_password: password
rabbit_port: 5672
rabbit_vhost: /
rabbit_exchange: nova
swift_region: DFW-cell-2

View File

@ -1,7 +1,9 @@
# Only restart stv3-worker if we didn't already go from stopped
# to started by the stv3 worker process task
- name: restart yagi-event
service: name=yagi-event state=restarted
service: name=yagi-event-{{item.cell}} state=restarted
with_items: cells
- name: restart pipeline-worker
service: name=pipeline_worker state=restarted
service: name=pipeline_worker_{{item}} state=restarted
with_sequence: count={{num_pipeline_workers}}

View File

@ -4,8 +4,9 @@
---
- name: yagi.conf
template: src=yagi.conf.j2 dest=/etc/stv3/yagi.conf
template: src=yagi.conf.j2 dest=/etc/stv3/yagi-{{item.cell}}.conf
owner=stv3 group=stv3 mode=0644
with_items: cells
notify:
- restart yagi-event
@ -16,13 +17,15 @@
- restart yagi-event
- name: yagi-event-initd
copy: src=yagi-event.debian.init.d dest=/etc/init.d/yagi-event
template: src=yagi-event.debian.init.d.j2 dest=/etc/init.d/yagi-event-{{item.cell}}
owner=stv3 group=stv3 mode=0755
with_items: cells
- name: pipeline-worker-initd
copy: src=pipeline-worker.debian.init.d
dest=/etc/init.d/pipeline_worker
template: src=pipeline-worker.debian.init.d.j2
dest=/etc/init.d/pipeline_worker_{{item}}
owner=stv3 group=stv3 mode=0755
with_sequence: count={{num_pipeline_workers}}
- name: yagi-event
debug: msg="Starting yagi-event"

View File

@ -17,10 +17,11 @@
PATH=/opt/stv3/bin:/sbin:/usr/sbin:/bin:/usr/bin
DESC="Winchester pipeline worker control"
NAME=pipeline_worker
CORENAME=pipeline_worker_{{item}}
DAEMON=/opt/stv3/bin/$NAME
DAEMON_ARGS="--config /etc/stv3/winchester.yaml"
PIDFILE=/var/run/stv3/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
PIDFILE=/var/run/stv3/$CORENAME.pid
SCRIPTNAME=/etc/init.d/$CORENAME
USER=stv3
GROUP=stv3
@ -66,7 +67,7 @@ do_stop()
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$CORENAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
@ -74,7 +75,7 @@ case "$1" in
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$CORENAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
@ -82,10 +83,10 @@ case "$1" in
esac
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
status_of_proc "$DAEMON" "$CORENAME" && exit 0 || exit $?
;;
restart|force-reload)
log_daemon_msg "Restarting $DESC" "$NAME"
log_daemon_msg "Restarting $DESC" "$CORENAME"
do_stop
do_start
;;

View File

@ -17,10 +17,11 @@
PATH=/opt/stv3/bin:/sbin:/usr/sbin:/bin:/usr/bin
DESC="YAGI worker control"
NAME=yagi-event
CELLNAME=yagi-event-{{item.cell}}
DAEMON=/opt/stv3/bin/$NAME
DAEMON_ARGS="--config /etc/stv3/yagi.conf"
PIDFILE=/var/run/stv3/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
PIDFILE=/var/run/stv3/$CELLNAME.pid
SCRIPTNAME=/etc/init.d/$CELLNAME
USER=stv3
GROUP=stv3
@ -28,7 +29,7 @@ GROUP=stv3
[ -x "$DAEMON" ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
[ -r /etc/default/$CELLNAME ] && . /etc/default/$CELLNAME
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
@ -66,7 +67,7 @@ do_stop()
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$CELLNAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
@ -74,7 +75,7 @@ case "$1" in
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$CELLNAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
@ -82,10 +83,10 @@ case "$1" in
esac
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
status_of_proc "$DAEMON" "$CELLNAME" && exit 0 || exit $?
;;
restart|force-reload)
log_daemon_msg "Restarting $DESC" "$NAME"
log_daemon_msg "Restarting $DESC" "$CELLNAME"
do_stop
do_start
;;

View File

@ -4,21 +4,21 @@ debug = True
update_timer = 10
[event_worker]
pidfile = yagi_event_worker.pid
pidfile = yagi_{{item.cell}}_event_worker.pid
daemonize = False
event_driver = yagi.broker.rabbit.Broker
[rabbit_broker]
host = {{ rabbit_host }}
user = {{ rabbit_user }}
password = {{ rabbit_password }}
port = {{ rabbit_port }}
vhost = {{ rabbit_vhost }}
host = {{ item.rabbit_host }}
user = {{ item.rabbit_user }}
password = {{ item.rabbit_password }}
port = {{ item.rabbit_port }}
vhost = {{ item.rabbit_vhost }}
poll_delay = 1
exchange_name = "{{ rabbit_exchange }}"
exchange_name = "{{ item.rabbit_exchange }}"
[logging]
logfile = /var/log/stv3/yagi.log
logfile = /var/log/stv3/yagi-{{item.cell}}.log
default_level = {{ yagi_log_level }}
#config_file = /etc/stv3/logging.conf
@ -67,7 +67,7 @@ callback_list=shoebox.handlers:MoveFileCallback, shoebox.handlers:SwiftUploadCal
container=sandbox
credentials_file=swift_credentials.conf
auth_method=rackspace
region={{ swift_region }}
region={{ item.swift_region }}
# If you don't want Swift support, comment the above callback=
# entry and uncomment this one:

View File

@ -17,5 +17,5 @@
- ["vars/local_settings.yaml"]
roles:
- common
- stv3-common
- stv3-workers