Merge pull request #597 from ClusterLabs/upgrade-tools

Added a work-around for an LVM JSON formatting issue
main
Digimer 9 months ago committed by GitHub
commit d990154564
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      Anvil/Tools/Storage.pm
  2. 2
      scancore-agents/scan-drbd/scan-drbd
  3. 60
      scancore-agents/scan-lvm/scan-lvm
  4. 1
      scancore-agents/scan-lvm/scan-lvm.xml

@ -3282,7 +3282,7 @@ sub manage_lvm_conf
os_type => $os_type, os_type => $os_type,
os_arch => $os_arch, os_arch => $os_arch,
}}); }});
if ($os_type !~ /\D8/) if (($os_type ne "rhel8") && ($os_type ne "centos-stream8"))
{ {
# Not EL8, return # Not EL8, return
return(0); return(0);

@ -88,7 +88,7 @@ if ($anvil->DRBD->gather_data({debug => 2}))
} }
# Make sure that lvm.conf's filter of DRBD devices is in place. # Make sure that lvm.conf's filter of DRBD devices is in place.
$problem = $anvil->Storage->manage_lvm_conf(); $problem = $anvil->Storage->manage_lvm_conf({debug => 2});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { problem => $problem }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { problem => $problem }});
# TODO: Remove this eventually. # TODO: Remove this eventually.

@ -1261,6 +1261,26 @@ sub collect_pvs_data
return_code => $return_code, return_code => $return_code,
}}); }});
# If there's an old filter in lvm.conf, it will generate an error that breaks the JSON formatting.
# See: https://issues.redhat.com/browse/RHEL-29680
if ($output =~ /remove the lvm.conf filter/gs)
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_log_0002"});
my $new_output = "";
foreach my $line (split/\n/, $output)
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { line => $line }});
if ($line =~ /remove the lvm.conf filter/)
{
next;
}
$new_output .= $line."\n";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { new_output => $new_output }});
}
$output = $new_output;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { output => $output }});
}
my $json = JSON->new->allow_nonref; my $json = JSON->new->allow_nonref;
my $pvs_data = $json->decode($output); my $pvs_data = $json->decode($output);
my $default_sector_size = 512; my $default_sector_size = 512;
@ -1364,6 +1384,26 @@ sub collect_vgs_data
return_code => $return_code, return_code => $return_code,
}}); }});
# If there's an old filter in lvm.conf, it will generate an error that breaks the JSON formatting.
# See: https://issues.redhat.com/browse/RHEL-29680
if ($output =~ /remove the lvm.conf filter/gs)
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_log_0002"});
my $new_output = "";
foreach my $line (split/\n/, $output)
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { line => $line }});
if ($line =~ /remove the lvm.conf filter/)
{
next;
}
$new_output .= $line."\n";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { new_output => $new_output }});
}
$output = $new_output;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { output => $output }});
}
my $json = JSON->new->allow_nonref; my $json = JSON->new->allow_nonref;
my $vgs_data = $json->decode($output); my $vgs_data = $json->decode($output);
foreach my $hash_ref (@{$vgs_data->{report}->[0]->{vg}}) foreach my $hash_ref (@{$vgs_data->{report}->[0]->{vg}})
@ -1408,6 +1448,26 @@ sub collect_lvs_data
return_code => $return_code, return_code => $return_code,
}}); }});
# If there's an old filter in lvm.conf, it will generate an error that breaks the JSON formatting.
# See: https://issues.redhat.com/browse/RHEL-29680
if ($output =~ /remove the lvm.conf filter/gs)
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_log_0002"});
my $new_output = "";
foreach my $line (split/\n/, $output)
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { line => $line }});
if ($line =~ /remove the lvm.conf filter/)
{
next;
}
$new_output .= $line."\n";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { new_output => $new_output }});
}
$output = $new_output;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { output => $output }});
}
my $json = JSON->new->allow_nonref; my $json = JSON->new->allow_nonref;
my $lvs_data = $json->decode($output); my $lvs_data = $json->decode($output);
foreach my $hash_ref (@{$lvs_data->{report}->[0]->{lv}}) foreach my $hash_ref (@{$lvs_data->{report}->[0]->{lv}})

@ -226,6 +226,7 @@ The attribute bits are:
<!-- Log entries --> <!-- Log entries -->
<key name="scan_lvm_log_0001">Starting: [#!variable!program!#].</key> <key name="scan_lvm_log_0001">Starting: [#!variable!program!#].</key>
<key name="scan_lvm_log_0002">[ NOTE ] - Please update lvm.conf to remove the filter: filter = [ "r|/dev/drbd*|" ]</key>
<!-- Warning entries --> <!-- Warning entries -->
<key name="scan_lvm_warning_0001">[ Warning ] - Failed to find the sector size for: [#!variable!device!#] This should be in the path: [#!variable!sector_path!#]. Assuming the sector size of: [#!variable!sector_size!#], but this could be incorrect.</key> <key name="scan_lvm_warning_0001">[ Warning ] - Failed to find the sector size for: [#!variable!device!#] This should be in the path: [#!variable!sector_path!#]. Assuming the sector size of: [#!variable!sector_size!#], but this could be incorrect.</key>

Loading…
Cancel
Save