Skip to content

Commit

Permalink
instance-manager: ensure 'ldconfig' run on pebble service startup (#14)
Browse files Browse the repository at this point in the history
Signed-off-by: Nashwan Azhari <[email protected]>
  • Loading branch information
aznashwan authored Sep 10, 2024
1 parent a8f0bb3 commit 60c0bd8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
5 changes: 4 additions & 1 deletion tests/sanity/test_longhorn_instance_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ def test_check_rock_image_contents(image_version):
binary_paths_to_check,
)

process = docker_util.run_in_docker(rock_image, ["nvme", "version"])
# NOTE(aznashwan): we must run `ldconfig` on container startup
# to re-index some libs `nvme` dynamically links to:
cmd = "ldconfig && nvme version"
process = docker_util.run_in_docker(rock_image, ["bash", "-c", cmd])
assert "nvme version 2.9.1" in process.stdout
assert "libnvme version 1.9" in process.stdout
22 changes: 22 additions & 0 deletions v1.7.0/longhorn-instance-manager/pebble-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

# Required to prevent Pebble from considering the service to have
# exited too quickly to be worth restarting or respecting the
# "on-failure: shutdown" directive and thus hanging indefinitely:
# https://github.com/canonical/pebble/issues/240#issuecomment-1599722443
sleep 1.1

# NOTE(aznashwan): the longhorn-instance-manager image includes a number of
# dynamically-linked binaries which the instance-manager exec's.
# These binaries require some external libraries which must be indexed:
ldconfig

TINI_ARGS="$@"
if [ $# -eq 0 ]; then
# https://github.com/longhorn/longhorn-instance-manager/blob/v1.7.0/package/Dockerfile#L177
# https://github.com/longhorn/longhorn-instance-manager/pull/664
TINI_ARGS="longhorn-instance-manager"
fi

# https://github.com/longhorn/longhorn-instance-manager/blob/v1.7.0/package/Dockerfile#L175
exec tini -- $TINI_ARGS
14 changes: 10 additions & 4 deletions v1.7.0/longhorn-instance-manager/rockcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ services:
startup: enabled
override: replace

# https://github.com/longhorn/longhorn-instance-manager/blob/v1.7.0/package/Dockerfile#L175-L177
# https://github.com/longhorn/longhorn-instance-manager/pull/664
command: /tini -- [ longhorn-instance-manager ]
# NOTE(aznashwan): the entrypoint script we add to the rock simply runs
# `ldconfig` before `exec`-ing the `tini` init service with the args:
command: bash /pebble-entrypoint.sh [ longhorn-instance-manager ]

on-success: shutdown
on-failure: shutdown

entrypoint-service: longhorn-instance-manager

parts:
# NOTE(aznashwan): the longhorn binary is built within a Docker container
# which is set up by Rancher's Dapper tool: https://github.com/rancher/dapper
Expand Down Expand Up @@ -356,5 +358,9 @@ parts:
set -eux -o pipefail
mkdir -p $CRAFT_PART_INSTALL/etc/ld.so.conf.d
echo /usr/local/lib > $CRAFT_PART_INSTALL/etc/ld.so.conf.d/99_local_libs.conf
echo /usr/local/lib > $CRAFT_PART_INSTALL/etc/ld.so.conf.d/99_usr_local_lib.conf
cp $CRAFT_PROJECT_DIR/pebble-entrypoint.sh $CRAFT_PART_INSTALL/pebble-entrypoint.sh
chmod +x $CRAFT_PART_INSTALL/pebble-entrypoint.sh

0 comments on commit 60c0bd8

Please sign in to comment.