Skip to content

Commit

Permalink
Merge pull request #2701 from M0ses/list_badshosts
Browse files Browse the repository at this point in the history
[backend] --list-badhosts for bs_admin
  • Loading branch information
mlschroe committed Feb 20, 2017
2 parents 5a43e1e + 544300e commit c2d0549
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/backend/bs_admin
Expand Up @@ -28,6 +28,7 @@ BEGIN {
unshift @INC, "$wd";
}

use strict;
use POSIX;
use Data::Dumper;
use Getopt::Long;
Expand Down Expand Up @@ -370,7 +371,7 @@ sub insert_request_db {
$db->{'noindex'} = {'id' => 1};

my @rid = split ('/',$file);
$rid = $rid[-1];
my $rid = $rid[-1];
my $req = readxml("$requestdir/$rid", $BSXML::request, 1);
print "WARNING: unable to parse request: $rid!\n" unless $req;
$db->updateindex($rid, {}, $req || {});
Expand Down Expand Up @@ -427,6 +428,7 @@ sub check_constraints_xml {
sub check_meta_xml {
my ($project, $package) = @_;
my $file;
my $metadesc;

if (defined($package)){
$file = "$projectsdir/${project}.pkg/${package}.xml";
Expand Down Expand Up @@ -617,6 +619,8 @@ while (@ARGV) {
} elsif ($arg eq "--parse-build-desc") {
die("ERROR: need a file name as argument (spec, dsc or kiwi)!\n") if @ARGV < 1;
my $file = shift @ARGV;
my $cfile;
my $arch;
my $cf = $cfile = $arch = undef;
$arch = shift @ARGV if @ARGV > 0;
if (@ARGV > 0) {
Expand All @@ -633,7 +637,7 @@ while (@ARGV) {
print Dumper($ret);
} elsif ($arg eq "--dump-cache") {
if (@ARGV == 1) {
$fullfile = shift @ARGV;
my $fullfile = shift @ARGV;
die("ERROR: invalid filename (must end with .cache or .solv)\n") if $fullfile !~ /\.(?:solv|cache)$/;
dump_solv($fullfile) if $fullfile =~ /\.solv$/;
dump_nStore($fullfile) if $fullfile =~ /\.cache$/;
Expand Down Expand Up @@ -1029,8 +1033,9 @@ while (@ARGV) {
my ($hash, $desc) = split(/\s+/, $_);
next if !defined( $sourcefiles{$hash.'-'.$desc});
# open link file to look if it links to a file that will be deleted
my $link;
eval {
my $link = readxml($sourcefiles{$hash.'-'.$desc}, $BSXML::link);
$link = readxml($sourcefiles{$hash.'-'.$desc}, $BSXML::link);
} ;
if ($@) { warn "$@ whilst processing $treesfiles{$file}"; next; }
next if !defined $link->{"package"} || !defined $link->{"project"} || !defined $link->{"rev"};
Expand Down Expand Up @@ -1126,6 +1131,20 @@ while (@ARGV) {
print "$val\n";
} elsif ( $arg eq "--drop-badhosts" ) {
BSUtil::touch("$rundir/bs_dispatch.dropbadhosts");
} elsif ( $arg eq "--list-badhosts" ) {
if ( -f "$rundir/dispatch.badhosts" ) {
my $result = {};
my $badhosts = BSUtil::retrieve("$rundir/dispatch.badhosts");
print Dumper($badhosts);
#for my $key (keys(%{$badhosts})) {
# if ($key =~ s#^([^/]+/[^/]+/[^/]+/[^/]+)#$1# ) {
# $result->{$key}=1;
# }
#}
#for my $key (sort(keys($result))) { print "$key\n" }
} else {
print "No badhosts found\n";
}
} else {
echo_help();
exit(1)
Expand Down
5 changes: 5 additions & 0 deletions src/backend/bs_dispatch
Expand Up @@ -1357,7 +1357,12 @@ while (1) {
delete $badhost{$_};
}
}
BSUtil::store("$rundir/dispatch.badhosts",undef,\%badhost);
} else {
# we dont care if file doesn`t exists
unlink("$rundir/dispatch.badhosts");
}

filechecks();
}

Expand Down

0 comments on commit c2d0549

Please sign in to comment.