Skip to content

lvm2: reporting format fixes#111

Merged
bmr-cymru merged 7 commits intomainfrom
bmr-lvm-json-std
Mar 13, 2025
Merged

lvm2: reporting format fixes#111
bmr-cymru merged 7 commits intomainfrom
bmr-lvm-json-std

Conversation

@bmr-cymru
Copy link
Copy Markdown
Contributor

@bmr-cymru bmr-cymru commented Mar 12, 2025

Resolves: #109, #110, #112.

@packit-as-a-service
Copy link
Copy Markdown

Congratulations! One of the builds has completed. 🍾

You can install the built RPMs by following these steps:

  • sudo yum install -y dnf-plugins-core on RHEL 8
  • sudo dnf install -y dnf-plugins-core on Fedora
  • dnf copr enable packit/snapshotmanager-snapm-111
  • And now you can install the packages.

Please note that the RPMs should be used only in a testing environment.

@bmr-cymru bmr-cymru force-pushed the bmr-lvm-json-std branch 4 times, most recently from d1697bb to d722e3f Compare March 12, 2025 18:57
@bmr-cymru bmr-cymru changed the title lvm2: always use json_std as the LVM2 reportformat lvm2: reporting format fixes Mar 12, 2025
@bmr-cymru bmr-cymru force-pushed the bmr-lvm-json-std branch 2 times, most recently from dbc33df to c69ddfc Compare March 12, 2025 21:21
Accept either JSON output format for the mock versions of the LVM
reporting commands. The fields parsed by the lvm2 plugins are not
affected by the JSON format version so the mock output is unchanged.
Since lvm2 on Ubuntu-24.04 does not support the --reportformat json_std
argument refactor the lvm2 plugin helper functions that call out to lvm2
reporting commands to be methods of the Lvm2 plugin class.

This allows the plugin to detect the lvm2 version when it is initialised
and set a private property, _json_fmt to the required --reportformat
string.

Subsequent calls to the helpers can then use this value to issue the
appropriate command line arguments for the running lvm2 version.

Amend test cases for the corresponding functions to use the appropriate
object type for helper unit tests.

Related: #110
Check whether the installed version of lvm2 supports the 'json_std'
--reportformat argument and switch back to 'json' for old versions.

Resolves: #110
Unless explicitly set on the command line the report format used by the
lvm2 tools may be influenced by settings in the environment or
configuration files.

For example, setting LVM_COMMAND_PROFILE selects an alternate
configuration file from /etc/lvm/profiles, which may override the
report/output_format option.

Prevent this by always setting the --reportformat explicitly on the lvm2
command line as is already done in other plugin helpers.

Resolves: #109
Make the vg_lv_from_device_path() helper a method of the Lvm2 plugins:
this facilitates applying environment variable sanitisation to the lvm
calls in a subsequent commit.

Related: #112
There are numerous LVM2 environment variables (see lvm(8)) that can
influence the behaviour of the commands that snapm relies on in the lvm2
plugins.

Filter the environment when initialising the plugin to discard any
unwanted variables: the LVM_SYSTEM_DIR environment variable is
explicitly excluded since it is used in the test suite and can be used
legitimately to direct snapm to an alternate LVM configuration.

Resolves: #112
The Stratis project released 3.8.0 today and the 3.7.0 package is no
longer available on pip: switch to installing from git and pin to the
old release for now.

Related: #113
@bmr-cymru bmr-cymru merged commit 9f9b082 into main Mar 13, 2025
15 checks passed
@bmr-cymru bmr-cymru deleted the bmr-lvm-json-std branch May 30, 2025 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lvm2: ensure vg_lv_from_device_path() receives expected format from lvs command

1 participant