Skip to content

Commit

Permalink
[backend] bs_admin: add --recheck-dod command to force recheck a DoD
Browse files Browse the repository at this point in the history
It supports a project or url prefix as argument
  • Loading branch information
mlschroe committed Sep 20, 2018
1 parent 157a9c7 commit 4df2f11
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/backend/bs_admin
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ my $configfile = "$BSConfig::bsdir/configuration.xml";
my $treesdir = $nosharedtrees ? "$BSConfig::bsdir/trees" : $srcrepdir;
my $sourcedb = "$BSConfig::bsdir/db/source";
my $rundir = "$BSConfig::bsdir/run";
my $dodsdir = "$BSConfig::bsdir/dods";


sub echo_help {
Expand Down Expand Up @@ -1158,6 +1159,12 @@ while (@ARGV) {
} else {
print "No badhosts found\n";
}
} elsif ($arg eq "--recheck-dod") {
die("ERROR: need url or project prefix as argument!\n") if @ARGV < 1;
my $rc = shift @ARGV;
my $fn = Digest::MD5::md5_hex($rc).".recheck";
writestr("$dodsdir/.$fn", "$dodsdir/$fn", "$rc\n");
BSUtil::touch("$dodsdir/.changed")
} else {
echo_help();
exit(1)
Expand Down
26 changes: 26 additions & 0 deletions src/backend/bs_dodup
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ my $timeout_large = 300;
my $checkinterval_ok = 60 * 60;
my $checkinterval_error = 10 * 60;

$checkinterval_ok = $BSConfig::dodup_checkinterval_ok if $BSConfig::dodup_checkinterval_ok;
$checkinterval_error = $BSConfig::dodup_checkinterval_error if $BSConfig::dodup_checkinterval_error;

BSUtil::mkdir_p_chown($bsdir, $BSConfig::bsuser, $BSConfig::bsgroup) || die("unable to create $bsdir\n");
BSUtil::drop_privs_to($BSConfig::bsuser, $BSConfig::bsgroup);

Expand Down Expand Up @@ -399,7 +402,15 @@ sub scan_dodsdir {
print "scanning doddatas directory...\n";
my %newdoddatas;
my %ids = map {$_->{'id'} => $_} values(%{$olddoddatas || {}});
my %rechecks;
for my $f (sort(grep {!/^\./s} ls($dodsdir))) {
if ($f =~ /.recheck$/) {
my $rc = readstr("$dodsdir/$f", 1);
chomp $rc;
$rechecks{$rc} = 1;
unlink("$dodsdir/$f");
next;
}
my @s = stat("$dodsdir/$f");
next unless @s;
my $id = "$s[9]/$s[7]/$s[1]";
Expand All @@ -421,6 +432,21 @@ sub scan_dodsdir {
$doddata->{'lastcheck'} ||= 0;
$newdoddatas{$prpa} = $doddata;
}
if (%rechecks) {
for my $doddata (values %newdoddatas) {
my $recheck = 0;
for my $rc (sort keys %rechecks) {
if ($rc =~ /^https?:\/\//) {
$recheck = 1 if $doddata->{'url'} && $doddata->{'url'} =~ /^\Q$rc\E/;
} else {
$recheck = 1 if "$doddata->{'project'}/$doddata->{'repository'}" =~ /^\Q$rc\E/;
}
}
next unless $recheck;
print "force recheck of $doddata->{'project'}/$doddata->{'repository'}\n";
$doddata->{'lastcheck'} = 0;
}
}
return %newdoddatas;
}

Expand Down

0 comments on commit 4df2f11

Please sign in to comment.