Skip to content

Commit

Permalink
mxraid/mxraid_assemble: Wait if enclosures start slowly
Browse files Browse the repository at this point in the history
Sometimes the disks in a enclosure are registered a bit
lately, so check if there is some dynamic (count of disks),
and if so -- just wait a little longer.

Note: this was only observed once 'in the wild', and the required
      delay would have been in the range of 50ms.
  • Loading branch information
thomas committed Nov 9, 2018
1 parent a23b12b commit 3a8b44e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions mxraid/mxraid_assemble
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use Data::Dumper; $Data::Dumper::Sortkeys=1;
use Getopt::Std; $Getopt::Std::STANDARD_HELP_VERSION=1;
sub HELP_MESSAGE{}
sub VERSION_MESSAGE{}
use Sys::Syslog;
use Time::HiRes qw(usleep);

import MxRaid::ConfData;
import MxRaid::HostData;
Expand Down Expand Up @@ -60,6 +62,22 @@ sub exec_version {
exit 0;
}

sub check_enclosures {
glob('/sys/class/enclosure/*') or return;

my $cnt_0 = () = (glob('/sys/block/sd[a-z]'), glob('/sys/block/sd[a-z][a-z]'));
usleep(0.3 * 1e6);
my $cnt_1 = () = (glob('/sys/block/sd[a-z]'), glob('/sys/block/sd[a-z][a-z]'));

if ( $cnt_0 != $cnt_1 ) { # then something still 'evolves', shout around and take a nap.
my ($prog) = $0 =~ m|([^/]+)$|;
openlog($prog,'pid','user');
Sys::Syslog::setlogsock('unix'); # with 'native' we get EOLs in the logfile, option "noeol" doesn't work
syslog('info', 'still discovering disks, diff is %d. Waiting 3 seconds ...', $cnt_1 - $cnt_0);
sleep 3;
}
}

my $ROOT=$<==0?1:0;

my %opts;
Expand Down Expand Up @@ -88,6 +106,7 @@ my $MDADM_CONF_BASE = '/dev/shm/mdadm.conf'; # config for mdadm, created with in
my $MDADM_ASSEMBLE_OPTIONS = '';

my $cd = MxRaid::ConfData->new($MDADMCONF_DB); $cd->verbose($VERBOSE); $cd->load();
check_enclosures(); # idle a bit if enclosures are attached ...
my $hd = MxRaid::HostData->new($cd); $hd->verbose($VERBOSE);
my $utils = MxRaid::Utils->new();

Expand Down

1 comment on commit 3a8b44e

@thomas
Copy link
Contributor Author

@thomas thomas commented on 3a8b44e Nov 9, 2018

Choose a reason for hiding this comment

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

Tested on 'phaedra', will be installed on Monday 12.Nov.

Please sign in to comment.