Skip to content

Commit

Permalink
etcd: add systemd unit support for clustering
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Khem Raj <[email protected]>
  • Loading branch information
ojayanth authored and kraj committed May 12, 2023
1 parent 9400a94 commit a179653
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
9 changes: 9 additions & 0 deletions meta-oe/recipes-extended/etcd/etcd/etcd-new.path
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions meta-oe/recipes-extended/etcd/etcd/etcd-new.service
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion meta-oe/recipes-extended/etcd/etcd_3.5.7.bb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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}/
Expand All @@ -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"
Expand Down

0 comments on commit a179653

Please sign in to comment.