From a179653ce204d90980f81aff66ef4fd5649568d5 Mon Sep 17 00:00:00 2001 From: ojayanth Date: Fri, 12 May 2023 05:08:41 -0500 Subject: [PATCH] etcd: add systemd unit support for clustering Refer https://etcd.io/docs/v3.5/op-guide/clustering/ for etcd clustering design background details. etcd-new.service triggers only, when the config file available in the specified path. This generic serive helps to start etcd cluster based on the project specific use cases and config files. etcd-new.service only required to run on initial setup or new node add into the existing cluster. All other use cases use regular etcd.service to start etcd with existing cluster configuration. Signed-off-by: ojayanth Signed-off-by: Khem Raj --- meta-oe/recipes-extended/etcd/etcd/etcd-new.path | 9 +++++++++ .../recipes-extended/etcd/etcd/etcd-new.service | 15 +++++++++++++++ meta-oe/recipes-extended/etcd/etcd_3.5.7.bb | 6 +++++- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 meta-oe/recipes-extended/etcd/etcd/etcd-new.path create mode 100644 meta-oe/recipes-extended/etcd/etcd/etcd-new.service diff --git a/meta-oe/recipes-extended/etcd/etcd/etcd-new.path b/meta-oe/recipes-extended/etcd/etcd/etcd-new.path new file mode 100644 index 00000000000..1a18a401601 --- /dev/null +++ b/meta-oe/recipes-extended/etcd/etcd/etcd-new.path @@ -0,0 +1,9 @@ +[Unit] +Description=Monitor the etcd config file changes + +[Path] +PathChanged=/run/etcd-new.conf +Unit=etcd-new.service + +[Install] +WantedBy=multi-user.target diff --git a/meta-oe/recipes-extended/etcd/etcd/etcd-new.service b/meta-oe/recipes-extended/etcd/etcd/etcd-new.service new file mode 100644 index 00000000000..479678dc670 --- /dev/null +++ b/meta-oe/recipes-extended/etcd/etcd/etcd-new.service @@ -0,0 +1,15 @@ +[Unit] +Description=etcd cluster member start/add service +Documentation=https://etcd.io/docs/v3.5/op-guide/clustering/ +ConditionPathExists=!/var/lib/etcd/member +ConditionPathExists=/run/etcd-new.conf +OnFailure=etcd.service + +[Service] +Type=notify +EnvironmentFile=/run/etcd-new.conf +ExecStart=/usr/bin/etcd +Restart=no + +[Install] +WantedBy=multi-user.target diff --git a/meta-oe/recipes-extended/etcd/etcd_3.5.7.bb b/meta-oe/recipes-extended/etcd/etcd_3.5.7.bb index c01b03e4aff..3e7bb0f68f5 100644 --- a/meta-oe/recipes-extended/etcd/etcd_3.5.7.bb +++ b/meta-oe/recipes-extended/etcd/etcd_3.5.7.bb @@ -10,6 +10,8 @@ SRC_URI = " \ file://0001-test_lib.sh-remove-gobin-requirement-during-build.patch;patchdir=src/${GO_IMPORT} \ file://etcd.service \ file://etcd-existing.conf \ + file://etcd-new.service \ + file://etcd-new.path \ " SRCREV = "215b53cf3b48ee761f4c40908b3874b2e5e95e9f" @@ -53,7 +55,7 @@ go_do_compile:prepend() { REQUIRED_DISTRO_FEATURES = "systemd" SYSTEMD_PACKAGES = "${PN}" -SYSTEMD_SERVICE:${PN}:append = " etcd.service" +SYSTEMD_SERVICE:${PN}:append = " etcd.service etcd-new.service etcd-new.path" do_install:append() { install -d ${D}${bindir}/ @@ -63,6 +65,8 @@ do_install:append() { install -m 0644 ${WORKDIR}/etcd-existing.conf -D -t ${D}${sysconfdir}/etcd.d install -d ${D}${systemd_system_unitdir} install -m 0644 ${WORKDIR}/etcd.service ${D}${systemd_system_unitdir}/ + install -m 0644 ${WORKDIR}/etcd-new.service ${D}${systemd_system_unitdir}/ + install -m 0644 ${WORKDIR}/etcd-new.path ${D}${systemd_system_unitdir}/ } FILES:${PN}:append = " ${sysconfdir}/etcd.d/etcd-existing.conf"