Merge "Add support for zuul-web and scheduler connections"

This commit is contained in:
Jenkins 2017-07-18 16:21:56 +00:00 committed by Gerrit Code Review
commit 4ceab2ffe9
6 changed files with 266 additions and 0 deletions

49
files/web-logging.conf Normal file
View File

@ -0,0 +1,49 @@
[loggers]
keys=root,zuul,gerrit,gear
[handlers]
keys=console,debug,normal
[formatters]
keys=simple
[logger_root]
level=WARNING
handlers=console
[logger_zuul]
level=DEBUG
handlers=debug,normal
qualname=zuul
[logger_gerrit]
level=INFO
handlers=debug,normal
qualname=gerrit
[logger_gear]
level=WARNING
handlers=debug,normal
qualname=gear
[handler_console]
level=WARNING
class=StreamHandler
formatter=simple
args=(sys.stdout,)
[handler_debug]
level=DEBUG
class=logging.handlers.WatchedFileHandler
formatter=simple
args=('/var/log/zuul/web-debug.log',)
[handler_normal]
level=INFO
class=logging.handlers.WatchedFileHandler
formatter=simple
args=('/var/log/zuul/web.log',)
[formatter_simple]
format=%(asctime)s %(levelname)s %(name)s: %(message)s
datefmt=

127
files/zuul-web.init Normal file
View File

@ -0,0 +1,127 @@
#! /bin/sh
### BEGIN INIT INFO
# Provides: zuul-web
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Zuul
# Description: Zuul Executor
### END INIT INFO
# Do NOT "set -e"
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
DESC="Zuul Web"
NAME=zuul-web
DAEMON=/usr/local/bin/zuul-web
PIDFILE=/var/run/$NAME/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
USER=root
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# 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
# 3 if pid file already exist
mkdir -p /var/run/$NAME
chown $USER /var/run/$NAME
ulimit -n 8192
if [ -f $PIDFILE ]; then
return 3
fi
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 -- $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()
{
$DAEMON stop
return 0
}
#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
$DAEMON reconfigure
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 ;;
3) echo "Pidfile at $PIDFILE already exists, run service zuul-web stop to clean up."
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_stop
do_start
;;
*)
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac
:

View File

@ -78,6 +78,8 @@ class zuul (
$gearman_server_ssl_cert = undef,
$gearman_server_ssl_key = undef,
$gearman_ssl_ca = undef,
$zuul_web_url = 'http://127.0.0.1:9000',
$zuul_scheduler_url = 'http://127.0.0.1:8001',
) {
include ::httpd
include ::pip
@ -564,6 +566,9 @@ class zuul (
if ! defined(Httpd::Mod['cgid']) {
httpd::mod { 'cgid': ensure => present }
}
if !defined(Mod['proxy_wstunnel']) {
httpd::mod { 'proxy_wstunnel': ensure => present }
}
case $::lsbdistcodename {
'precise': {

72
manifests/web.pp Normal file
View File

@ -0,0 +1,72 @@
# Copyright 2017 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# == Class: zuul::web
#
class zuul::web (
$ensure = undef,
$manage_log_conf = true,
$web_listen_address = '127.0.0.1',
$web_listen_port = 9000,
) {
service { 'zuul-web':
ensure => $ensure,
name => 'zuul-web',
enable => true,
hasrestart => true,
require => [File['/etc/init.d/zuul-web'],
Class['zuul::systemd_reload']]
}
file { '/etc/init.d/zuul-web':
ensure => present,
owner => 'root',
group => 'root',
mode => '0555',
source => 'puppet:///modules/zuul/zuul-web.init',
notify => Class['zuul::systemd_reload'],
}
if $manage_log_conf {
file { '/etc/zuul/web-logging.conf':
ensure => present,
source => 'puppet:///modules/zuul/web-logging.conf',
}
}
include ::logrotate
::logrotate::file { 'web.log':
log => '/var/log/zuul/web.log',
options => [
'compress',
'missingok',
'rotate 30',
'daily',
'notifempty',
],
require => Service['zuul-web'],
}
::logrotate::file { 'web-debug.log':
log => '/var/log/zuul/web-debug.log',
options => [
'compress',
'missingok',
'rotate 30',
'daily',
'notifempty',
],
require => Service['zuul-web'],
}
}

View File

@ -100,6 +100,10 @@
<% end -%>
RewriteRule ^/status.json$ <%= @zuul_status_url %>/status.json [P]
RewriteRule ^/status/(.*) <%= @zuul_status_url %>/status/$1 [P]
RewriteRule ^/connection/(.*) <%= @zuul_scheduler_url %>/connection/$1 [P]
RewriteRule ^/console-stream <%= @zuul_web_url %>/console-stream [P]
RewriteRule ^/static/(.*) <%= @zuul_web_url %>/static/$1 [P]
RewriteRule ^/jobs/(.*) <%= @zuul_web_url %>/jobs/$1 [P]
AddOutputFilterByType DEFLATE application/json

View File

@ -56,6 +56,15 @@ trusted_rw_dirs=<%= @trusted_rw_dirs.join(':') %>
untrusted_ro_dirs=<%= @untrusted_ro_dirs.join(':') %>
untrusted_rw_dirs=<%= @untrusted_rw_dirs.join(':') %>
[web]
log_config=/etc/zuul/web-logging.conf
<% if @web_listen_address != "" -%>
listen_address=<%= @web_listen_address %>
<% end -%>
<% if @web_listen_port != "" -%>
listen_port=<%= @web_listen_port %>
<% end -%>
<% @connections.each do |connection| -%>
[connection "<%= connection['name'] %>"]
<% connection.each do |key,value| -%>