From 2278e4cf84ae91e17a6ac94cbe98cea5308e2c2f Mon Sep 17 00:00:00 2001 From: Jan Zerebecki Date: Tue, 10 Mar 2020 07:46:16 +0100 Subject: [PATCH] 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. --- scripts/mkcloudhost/allocpool | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scripts/mkcloudhost/allocpool b/scripts/mkcloudhost/allocpool index 6614a588f8..44a06577e7 100755 --- a/scripts/mkcloudhost/allocpool +++ b/scripts/mkcloudhost/allocpool @@ -5,6 +5,7 @@ use Time::HiRes qw(sleep); use Fcntl qw(:DEFAULT :flock); my $pooldir="$ENV{HOME}/pool"; +my $allocationsfile="$ENV{HOME}/allocations"; my $allocname="tmpqueuesched.pid"; # Take the oldest directory my @dirs= sort { (stat("$a/$allocname"))[9] <=> @@ -19,6 +20,19 @@ sleep(rand(2)); # reduce chance of collisions with make -j # lock+select testdir my $found=0; foreach my $d (@dirs) { + # check that allocations isn't out of sync with pool + open my $fha, $allocationsfile or die "Error: cant read $allocationsfile"; + my $allocationfound=0; + my $n=$d; + $n=~ s/$pooldir\///; + while(my $line=<$fha>) { + if($line =~ /^[a-z]*$n jenkins$/) { + $allocationfound=1; + last; + } + } + if(!$allocationfound) {die "Error: cant find in $allocationsfile: $n jenkins"} + close($fha); # use own allocation lock protocol my $a="$d/$allocname"; sysopen my $fh, $a, O_RDWR|O_CREAT or die "cant create $a";