From 8a8d5ce720c6648a07b7029ee9b4ef68f0ebc1a0 Mon Sep 17 00:00:00 2001 From: Claudiu Belu Date: Tue, 10 Sep 2024 11:39:56 +0000 Subject: [PATCH] Adds longhorn-manager command patch The original longhorn-manager image doesn't have an entrypoint, only a CMD. This means that when the image is launched, it will run the CMD directly. Basically, the CMD is the ENTRYPOINT (binary + arguments). That works fine with the current deployments. longhorn-manager will create the daemonset.apps/longhorn-csi-plugin, which will have a longhorn-manager container, which doesn't override the entrypoint, only the args (aka CMD). But in our rock scenario, Pebble is the entrypoint, which will get those arguments and pass them on onto the service defined above. This results in an invalid command being run, something like: longhorn-manager -d daemon longhorn-manager -d csi --nodeid=... This patch updates the mentioned container args to command, overriding the Pebble entrypoint, avoiding this problem. --- .../longhorn-csi-plugin-command.patch | 13 +++++++++++++ v1.7.0/longhorn-manager/rockcraft.yaml | 16 ++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 v1.7.0/longhorn-manager/longhorn-csi-plugin-command.patch diff --git a/v1.7.0/longhorn-manager/longhorn-csi-plugin-command.patch b/v1.7.0/longhorn-manager/longhorn-csi-plugin-command.patch new file mode 100644 index 0000000..e7bc6ca --- /dev/null +++ b/v1.7.0/longhorn-manager/longhorn-csi-plugin-command.patch @@ -0,0 +1,13 @@ +diff --git a/csi/deployment.go b/csi/deployment.go +index 68ed5c5f2..b0e523a4a 100644 +--- a/csi/deployment.go ++++ b/csi/deployment.go +@@ -375,7 +375,7 @@ func NewPluginDeployment(namespace, serviceAccount, nodeDriverRegistrarImage, li + }, + }, + }, +- Args: []string{ ++ Command: []string{ + "longhorn-manager", + "-d", + "csi", diff --git a/v1.7.0/longhorn-manager/rockcraft.yaml b/v1.7.0/longhorn-manager/rockcraft.yaml index 77d1ccf..417f9c4 100644 --- a/v1.7.0/longhorn-manager/rockcraft.yaml +++ b/v1.7.0/longhorn-manager/rockcraft.yaml @@ -61,6 +61,22 @@ parts: - CGO_ENABLED: 0 - VERSION: $CRAFT_PROJECT_VERSION override-build: | + # NOTE(claudiub): The original longhorn-manager image doesn't have an entrypoint, only a CMD. + # This means that when the image is launched, it will run the CMD directly. Basically, the + # CMD is the ENTRYPOINT (binary + arguments). That works fine with the current deployments. + # + # longhorn-manager will create the daemonset.apps/longhorn-csi-plugin, which will + # have a longhorn-manager container, which doesn't override the entrypoint, only the + # args (aka CMD). + # But in our rock scenario, Pebble is the entrypoint, which will get those arguments and pass them + # on onto the service defined above. This results in an invalid command being run, something like: + # longhorn-manager -d daemon longhorn-manager -d csi --nodeid=... + # + # This patch updates the mentioned container args to command, overriding the Pebble entrypoint, + # avoiding this problem. + cp $CRAFT_PROJECT_DIR/longhorn-csi-plugin-command.patch ./ + git apply -v longhorn-csi-plugin-command.patch + # https://github.com/longhorn/longhorn-manager/blob/v1.7.0/package/Dockerfile#L15 mkdir -p $CRAFT_PART_INSTALL/usr/local/sbin/ cp package/launch-manager package/nsmounter $CRAFT_PART_INSTALL/usr/local/sbin/