aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/patches/ganeti-shepherd-support.patch
blob: f7506043441d36276d4aa164a21a36153af0d67e (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Ganeti uses an internal tool to start/stop daemons during init and
upgrade.  This patch makes the tool use native Shepherd facilities.

diff --git a/daemons/daemon-util.in b/daemons/daemon-util.in
--- a/daemons/daemon-util.in
+++ b/daemons/daemon-util.in
@@ -184,6 +184,21 @@ use_systemctl() {
   return 1
 }
 
+# Checks if we should use the Shepherd to start/stop daemons
+use_shepherd() {
+  # Is Shepherd running as PID 1?
+  ps --no-headers -p 1 -o cmd | grep -q shepherd || return 1
+
+  type -p herd >/dev/null || return 1
+
+  # Does Shepherd know about Ganeti at all?
+  if herd status | grep -q ganeti; then
+    return 0
+  fi
+
+  return 1
+}
+
 # Prints path to PID file for a daemon.
 daemon_pidfile() {
   if [[ "$#" -lt 1 ]]; then
@@ -261,6 +276,13 @@ check() {
     else
       return 1
     fi
+  elif use_shepherd; then
+    activestate="$(herd status ${name})"
+    if echo $activestate | grep -q Running ; then
+      return 0
+    else
+      return 1
+    fi
   elif type -p start-stop-daemon >/dev/null; then
     start-stop-daemon --stop --signal 0 --quiet \
       --pidfile $pidfile --name "$name"
@@ -291,6 +313,20 @@ start() {
     return $?
   fi
 
+  if use_shepherd; then
+    if herd status "$name" | grep -q "disabled"; then
+      # The Shepherd will disable a service that has stopped, even if it exits
+      # gracefully.  Thus, we must re-enable it in case of a master failover.
+      herd enable "${name}"
+    fi
+    # Note: unlike systemd, which happily starts a service and returns success
+    # even if the daemon immediately exits, the Shepherd actually waits for it
+    # to come up.  Thus, ignore the exit status from 'herd start' in case of
+    # master daemons running on the wrong node, or ganeti-kvmd disabled, etc.
+    herd start "${name}"
+    return 0
+  fi
+
   # Read $<daemon>_ARGS and $EXTRA_<daemon>_ARGS
   eval local args="\"\$${ucname}_ARGS \$EXTRA_${ucname}_ARGS\""
 
@@ -336,6 +372,13 @@ stop() {
 
   if use_systemctl; then
     systemctl stop "${name}.service"
+  elif use_shepherd; then
+    if herd status | grep -q "$name"; then
+      herd stop "$name"
+    else
+      # Do not raise an error if the service has not been enabled.
+      return 0
+    fi
   elif type -p start-stop-daemon >/dev/null; then
     start-stop-daemon --stop --quiet --oknodo --retry 30 \
       --pidfile $pidfile --name "$name"
@@ -352,6 +395,9 @@ check_and_start() {
     if use_systemctl; then
       echo "${name} supervised by systemd but not running, will not restart."
       return 1
+    elif use_shepherd; then
+      echo "${name} supervised by shepherd but not running, will not restart."
+      return 1
     fi
 
     start $name
530'>2019-02-02gnu: Add emacs-mkmcc-gnuplot-mode....* gnu/packages/emacs-xyz.scm (emacs-mkmcc-gnuplot-mode): New variable. Arun Isaac 2019-02-01gnu: emacs-slime: Update to 2.23....* gnu/packages/emacs-xyz.scm (emacs-slime): Update to 2.23. Pierre Neidhardt 2019-01-26gnu: emacs-ivy: Update to 0.11.0....* gnu/packages/emacs-xyz.scm (emacs-ivy): Update to 0.11.0. Ricardo Wurmus 2019-01-24gnu: emacspeak: Update to 49.0....* gnu/packages/emacs.scm (emacspeak): Update to 49.0. [arguments]: In the 'install' phase, fix the launch script substitution. Kei Kebreau 2019-01-23gnu: emacs-elpy: Update to 1.28.0....* gnu/packages/emacs-xyz.scm (emacs-elpy): Update to 1.28.0. Maxim Cournoyer 2019-01-23gnu: Add emacs-magit-gerrit....* gnu/packages/emacs-xyz.scm (emacs-magit-gerrit): New variable. Maxim Cournoyer 2019-01-23gnu: Add emacs-simple-mpc....* gnu/packages/emacs-xyz.scm (emacs-simple-mpc): New variable. Ricardo Wurmus 2019-01-23gnu: emacs-emms-mode-line-cycle: Don't use unstable tarball....* gnu/packages/emacs-xyz.scm (emacs-emms-mode-line-cycle)[source]: Use 'git-fetch'. Efraim Flashner 2019-01-23gnu: emacs-ghub: Update to 3.2.0....* gnu/packages/emacs-xyz.scm (emacs-ghub): Update to 3.2.0. [propagated-inputs]: Add emacs-dash, emacs-graphql, emacs-treepy. [synopsis, description]: Update. (emacs-magit, emacs-magit-svn)[propagated-inputs]: Add emacs-graphql, emacs-treepy. [arguments]: Update accordingly. Efraim Flashner 2019-01-23gnu: emacs-magit: Update to 2.13.1....* gnu/packages/emacs-xyz.scm (emacs-magit): Update to 2.13.1. [source]: Use 'git-fetch'. Efraim Flashner 2019-01-23gnu: emacs-haskell-mode: Don't use unstable tarball....* gnu/packages/emacs-xyz.scm (emacs-haskell-mode)[source]: Use 'git-fetch'. Efraim Flashner 2019-01-23gnu: emacs-ghub: Don't use unstable-tarball....* gnu/packages/emacs-xyz.scm (emacs-ghub)[source]: Use 'git-fetch'. Efraim Flashner 2019-01-23gnu: emacs-magit-svn: Update to 2.2.1....* gnu/packages/emacs-xyz.scm (emacs-magit-svn): Update to 2.2.1. Efraim Flashner 2019-01-23gnu: emacs-magit-svn: Add missing inputs....* gnu/packages/emacs-xyz.scm (emacs-magit-svn)[propagated-inputs]: Add emacs-ghub, emacs-magit-popup. [arguments]: Adjust accordingly. Efraim Flashner 2019-01-23gnu: eamcs-magit-svm: Don't use unstable tarball....* gnu/packages/emacs-xyz.scm (emacs-magit-svn)[source]: Use 'git-fetch'. [native-inputs]: Remove tar, gzip. [arguments]: Adjust code accordingly. Efraim Flashner 2019-01-23gnu: emacs-git-modes: Don't use unstable tarball....* gnu/packages/emacs-xyz.scm (emacs-git-mode)[source]: Use 'git-fetch'. Efraim Flashner 2019-01-22gnu: emacs-ert-runner: Update to latest upstream commit....The latest tag is many years old, and the latest upstream branch includes important fixes such as displaying correctly the backtrace upon encountering errors (see: https://github.com/rejeep/ert-runner.el/commit/4b6e6cb81fb3cb9db60046f70256555a9ae97459). * gnu/packages/emacs-xyz.scm (emacs-ert-runner): Update to the latest upstream commit. [origin]: Use GIT-FETCH instead of URL-FETCH to mitigate against GitHub's dynamically generated tarballs. Maxim Cournoyer 2019-01-21gnu: emacs-nix-mode: Move to emacs-xyz.scm....This removes emacs-xyz.scm from the closure of (gnu packages base). * gnu/packages/package-management.scm (emacs-nix-mode): Move back to... * gnu/packages/emacs-xyz.scm (emacs-nix-mode): ... here. New variable. Ludovic Courtès 2019-01-19gnu: emacs-matrix-client: Update to a0623667....* gnu/packages/emacs-xyz.scm (emacs-matrix-client): Update to a0623667. Nicolas Goaziou 2019-01-18gnu: emacs-matrix-client: Bump revision....* gnu/packages/emacs-xyz.scm (emacs-matrix-client): Bump revision to trigger the update, since updating commit is not enough. Nicolas Goaziou 2019-01-17gnu: emacs-matrix-client: Update to 2a95a1f....* gnu/packages/emacs-xyz.scm (emacs-matrix-client): Update to 2a95a1f. [propagated-inputs]: Add `emacs-anaphora'. Nicolas Goaziou 2019-01-17gnu: Add emacs-anaphora....* gnu/packages/emacs-xyz.scm (emacs-anaphora): New variable. Nicolas Goaziou 2019-01-17gnu: Add emacs-edbi-sqlite....* gnu/packages/emacs-xyz.scm (emacs-edbi-sqlite): New variable. Pierre Neidhardt 2019-01-17gnu: Add emacs-edbi....* gnu/packages/emacs-xyz.scm (emacs-edbi): New variable. Pierre Neidhardt 2019-01-17gnu: Add emacs-epc....* gnu/packages/emacs-xyz.scm (emacs-epc): New variable. Pierre Neidhardt 2019-01-17gnu: Add emacs-ctable....* gnu/packages/emacs-xyz.scm (emacs-ctable): New variable. Pierre Neidhardt 2019-01-17gnu: Add emacs-e2wm....* gnu/packages/emacs-xyz.scm (emacs-e2wm): New variable. Pierre Neidhardt 2019-01-17gnu: Add emacs-window-layout....* gnu/packages/emacs-xyz.scm (emacs-window-layout): New variable. Pierre Neidhardt 2019-01-16gnu: Move Emacs packages to new module....* gnu/packages/emacs.scm: Move almost all packages from here... * gnu/packages/emacs-xyz.scm: ...to this new module. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. * gnu/packages/ocaml.scm, gnu/packages/package-management.scm, gnu/packages/statistics.scm: Update module references. Ricardo Wurmus