From: Francois Gouget Subject: [PATCH] testbot/Submit: Ensure the staged patch can be cleaned up if submit fails. Message-Id: Date: Tue, 21 Jan 2020 12:07:05 +0100 (CET) Signed-off-by: Francois Gouget --- 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 '-websubmit_'. 2. When the user clicks on the Submit button the file is renamed to '_'. 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