Skip to content

Commit 9620f62

Browse files
committed
make allocpool check the allocations file
as sometimes people change allocations, but not the contents of the pool directory or the other way around. Make it check both, to ensure someones running mkcloud is not replaced.
1 parent 21990db commit 9620f62

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

scripts/mkcloudhost/allocpool

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use Time::HiRes qw(sleep);
55
use Fcntl qw(:DEFAULT :flock);
66

77
my $pooldir="$ENV{HOME}/pool";
8+
my $allocationsfile="$ENV{HOME}/allocations";
89
my $allocname="tmpqueuesched.pid";
910
# Take the oldest directory
1011
my @dirs= sort { (stat("$a/$allocname"))[9] <=>
@@ -19,6 +20,19 @@ sleep(rand(2)); # reduce chance of collisions with make -j
1920
# lock+select testdir
2021
my $found=0;
2122
foreach my $d (@dirs) {
23+
# check that allocations isn't out of sync with pool
24+
open my $fha, $allocationsfile or die "Error: cant read $allocationsfile";
25+
my $allocationfound=0;
26+
my $n=$d;
27+
$n=~ s/$pooldir\///;
28+
while(<$fha>) {
29+
if(/^[a-z]*$n jenkins$/) {
30+
$allocationfound=1;
31+
last;
32+
}
33+
}
34+
if(!$allocationfound) {die "Error: cant find in $allocationsfile: $n jenkins"}
35+
close($fha);
2236
# use own allocation lock protocol
2337
my $a="$d/$allocname";
2438
sysopen my $fh, $a, O_RDWR|O_CREAT or die "cant create $a";

0 commit comments

Comments
 (0)