]> xenbits.xensource.com Git - people/iwj/osstest.git/commitdiff
alloc_resources: Support special abandonment values
authorIan Jackson <ian.jackson@eu.citrix.com>
Fri, 20 Jul 2018 15:11:37 +0000 (16:11 +0100)
committerIan Jackson <ian.jackson@eu.citrix.com>
Mon, 29 Apr 2019 17:05:57 +0000 (18:05 +0100)
This gives a way for the caller's $resourcecall to signal something
interesting, back to its main loop.  This is useful for calling
broken, for example: that can't be done within $resourcecall because
$resourcecall operates within the allocation db transaction (which
ought to be rolled back...)

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Osstest/Executive.pm

index 0d8502b52030a38e92335f8de21e66a462c8cc06..b27b8d25bfe79b6d7dc8d85833b27929c6551f0f 100644 (file)
@@ -737,7 +737,8 @@ sub alloc_resources {
     #
     #  values of $ok
     #            0  rollback, wait and try again
-    #            1  commit, completed ok
+    #            1  commit, completed ok } return the
+    #           >1  rollback and abandon }  value of $ok
     #  $bookinglist should be undef or a hash for making a booking
     #
     # $resourcecall should not look at tasks.live
@@ -859,10 +860,14 @@ sub alloc_resources {
                    # $resourcecall itself failed: bomb out (don't retry)
                    $ok=-1;
                }
-               return db_retry_abort() unless $ok>0;
+               return db_retry_abort() unless $ok==1;
            }]);
 
-           if ($bookinglist && $ok!=-1) {
+           if ($ok<0 || $ok>1) {
+                return 1;
+           }
+
+           if ($bookinglist) {
                my %prstart;
                foreach my $book (@{ $bookinglist->{Bookings} }) {
                    my $pr = $book->{Reso};
@@ -890,8 +895,6 @@ sub alloc_resources {
 
             if ($ok==1) {
                 print $qserv "thought-done\n" or die $!;
-            } elsif ($ok<0) {
-                return 1;
             } else { # 0
                 logm("resource allocation: deferring");
                 print $qserv "thought-wait\n" or die $!;
@@ -935,8 +938,12 @@ END
             $ok= 0;
         }
     }
-    die unless $ok==1;
-    logm("resource allocation: successful.");
+    if ($ok==1) {
+       logm("resource allocation: successful.");
+    } else {
+       logm("resource allocation: resourcecall returned ($ok,...)");
+    }
+    return $ok;
 }
 
 sub resource_check_allocated ($$) {