* [meta-virtualization][PATCH] k3s: fix systemd service install
@ 2021-12-29 12:05 Adrian Freihofer
2021-12-29 16:44 ` Bruce Ashfield
0 siblings, 1 reply; 2+ messages in thread
From: Adrian Freihofer @ 2021-12-29 12:05 UTC (permalink / raw)
To: meta-virtualization; +Cc: Adrian Freihofer
- sed was complicated and fragile
- sed runs on k3s-agent.service before it was installed
- not all paths were replaced
- "if systemd in DISTRO_FEATURES" is already handled in systemd.bbclass
Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
---
recipes-containers/k3s/k3s/k3s-agent.service | 4 ++--
recipes-containers/k3s/k3s/k3s.service | 4 ++--
recipes-containers/k3s/k3s_git.bb | 12 ++++++------
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/recipes-containers/k3s/k3s/k3s-agent.service b/recipes-containers/k3s/k3s/k3s-agent.service
index 9f9016d..eeeef2a 100644
--- a/recipes-containers/k3s/k3s/k3s-agent.service
+++ b/recipes-containers/k3s/k3s/k3s-agent.service
@@ -21,6 +21,6 @@ Restart=always
RestartSec=5s
ExecStartPre=-/sbin/modprobe br_netfilter
ExecStartPre=-/sbin/modprobe overlay
-ExecStart=/usr/local/bin/k3s agent
-ExecStopPost=/usr/local/bin/k3s-clean
+ExecStart=@@BIN_PREFIX@@/bin/k3s agent
+ExecStopPost=@@BIN_PREFIX@@/bin/k3s-clean
diff --git a/recipes-containers/k3s/k3s/k3s.service b/recipes-containers/k3s/k3s/k3s.service
index 33d3ee7..b82d8ce 100644
--- a/recipes-containers/k3s/k3s/k3s.service
+++ b/recipes-containers/k3s/k3s/k3s.service
@@ -29,9 +29,9 @@ RestartSec=5s
ExecStartPre=/bin/sh -xc '! systemctl is-enabled --quiet nm-cloud-setup.service'
ExecStartPre=-/sbin/modprobe br_netfilter
ExecStartPre=-/sbin/modprobe overlay
-ExecStart=/usr/local/bin/k3s server
+ExecStart=@@BIN_PREFIX@@/bin/k3s server
# Avoid any delay due to this service when the system is rebooting or shutting
# down by using the k3s-killall.sh script to kill all of the running k3s
# services and containers
ExecStopPost=/bin/sh -c "if systemctl is-system-running | grep -i \
- 'stopping'; then /usr/local/bin/k3s-killall.sh; fi"
+ 'stopping'; then @@BIN_PREFIX@@/bin/k3s-killall.sh; fi"
diff --git a/recipes-containers/k3s/k3s_git.bb b/recipes-containers/k3s/k3s_git.bb
index c9779ea..d38044c 100644
--- a/recipes-containers/k3s/k3s_git.bb
+++ b/recipes-containers/k3s/k3s_git.bb
@@ -63,12 +63,12 @@ do_install() {
install -m 755 "${WORKDIR}/k3s-clean" "${D}${BIN_PREFIX}/bin"
install -m 755 "${WORKDIR}/k3s-killall.sh" "${D}${BIN_PREFIX}/bin"
- if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
- install -D -m 0644 "${WORKDIR}/k3s.service" "${D}${systemd_system_unitdir}/k3s.service"
- install -D -m 0644 "${WORKDIR}/k3s-agent.service" "${D}${systemd_system_unitdir}/k3s-agent.service"
- sed -i "s#\(Exec\)\(.*\)=\(.*\)\(k3s\)#\1\2=${BIN_PREFIX}/bin/\4#g" "${D}${systemd_system_unitdir}/k3s.service" "${D}${systemd_system_unitdir}/k3s-agent.service"
- install -m 755 "${WORKDIR}/k3s-agent" "${D}${BIN_PREFIX}/bin"
- fi
+ install -D -m 0644 "${WORKDIR}/k3s.service" "${D}${systemd_system_unitdir}/k3s.service"
+ install -D -m 0644 "${WORKDIR}/k3s-agent.service" "${D}${systemd_system_unitdir}/k3s-agent.service"
+ install -m 755 "${WORKDIR}/k3s-agent" "${D}${BIN_PREFIX}/bin"
+ sed -i -e "s#@@BIN_PREFIX@@#${BIN_PREFIX}#g" \
+ "${D}${systemd_system_unitdir}/k3s.service" \
+ "${D}${systemd_system_unitdir}/k3s-agent.service"
}
PACKAGES =+ "${PN}-server ${PN}-agent"
--
2.31.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [meta-virtualization][PATCH] k3s: fix systemd service install
2021-12-29 12:05 [meta-virtualization][PATCH] k3s: fix systemd service install Adrian Freihofer
@ 2021-12-29 16:44 ` Bruce Ashfield
0 siblings, 0 replies; 2+ messages in thread
From: Bruce Ashfield @ 2021-12-29 16:44 UTC (permalink / raw)
To: Adrian Freihofer; +Cc: meta-virtualization, Adrian Freihofer
On Wed, Dec 29, 2021 at 7:05 AM Adrian Freihofer
<adrian.freihofer@gmail.com> wrote:
>
> - sed was complicated and fragile
> - sed runs on k3s-agent.service before it was installed
Was that actually causing breakage ? As long as WORKDIR is used, it
typically doesn't break anything.
> - not all paths were replaced
Which ones in particular ? We should document
> - "if systemd in DISTRO_FEATURES" is already handled in systemd.bbclass
It still needs to be protected by the check. We shouldn't be
installing them at all if it isn't enabled. The bbclass doesn't help
with that.
Bruce
>
> Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
> ---
> recipes-containers/k3s/k3s/k3s-agent.service | 4 ++--
> recipes-containers/k3s/k3s/k3s.service | 4 ++--
> recipes-containers/k3s/k3s_git.bb | 12 ++++++------
> 3 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/recipes-containers/k3s/k3s/k3s-agent.service b/recipes-containers/k3s/k3s/k3s-agent.service
> index 9f9016d..eeeef2a 100644
> --- a/recipes-containers/k3s/k3s/k3s-agent.service
> +++ b/recipes-containers/k3s/k3s/k3s-agent.service
> @@ -21,6 +21,6 @@ Restart=always
> RestartSec=5s
> ExecStartPre=-/sbin/modprobe br_netfilter
> ExecStartPre=-/sbin/modprobe overlay
> -ExecStart=/usr/local/bin/k3s agent
> -ExecStopPost=/usr/local/bin/k3s-clean
> +ExecStart=@@BIN_PREFIX@@/bin/k3s agent
> +ExecStopPost=@@BIN_PREFIX@@/bin/k3s-clean
>
> diff --git a/recipes-containers/k3s/k3s/k3s.service b/recipes-containers/k3s/k3s/k3s.service
> index 33d3ee7..b82d8ce 100644
> --- a/recipes-containers/k3s/k3s/k3s.service
> +++ b/recipes-containers/k3s/k3s/k3s.service
> @@ -29,9 +29,9 @@ RestartSec=5s
> ExecStartPre=/bin/sh -xc '! systemctl is-enabled --quiet nm-cloud-setup.service'
> ExecStartPre=-/sbin/modprobe br_netfilter
> ExecStartPre=-/sbin/modprobe overlay
> -ExecStart=/usr/local/bin/k3s server
> +ExecStart=@@BIN_PREFIX@@/bin/k3s server
> # Avoid any delay due to this service when the system is rebooting or shutting
> # down by using the k3s-killall.sh script to kill all of the running k3s
> # services and containers
> ExecStopPost=/bin/sh -c "if systemctl is-system-running | grep -i \
> - 'stopping'; then /usr/local/bin/k3s-killall.sh; fi"
> + 'stopping'; then @@BIN_PREFIX@@/bin/k3s-killall.sh; fi"
> diff --git a/recipes-containers/k3s/k3s_git.bb b/recipes-containers/k3s/k3s_git.bb
> index c9779ea..d38044c 100644
> --- a/recipes-containers/k3s/k3s_git.bb
> +++ b/recipes-containers/k3s/k3s_git.bb
> @@ -63,12 +63,12 @@ do_install() {
> install -m 755 "${WORKDIR}/k3s-clean" "${D}${BIN_PREFIX}/bin"
> install -m 755 "${WORKDIR}/k3s-killall.sh" "${D}${BIN_PREFIX}/bin"
>
> - if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
> - install -D -m 0644 "${WORKDIR}/k3s.service" "${D}${systemd_system_unitdir}/k3s.service"
> - install -D -m 0644 "${WORKDIR}/k3s-agent.service" "${D}${systemd_system_unitdir}/k3s-agent.service"
> - sed -i "s#\(Exec\)\(.*\)=\(.*\)\(k3s\)#\1\2=${BIN_PREFIX}/bin/\4#g" "${D}${systemd_system_unitdir}/k3s.service" "${D}${systemd_system_unitdir}/k3s-agent.service"
> - install -m 755 "${WORKDIR}/k3s-agent" "${D}${BIN_PREFIX}/bin"
> - fi
> + install -D -m 0644 "${WORKDIR}/k3s.service" "${D}${systemd_system_unitdir}/k3s.service"
> + install -D -m 0644 "${WORKDIR}/k3s-agent.service" "${D}${systemd_system_unitdir}/k3s-agent.service"
> + install -m 755 "${WORKDIR}/k3s-agent" "${D}${BIN_PREFIX}/bin"
> + sed -i -e "s#@@BIN_PREFIX@@#${BIN_PREFIX}#g" \
> + "${D}${systemd_system_unitdir}/k3s.service" \
> + "${D}${systemd_system_unitdir}/k3s-agent.service"
> }
>
> PACKAGES =+ "${PN}-server ${PN}-agent"
> --
> 2.31.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#6988): https://lists.yoctoproject.org/g/meta-virtualization/message/6988
> Mute This Topic: https://lists.yoctoproject.org/mt/88013223/1050810
> Group Owner: meta-virtualization+owner@lists.yoctoproject.org
> Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [bruce.ashfield@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
--
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-12-29 16:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-29 12:05 [meta-virtualization][PATCH] k3s: fix systemd service install Adrian Freihofer
2021-12-29 16:44 ` Bruce Ashfield
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).