As of corosync upstream commit ae859515, in systemd builds, StateDirectory is set in the systemd corosync.service file. The corosync state directory defaults to this value if not set in the corosync config file. Corosync falls back to using /var/lib/corosync only if the systemd StateDirectory is not set. The same commit removes /var/lib/corosync from RPM builds with systemd. As a result, if corosync was built with systemd, then starting corosync outside of systemd fails unless /var/lib/corosync has been created manually or through some other means. Starting corosync directly from the command line fails with the following error, because the STATE_DIRECTORY environment variable was not set by systemd: Cannot chdir to state directory /var/lib/corosync. No such file or directory This causes Pacemaker's cts-fencing script to fail. This seems like a bug in corosync, as it now assumes that corosync will always be started by systemd if available. Here, we work around it in cts by doing exactly that. Resolves RHEL-110075 Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
76 lines
2.9 KiB
Diff
76 lines
2.9 KiB
Diff
From b1fd6ccea9083826c1c2fb40418651704989a904 Mon Sep 17 00:00:00 2001
|
|
From: Reid Wahl <nrwahl@protonmail.com>
|
|
Date: Wed, 13 Aug 2025 17:33:16 -0700
|
|
Subject: [PATCH] Fix: cts: Start corosync using systemd if available
|
|
|
|
As of corosync upstream commit ae859515, in systemd builds,
|
|
StateDirectory is set in the systemd corosync.service file. The corosync
|
|
state directory defaults to this value if not set in the corosync config
|
|
file. Corosync falls back to using /var/lib/corosync only if the systemd
|
|
StateDirectory is not set.
|
|
|
|
The same commit removes /var/lib/corosync from RPM builds with systemd.
|
|
|
|
As a result, if corosync was built with systemd, then starting corosync
|
|
outside of systemd fails unless /var/lib/corosync has been created
|
|
manually or through some other means. Starting corosync directly from
|
|
the command line fails with the following error, because the
|
|
STATE_DIRECTORY environment variable was not set by systemd:
|
|
|
|
Cannot chdir to state directory /var/lib/corosync. No such file or
|
|
directory
|
|
|
|
This causes Pacemaker's cts-fencing script to fail.
|
|
|
|
This seems like a bug in corosync, as it now assumes that corosync will
|
|
always be started by systemd if available. Here, we work around it in
|
|
cts by doing exactly that.
|
|
|
|
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
|
|
---
|
|
python/pacemaker/_cts/corosync.py | 11 ++++++++++-
|
|
1 file changed, 10 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/python/pacemaker/_cts/corosync.py b/python/pacemaker/_cts/corosync.py
|
|
index 0a55dd7c96..beb574d2b8 100644
|
|
--- a/python/pacemaker/_cts/corosync.py
|
|
+++ b/python/pacemaker/_cts/corosync.py
|
|
@@ -11,6 +11,7 @@ import tempfile
|
|
import time
|
|
|
|
from pacemaker.buildoptions import BuildOptions
|
|
+from pacemaker._cts.environment import EnvFactory
|
|
from pacemaker._cts.process import killall, stdout_from_command
|
|
|
|
|
|
@@ -112,6 +113,9 @@ class Corosync:
|
|
self.logdir = logdir
|
|
self.cluster_name = cluster_name
|
|
|
|
+ # The Corosync class doesn't use self._env._nodes, but the
|
|
+ # "--nodes" argument is required to be present and nonempty
|
|
+ self._env = EnvFactory().getInstance(args=["--nodes", "localhost"])
|
|
self._existing_cfg_file = None
|
|
|
|
def _ready(self, logfile, timeout=10):
|
|
@@ -149,10 +153,15 @@ class Corosync:
|
|
self.cluster_name, localname())
|
|
logfile = corosync_log_file(BuildOptions.COROSYNC_CONFIG_FILE)
|
|
|
|
+ if self._env["have_systemd"]:
|
|
+ cmd = ["systemctl", "start", "corosync.service"]
|
|
+ else:
|
|
+ cmd = ["corosync"]
|
|
+
|
|
if self.verbose:
|
|
print("Starting corosync")
|
|
|
|
- with subprocess.Popen("corosync", stdout=subprocess.PIPE, stderr=subprocess.PIPE) as test:
|
|
+ with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as test:
|
|
test.wait()
|
|
|
|
# Wait for corosync to be ready before returning
|
|
--
|
|
2.50.1
|
|
|