From 0c953101ff17e66fc9c5844a6a13c3d525c1628f Mon Sep 17 00:00:00 2001 From: Matthew Mosesohn Date: Mon, 15 Aug 2016 12:25:35 +0300 Subject: [PATCH] Fix init scripts for etcd. Fixes #383 Fixes Ubuntu 14.04 deployment of etcd. --- Vagrantfile | 2 +- roles/etcd/templates/deb-etcd-docker.initd.j2 | 11 +++++++---- roles/etcd/templates/deb-etcd-proxy-docker.initd.j2 | 11 +++++++---- roles/kubernetes/node/templates/deb-kubelet.initd.j2 | 4 +++- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index ac8b91827..e7efdda57 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -76,7 +76,7 @@ Vagrant.configure("2") do |config| ip = "#{$subnet}.#{i+100}" host_vars[vm_name] = { "ip" => ip, - "access_ip" => ip, + #"access_ip" => ip, "flannel_interface" => ip, "flannel_backend_type" => "host-gw", "local_release_dir" => "/vagrant/temp", diff --git a/roles/etcd/templates/deb-etcd-docker.initd.j2 b/roles/etcd/templates/deb-etcd-docker.initd.j2 index d2528b034..a83aae184 100644 --- a/roles/etcd/templates/deb-etcd-docker.initd.j2 +++ b/roles/etcd/templates/deb-etcd-docker.initd.j2 @@ -16,7 +16,8 @@ PATH=/sbin:/usr/sbin:/bin/:/usr/bin DESC="etcd k/v store" NAME=etcd 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 \ -v /usr/share/ca-certificates/:/etc/ssl/certs:ro \ -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 }} \ {% if etcd_after_v3 %} {{ etcd_container_bin_dir }}etcd -{% endif %}' +{% endif %}" SCRIPTNAME=/etc/init.d/$NAME -DAEMON_USER=etcd +DAEMON_USER=root STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/5/KILL/5}" PID=/var/run/etcd.pid @@ -48,6 +49,8 @@ do_status() # 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 -- \ $DAEMON_ARGS \ || return 2 @@ -58,7 +61,7 @@ do_start() # 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="$?" sleep 1 diff --git a/roles/etcd/templates/deb-etcd-proxy-docker.initd.j2 b/roles/etcd/templates/deb-etcd-proxy-docker.initd.j2 index 592361351..ad0338a09 100644 --- a/roles/etcd/templates/deb-etcd-proxy-docker.initd.j2 +++ b/roles/etcd/templates/deb-etcd-proxy-docker.initd.j2 @@ -16,7 +16,8 @@ PATH=/sbin:/usr/sbin:/bin/:/usr/bin DESC="etcd-proxy" NAME=etcd-proxy 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 \ --stop-signal=SIGKILL \ -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 }} \ {% if etcd_after_v3 %} {{ etcd_container_bin_dir }}etcd -{% endif %}' +{% endif %}" SCRIPTNAME=/etc/init.d/$NAME -DAEMON_USER=etcd +DAEMON_USER=root STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/5/KILL/5}" PID=/var/run/etcd-proxy.pid @@ -49,6 +50,8 @@ do_status() # 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 -- \ $DAEMON_ARGS \ || return 2 @@ -59,7 +62,7 @@ do_start() # 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="$?" sleep 1 diff --git a/roles/kubernetes/node/templates/deb-kubelet.initd.j2 b/roles/kubernetes/node/templates/deb-kubelet.initd.j2 index 65fd537f0..5d5184efe 100644 --- a/roles/kubernetes/node/templates/deb-kubelet.initd.j2 +++ b/roles/kubernetes/node/templates/deb-kubelet.initd.j2 @@ -1,7 +1,7 @@ #!/bin/bash # ### BEGIN INIT INFO -# Provides: kubelet +# Provides: kubelet # Required-Start: $local_fs $network $syslog # Required-Stop: # Default-Start: 2 3 4 5 @@ -39,6 +39,8 @@ DAEMON_USER=root # do_start() { + /usr/bin/docker rm -f kubelet &>/dev/null || true + sleep 1 # Return # 0 if daemon has been started # 1 if daemon was already running