-
Notifications
You must be signed in to change notification settings - Fork 2
feat(prepare): exclude loop and virtual devices from host LVM scanning #49
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
Changes from 1 commit
1f3856a
0657c42
61a6067
f3964ed
7539c42
961c1db
ffc62f4
a870f42
c06237f
91cc24b
023de19
189287e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -276,6 +276,18 @@ | |
| } | ||
| notify: Restart multipathd | ||
|
|
||
| # Exclude DRBD, device-mapper, zvol and loop devices from the host's | ||
| # LVM device scanning. Without this the host LVM may scan and activate | ||
| # volume groups backed by LINSTOR/DRBD volumes — or located inside | ||
| # loop-mounted images — making them unavailable to the satellite. | ||
| # Mirrors the global_filter shipped in the Talos machine config. | ||
| - name: Exclude virtual and loop devices from host LVM scanning | ||
| ansible.builtin.lineinfile: | ||
| path: /etc/lvm/lvm.conf | ||
| regexp: '^\s*#?\s*global_filter\s*=' | ||
| insertafter: '^devices {' | ||
| line: ' global_filter = [ "r|^/dev/drbd.*|", "r|^/dev/dm-.*|", "r|^/dev/zd.*|", "r|^/dev/loop.*|" ]' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This task introduces two issues that should be addressed:
- name: Exclude virtual and loop devices from host LVM scanning
ansible.builtin.lineinfile:
path: /etc/lvm/lvm.conf
regexp: '^\s*#?\s*global_filter\s*='
insertafter: '^\s*devices\s*{'
line: ' global_filter = {{ cozystack_lvm_global_filter | default(["r|^/dev/drbd.*|", "r|^/dev/dm-.*|", "r|^/dev/zd.*|", "r|^/dev/loop.*|"]) | to_json }}'
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both points addressed in 0657c42.
|
||
|
|
||
| - name: Configure sysctl parameters | ||
| ansible.posix.sysctl: | ||
| name: "{{ item.name }}" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -322,6 +322,18 @@ | |
| } | ||
| notify: Restart multipathd | ||
|
|
||
| # Exclude DRBD, device-mapper, zvol and loop devices from the host's | ||
| # LVM device scanning. Without this the host LVM may scan and activate | ||
| # volume groups backed by LINSTOR/DRBD volumes — or located inside | ||
| # loop-mounted images — making them unavailable to the satellite. | ||
| # Mirrors the global_filter shipped in the Talos machine config. | ||
| - name: Exclude virtual and loop devices from host LVM scanning | ||
| ansible.builtin.lineinfile: | ||
| path: /etc/lvm/lvm.conf | ||
| regexp: '^\s*#?\s*global_filter\s*=' | ||
| insertafter: '^devices {' | ||
| line: ' global_filter = [ "r|^/dev/drbd.*|", "r|^/dev/dm-.*|", "r|^/dev/zd.*|", "r|^/dev/loop.*|" ]' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This task introduces two issues that should be addressed:
- name: Exclude virtual and loop devices from host LVM scanning
ansible.builtin.lineinfile:
path: /etc/lvm/lvm.conf
regexp: '^\s*#?\s*global_filter\s*='
insertafter: '^\s*devices\s*{'
line: ' global_filter = {{ cozystack_lvm_global_filter | default(["r|^/dev/drbd.*|", "r|^/dev/dm-.*|", "r|^/dev/zd.*|", "r|^/dev/loop.*|"]) | to_json }}'
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both points addressed in 0657c42.
|
||
|
|
||
| - name: Configure sysctl parameters | ||
| ansible.posix.sysctl: | ||
| name: "{{ item.name }}" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This task introduces two issues that should be addressed:
Robustness of
insertafter: The regex^devices {is very strict and requires the line to start exactly withdevices {(no leading whitespace, exactly one space before the brace). If the target system'slvm.confhas any leading indentation or different spacing (e.g.,devices{), the regex will fail to match. Wheninsertafterfails to match,lineinfileappends the line to the end of the file. In LVM configuration, settings outside their respective blocks (likedevices { ... }) are invalid or ignored, which would break the configuration or prevent the filter from working. Using^\s*devices\s*{is much more robust.LUKS and Multipath Compatibility: Rejecting
/dev/dm-.*in theglobal_filterprevents the host LVM from scanning any device-mapper devices. This will completely break hosts that use LVM on top of LUKS (encrypted partitions) or LVM on top of Multipath (MPIO), as their physical volumes (PVs) reside on/dev/dm-Xdevices. To make this safe and customizable, we should expose the filter list as a variable (e.g.,cozystack_lvm_global_filter) using thedefaultfilter. This allows users with LUKS or Multipath to override the filter in their inventory (e.g., by removing"r|^/dev/dm-.*|"), while keeping the current default behavior for dedicated storage nodes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both points addressed in 0657c42.
insertafteris now^\s*devices\s*{, so the setting still lands inside thedevices{}block whenlvm.confuses leading whitespace or compact bracing, instead of being appended at EOF where LVM ignores it.cozystack_lvm_global_filter(same default), rendered withto_json. Hosts whose own PVs live on device-mapper devices (LVM-on-LUKS, multipath) can override it from inventory — e.g. drop ther|^/dev/dm-.*|entry.