Merge pull request #416 from kubespray/bug383

Fix init scripts for etcd. Fixes #383
This commit is contained in:
Smaine Kahlouch 2016-08-16 09:17:53 +02:00 committed by GitHub
commit 430a87d887
4 changed files with 18 additions and 10 deletions

2
Vagrantfile vendored
View file

@ -76,7 +76,7 @@ Vagrant.configure("2") do |config|
ip = "#{$subnet}.#{i+100}" ip = "#{$subnet}.#{i+100}"
host_vars[vm_name] = { host_vars[vm_name] = {
"ip" => ip, "ip" => ip,
"access_ip" => ip, #"access_ip" => ip,
"flannel_interface" => ip, "flannel_interface" => ip,
"flannel_backend_type" => "host-gw", "flannel_backend_type" => "host-gw",
"local_release_dir" => "/vagrant/temp", "local_release_dir" => "/vagrant/temp",

View file

@ -16,7 +16,8 @@ PATH=/sbin:/usr/sbin:/bin/:/usr/bin
DESC="etcd k/v store" DESC="etcd k/v store"
NAME=etcd NAME=etcd
DAEMON={{ docker_bin_dir | default("/usr/bin") }}/docker DAEMON={{ docker_bin_dir | default("/usr/bin") }}/docker
DAEMON_ARGS='--restart=always --env-file=/etc/etcd.env \ DAEMON_EXEC=`basename $DAEMON`
DAEMON_ARGS="run --restart=always --env-file=/etc/etcd.env \
--net=host \ --net=host \
-v /usr/share/ca-certificates/:/etc/ssl/certs:ro \ -v /usr/share/ca-certificates/:/etc/ssl/certs:ro \
-v /var/lib/etcd:/var/lib/etcd:rw \ -v /var/lib/etcd:/var/lib/etcd:rw \
@ -24,10 +25,10 @@ DAEMON_ARGS='--restart=always --env-file=/etc/etcd.env \
{{ etcd_image_repo }}:{{ etcd_image_tag }} \ {{ etcd_image_repo }}:{{ etcd_image_tag }} \
{% if etcd_after_v3 %} {% if etcd_after_v3 %}
{{ etcd_container_bin_dir }}etcd {{ etcd_container_bin_dir }}etcd
{% endif %}' {% endif %}"
SCRIPTNAME=/etc/init.d/$NAME SCRIPTNAME=/etc/init.d/$NAME
DAEMON_USER=etcd DAEMON_USER=root
STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/5/KILL/5}" STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/5/KILL/5}"
PID=/var/run/etcd.pid PID=/var/run/etcd.pid
@ -48,6 +49,8 @@ do_status()
# #
do_start() do_start()
{ {
{{ docker_bin_dir | default("/usr/bin") }}/docker rm -f {{ etcd_member_name | default("etcd-proxy") }} &>/dev/null || true
sleep 1
start-stop-daemon --background --start --quiet --make-pidfile --pidfile $PID --user $DAEMON_USER --exec $DAEMON -- \ start-stop-daemon --background --start --quiet --make-pidfile --pidfile $PID --user $DAEMON_USER --exec $DAEMON -- \
$DAEMON_ARGS \ $DAEMON_ARGS \
|| return 2 || return 2
@ -58,7 +61,7 @@ do_start()
# #
do_stop() do_stop()
{ {
start-stop-daemon --stop --quiet --retry=$STOP_SCHEDULE --pidfile $PID --name $NAME start-stop-daemon --stop --quiet --retry=$STOP_SCHEDULE --pidfile $PID --name $DAEMON_EXEC
RETVAL="$?" RETVAL="$?"
sleep 1 sleep 1

View file

@ -16,7 +16,8 @@ PATH=/sbin:/usr/sbin:/bin/:/usr/bin
DESC="etcd-proxy" DESC="etcd-proxy"
NAME=etcd-proxy NAME=etcd-proxy
DAEMON={{ docker_bin_dir | default("/usr/bin") }}/docker DAEMON={{ docker_bin_dir | default("/usr/bin") }}/docker
DAEMON_ARGS='--restart=always --env-file=/etc/etcd-proxy.env \ DAEMON_EXEC=`basename $DAEMON`
DAEMON_ARGS="run --restart=always --env-file=/etc/etcd-proxy.env \
--net=host \ --net=host \
--stop-signal=SIGKILL \ --stop-signal=SIGKILL \
-v /usr/share/ca-certificates/:/etc/ssl/certs:ro \ -v /usr/share/ca-certificates/:/etc/ssl/certs:ro \
@ -24,11 +25,11 @@ DAEMON_ARGS='--restart=always --env-file=/etc/etcd-proxy.env \
{{ etcd_image_repo }}:{{ etcd_image_tag }} \ {{ etcd_image_repo }}:{{ etcd_image_tag }} \
{% if etcd_after_v3 %} {% if etcd_after_v3 %}
{{ etcd_container_bin_dir }}etcd {{ etcd_container_bin_dir }}etcd
{% endif %}' {% endif %}"
SCRIPTNAME=/etc/init.d/$NAME SCRIPTNAME=/etc/init.d/$NAME
DAEMON_USER=etcd DAEMON_USER=root
STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/5/KILL/5}" STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/5/KILL/5}"
PID=/var/run/etcd-proxy.pid PID=/var/run/etcd-proxy.pid
@ -49,6 +50,8 @@ do_status()
# #
do_start() do_start()
{ {
{{ docker_bin_dir | default("/usr/bin") }}/docker rm -f {{ etcd_proxy_member_name | default("etcd-proxy") }} &>/dev/null || true
sleep 1
start-stop-daemon --background --start --quiet --make-pidfile --pidfile $PID --user $DAEMON_USER --exec $DAEMON -- \ start-stop-daemon --background --start --quiet --make-pidfile --pidfile $PID --user $DAEMON_USER --exec $DAEMON -- \
$DAEMON_ARGS \ $DAEMON_ARGS \
|| return 2 || return 2
@ -59,7 +62,7 @@ do_start()
# #
do_stop() do_stop()
{ {
start-stop-daemon --stop --quiet --retry=$STOP_SCHEDULE --pidfile $PID --name $NAME start-stop-daemon --stop --quiet --retry=$STOP_SCHEDULE --pidfile $PID --name $DAEMON_EXEC
RETVAL="$?" RETVAL="$?"
sleep 1 sleep 1

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# #
### BEGIN INIT INFO ### BEGIN INIT INFO
# Provides: kubelet # Provides: kubelet
# Required-Start: $local_fs $network $syslog # Required-Start: $local_fs $network $syslog
# Required-Stop: # Required-Stop:
# Default-Start: 2 3 4 5 # Default-Start: 2 3 4 5
@ -39,6 +39,8 @@ DAEMON_USER=root
# #
do_start() do_start()
{ {
/usr/bin/docker rm -f kubelet &>/dev/null || true
sleep 1
# Return # Return
# 0 if daemon has been started # 0 if daemon has been started
# 1 if daemon was already running # 1 if daemon was already running