Commit 5d2cf35c authored by Leigh Stoller's avatar Leigh Stoller

Simple workaround for the gitrepo hook encountering a locked profile.

This can happen if two commits to the repo happen very quickly. Spin
for a little bit before giving up. Not a great solution, needs more
thought when I have time.
parent aa8569f8
......@@ -939,6 +939,26 @@ sub Unlock($)
return 0;
}
#
# Wait for lock with timeout (in seconds).
#
sub WaitForLock($$)
{
my ($self, $timeout) = @_;
return $self->Lock()
if (! $timeout);
while ($timeout >= 0) {
return 0
if ($self->Lock() == 0);
$timeout--;
sleep(1);
}
return -1;
}
#
# Update the disk image inside a profile. We update the URL for the
# specified node, and if $all is set, we change all nodes with the
......
......@@ -908,7 +908,7 @@ sub UpdateProfileFromRepo()
elsif (!$project->AccessCheck($this_user, TB_PROJECT_MAKEIMAGEID())) {
fatal("Not enough permission in this project");
}
if ($profile->Lock()) {
if ($profile->WaitForLock(10)) {
print STDERR "Profile is busy, cannot lock it.\n";
exit(1);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment