Skip to content

lvmd: support lvm-command-prefix option in lvmd.conf #1045

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 14, 2025

Conversation

ushitora-anqou
Copy link
Contributor

@ushitora-anqou ushitora-anqou commented May 16, 2025

Fix #1042.

In DaemonSet mode, LVMd currently executes every LVM command through
/usr/bin/nsenter with hard-coded arguments. This prevents users from:

  • Changing the path to nsenter or its options
  • Wrapping the command in a logging program or other tool
  • Running LVM commands without nsenter (though this is risky)

This commint introduces the lvm-command-prefix option in lvmd.conf to
provide that flexibility. The value is a list of strings that will be
prepended to every command invocation. For example, if it is set to X,
LV creation will be invoked as X /sbin/lvm lvcreate ....

The default value of this option is equivalent to /usr/bin/nsenter -m -u -i -n -p -t 1, so the current behaviour will not break by
default.

@ushitora-anqou ushitora-anqou changed the title add option to use LVM commands in containers [WIP] add option to use LVM commands in containers May 16, 2025
@molpako molpako moved this from To do to In progress in Development May 16, 2025
@ushitora-anqou ushitora-anqou force-pushed the avoid-nsenter-option branch 2 times, most recently from daac12f to ed7d6e9 Compare May 22, 2025 00:50
@ushitora-anqou ushitora-anqou force-pushed the avoid-nsenter-option branch 3 times, most recently from 87b25c3 to e1efbb3 Compare June 4, 2025 02:32
@ushitora-anqou ushitora-anqou force-pushed the avoid-nsenter-option branch 20 times, most recently from 446f42b to a728203 Compare July 4, 2025 00:20
@ushitora-anqou ushitora-anqou changed the title [WIP] add option to use LVM commands in containers add option to execute LVM commands inside a container Jul 4, 2025
@ushitora-anqou ushitora-anqou force-pushed the avoid-nsenter-option branch 5 times, most recently from a7b8f04 to 52e432b Compare July 10, 2025 00:40
@ushitora-anqou ushitora-anqou changed the title add option to execute LVM commands inside a container lvmd: support lvm-command-prefix option in lvmd.conf Jul 10, 2025
@ushitora-anqou ushitora-anqou requested a review from toshipp July 10, 2025 09:21
Copy link
Contributor

@llamerada-jp llamerada-jp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the change from what I said before.
I think it would be better to deprecate lvm-path in lvmd command option and create a new option to specify the whole prefix + lvm-path in lvmd.conf.

@ushitora-anqou
Copy link
Contributor Author

Sorry for the change from what I said before. I think it would be better to deprecate lvm-path in lvmd command option and create a new option to specify the whole prefix + lvm-path in lvmd.conf.

Implemented in the following commits:

lvm-command-prefix now includes /sbin/lvm at the end of the slice by default, so I forbid users to use --lvm-path and lvm-command-prefix at the same time.

In DaemonSet mode, LVMd currently executes every LVM command through
/usr/bin/nsenter with hard-coded arguments. This prevents users from:

- Changing the path to nsenter or its options
- Wrapping the command in a logging program or other tool
- Running LVM commands without nsenter (though this is risky)

This commint introduces the lvm-command-prefix option in lvmd.conf to
provide that flexibility. The value is a list of strings that will be
prepended to every command invocation. For example, if it is set to X,
LV creation will be invoked as `X /sbin/lvm lvcreate ...`.

The default value of this option is equivalent to `/usr/bin/nsenter -m
-u -i -n -p -t 1`, so the current behaviour will not break by default.

Signed-off-by: Ryotaro Banno <ryotaro.banno@gmail.com>
This commit adds the `lvmd.additionalLVMDYamlContent` key to values.yaml,
enabling users to append extra settings to the generated lvmd.yaml file.

Please note that this option is different from `lvmd.additionalConfigs`,
which creates a separate lvmd.yaml ConfigMap instead of modifying the
existing one.

Signed-off-by: Ryotaro Banno <ryotaro.banno@gmail.com>
We have two options to adapt LVM command invocation i.e., --lvm-path
option and lvm-command-prefix setting. The lvm-command-prefix setting is
more general than --lvm-path, so the --lvm-path option is not necessary
anymore.

This commit deprecates the option. Users should use lvm-command-prefix
instead.

Signed-off-by: Ryotaro Banno <ryotaro.banno@gmail.com>
@ushitora-anqou
Copy link
Contributor Author

I'll merge this PR because there's no code change after the reviewers approved it:
https://github.com/topolvm/topolvm/compare/b04458abdcc724c8a703aa9b52101af90803e4a1..6f8f7f8cf0e0d25fccba3dc9ec3bad4809b11cb0

@ushitora-anqou ushitora-anqou merged commit 138a320 into main Jul 14, 2025
25 of 26 checks passed
@ushitora-anqou ushitora-anqou deleted the avoid-nsenter-option branch July 14, 2025 00:49
@github-project-automation github-project-automation bot moved this from Review in progress to Done in Development Jul 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Support hosts without lvm CLI preinstalled
4 participants