[PATCH] testbot/Submit: Ensure the staged patch can be cleaned up if submit fails.
Francois Gouget
fgouget at codeweavers.com
Tue Jan 21 05:07:05 CST 2020
Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
Janitor now reports errors to the TestBot administrators and it has been
reporting an unexpected staging file called
'e4b15422eaed510e12c4cd7735335c41gdi32_test.exe'. That file got created
by the Submit script on the 30th of December but should not have stayed
there.
What normally happens is this:
1. The uploaded patch or executable is saved in the staging directory as
'<sessionid>-websubmit_<filename>'.
2. When the user clicks on the Submit button the file is renamed to
'<rnd><filename'. This is how the file above got there.
3. Then the Submit script creates the new job and if that fails it
renames the file back.
4. Otherwise, once the job id is known, it renames the file again to
'<jobid>_<filename>'.
5. Later on the Engine picks up the new job and sets it up which
involves moving the file out of the directory and to the job's
directory.
So something wrong happened between steps 2 and 4 but did not trigger
the step 3 rollback. The most likely culprit is a Perl error. In the web
server log I found a couple of 'Undefined subroutine
&WineTestBot::Jobs::CreatePatches' errors that typically happen when
Apache needs to be restarted after a TestBot code update. This is
likely to be the reason for this issue.
So this patch renames the step 2 file so Janitor can identify it and
automatically clean it up.
testbot/bin/Janitor.pl | 2 +-
testbot/web/Submit.pl | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/testbot/bin/Janitor.pl b/testbot/bin/Janitor.pl
index f78c75d72e..121a3a6066 100755
--- a/testbot/bin/Janitor.pl
+++ b/testbot/bin/Janitor.pl
@@ -271,7 +271,7 @@ if (opendir(my $dh, "$DataDir/staging"))
my $Age = int((-M $FileName) + 0.5);
my $TTL = $JobPurgeDays ? $JobPurgeDays - $Age : undef;
- if ($Entry =~ /^[0-9a-f]{32}-websubmit_/)
+ if ($Entry =~ /^[0-9a-f]{32}-websubmit2?_/)
{
# These files always expire after one day
$TTL = 1 - $Age;
diff --git a/testbot/web/Submit.pl b/testbot/web/Submit.pl
index bd3dc9fe13..1943b426e9 100644
--- a/testbot/web/Submit.pl
+++ b/testbot/web/Submit.pl
@@ -1292,7 +1292,7 @@ sub OnSubmit($)
# Rename the staging file to avoid race conditions if the user clicks on
# Submit multiple times
my $OldStaging = $self->_GetStagingFilePath();
- my $Staging = CreateNewLink($OldStaging, "$DataDir/staging", $self->{FileName});
+ my $Staging = CreateNewLink($OldStaging, "$DataDir/staging", "-websubmit2_$self->{FileName}");
if (!defined $Staging)
{
$self->{ErrMessage} = "Could not rename '$self->{FileName}': $!";
--
2.20.1
More information about the wine-devel
mailing list