From 2a7e483dda5959ac9cfb0eacef7ec563ccc1c0af Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Mon, 25 Apr 2022 15:47:29 -0500 Subject: [PATCH] CASMINST-4471 adjust init script for podman load behavior podman load no longer allows the tagging of the image during a load op: https://github.com/containers/podman/issues/7387 to adjust the script for this, I filter the images to match metal-basecamp, get the image id, and then tag it in a separate command after the image has loaded Signed-off-by: Jacob Salmela prevent error ``` Apr 25 20:58:20 redbull-ncn-m001-pit systemd[1]: /usr/lib/systemd/system/basecamp.service:14: Unit configured to use KillMode=none. Support for KillMode=none is deprecated and will be eventually removed in future SLE versions. Please see SUSE TID https://www.suse.com/support/kb/doc/?id=000020394 for more details. ``` by setting the killmode to control-group Signed-off-by: Jacob Salmela --- .version | 2 +- init/basecamp-init.sh | 15 +++++++++------ init/basecamp.service | 6 ++++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.version b/.version index 9ee1f78..ccad953 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -1.1.11 +1.1.12 diff --git a/init/basecamp-init.sh b/init/basecamp-init.sh index 95c1423..3e192af 100755 --- a/init/basecamp-init.sh +++ b/init/basecamp-init.sh @@ -23,7 +23,6 @@ # OTHER DEALINGS IN THE SOFTWARE. # -set -x if [ $# -lt 2 ]; then echo >&2 "usage: basecamp-init PIDFILE CIDFILE [CONTAINER [VOLUME]]" exit 1 @@ -31,8 +30,7 @@ fi BASECAMP_PIDFILE="$1" BASECAMP_CIDFILE="$2" -BASECAMP_CONTAINER_NAME="${3-metal\-basecamp}" -BASECAMP_VOLUME_NAME="${4:-${BASECAMP_CONTAINER_NAME}-configs}" +BASECAMP_CONTAINER_NAME="${3-basecamp}" BASECAMP_IMAGE_PATH="@@basecamp-path@@" BASECAMP_IMAGE="@@basecamp-image@@" @@ -68,11 +66,16 @@ EOF mkdir -pv "$(echo ${BASECAMP_VOLUME_MOUNT_STATIC} | cut -f 1 -d :)" # Create basecamp container -if ! podman inspect "$BASECAMP_CONTAINER_NAME" ; then +if ! podman inspect "$BASECAMP_CONTAINER_NAME" &>dev/null; then rm -f "$BASECAMP_CIDFILE" || exit # Load basecamp image if it doesn't already exist - if ! podman image inspect "$BASECAMP_IMAGE" >dev/null; then - podman load "$BASECAMP_IMAGE_PATH" "$BASECAMP_IMAGE" || exit + if ! podman image inspect "$BASECAMP_IMAGE" &>dev/null; then + # load the image + podman load -i "$BASECAMP_IMAGE_PATH" || exit + # get the image id + BASECAMP_IMAGE_ID=$(podman images --noheading --format "{{.Id}}" --filter label="org.label-schema.name=$BASECAMP_CONTAINER_NAME") + # tag the image + podman tag "$BASECAMP_IMAGE_ID" "$BASECAMP_IMAGE" fi podman create \ --conmon-pidfile "$BASECAMP_PIDFILE" \ diff --git a/init/basecamp.service b/init/basecamp.service index 729a667..8fc7792 100644 --- a/init/basecamp.service +++ b/init/basecamp.service @@ -11,8 +11,10 @@ ExecStartPre=/usr/sbin/basecamp-init.sh %t/%n-pid %t/%n-cid basecamp ExecStart=/usr/bin/podman start basecamp ExecStop=/usr/bin/podman stop --ignore -t 10 basecamp PIDFile=%t/%n-pid -KillMode=none +# all remaining processes in the control group of this unit will be killed on unit stop +# https://www.suse.com/support/kb/doc/?id=000020394 +KillMode=control-group Type=forking [Install] -WantedBy=multi-user.target \ No newline at end of file +WantedBy=multi-user.target