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
[lvm2] Fix warning due to locking_type=0 option #2127
[lvm2] Fix warning due to locking_type=0 option #2127
Conversation
|
As far as I can tell, |
I don't think so: If I am right, the change in Some feedback from @slashdd or others from Ubuntu/Debian is welcomed, if it can't break something. |
|
(optionally, we can make the |
Ah yes, you're right. I must not have checked the display commands as I should have done. I checked the Clearly the scope of that option is not as extensive on earlier releases as it is on RHEL 8. |
|
I would suggest wrapping something around a predicate to produce the desired change in string based on a version check, or failing that (since it may depend too closely on distro NVR specifics) base on the output of |
|
Updated the commit to check I tested using |
sos/report/plugins/lvm2.py
Outdated
| if '--nolocking' in self.exec_cmd('vgdisplay -h')['output']: | ||
| lvm_opts = '--config="global{metadata_read_only=1}" --nolocking' | ||
| else: | ||
| lvm_opts = '--config="global{locking_type=0 metadata_read_only=1}"' |
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.
We have a somewhat recent addition in the API in the form of predicates that handles this directly.
It'd be something like:
nolock = {'cmd': vgdisplay -h', 'output': '--nolocking'}
if self.test_predicate(self, pred=SoSPredicate(self, cmd_outputs=nolock):
lvm_opts = 'foo'
else:
lvm_opts = 'bar'The grub2 plugin has an example of this kind of predicate.
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.
Thanks! That seems to work (though the first self arg to test_predicate is unnecessary here and in grub2.py).
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.
You don't really need to use test_predicate() here since this is a known predicate for a specific condition - the only difference between self.test_predicate(pred) and bool(pred) is that test_predicate() will use the default command or plugin predicate instead of the pred= kwarg if they are set and it is not - that's probably not the behaviour you want here, even if it currently gives the same result.
The test_predicate() call has self as the first argument since it is a method of the Plugin class (in order to retrieve the stored command or plugin predicate).
Same comment applies to the use in grub2: it can simply be rewritten as:
if bool(SoSPredicate(self, cmd_outputs=co)):
grub_cmd += ' --no-grubenv-update'And likewise here - generally speaking plugins should not need to call Plugin.test_predicate() themselves - its main use is to consistently apply the predicate precedence rules when evaluating predicates in the Plugin helper methods (add_copy_spec(), add_cmd_output(), add_string_as_file(), collect_cmd_output(), and exec_cmd(): these need to properly evaluate any predicate passed in the method arguments as well as any stored command or plugin predicate. For this kind of one-off use where a single, specific predicate guards an action that's not required and it makes the code harder to follow.
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.
Great to know! That's much cleaner.
|
Updated based on @TurboTurtle 's feedback. I tested with upstream sos on RHEL 7 and RHEL 8, and it appears to work as intended. Let me know if you find that it doesn't. |
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.
Ack to the general approach but please drop the unnecessary test_predicate() and just use the boolean value of the predicate.
On RHEL 8, the option `--config="global{locking_type=0}"` is deprecated.
This option is included in the lvm_opts variable and thus produces
deprecation warnings in the outputs of pvscan, vgscan, pvs, vgs, and
lvs:
WARNING: locking_type (0) is deprecated, using --nolocking.
This patch fixes the issue by removing "locking_type=0" from the config
string and appending "--nolocking" to lvm_opts on systems where
"--nolocking" is supported.
Related to RHBZ#1849248.
Resolves: #2127
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
On RHEL 8, the option
--config="global{locking_type=0}"is deprecated.This option is included in the
lvm_optsvariable and thus producesdeprecation warnings in the outputs of
pvscan,vgscan,pvs,vgs,and
lvs:This patch fixes the issue by removing
locking_type=0from the configstring and appending
--nolockingtolvm_opts.Related to RHBZ#1849248.
Signed-off-by: Reid Wahl nrwahl@protonmail.com
Please place an 'X' inside each '[]' to confirm you adhere to our Contributor Guidelines
Closes: #ISSUENUMBERincluded in an independent line?Resolves: #PRNUMBERincluded in an independent line?