All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Ian Campbell <ian.campbell@citrix.com>
Subject: [OSSTEST PATCH 8/9] mg-allocate: Better error handling when no candidates
Date: Thu, 17 Dec 2015 17:06:07 +0000	[thread overview]
Message-ID: <1450371968-27997-8-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1450371968-27997-1-git-send-email-ian.jackson@eu.citrix.com>

Spot when our db search revealed no candidates for the resources to
allocate, and:
 - when doing an immediate allocation, call it an error
 - when doing a planned allocation, cause it to prevent allocation
   on this iteration, and print a suitably unreassuring message

Previously it would simply say `nothing available'.

Implement this as follows:
 - Report lack of candidates as $ok=-1 from alloc_1rescand
 - In alloc_1res, return this -1 as with any non-zero $ok
 - Handle the new $ok at all the call sites, in particular
 - In plan(), rename `allok' to `worstok' and have it be
   the worst relevant $ok value.  If $ok gives -1, return
   undef, rather than a booking list, to the allocator core.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 mg-allocate |   24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/mg-allocate b/mg-allocate
index 4c32fa8..54a7af3 100755
--- a/mg-allocate
+++ b/mg-allocate
@@ -211,6 +211,9 @@ END
         $got_shareix= $candrow->{shareix};
         $ok=1; last;
     }
+    if (!$resq->rows) {
+	return (-1,undef);
+    }
     return ($ok, { Allocate => $allocate,
 		   Shareix => $got_shareix,
 		   Info => "$resname ($restype/$resname/$got_shareix)"
@@ -248,6 +251,8 @@ sub execute () {
             if (!$ok) {
                 logm("nothing available for $res, sorry");
                 $allok=0;
+            } elsif ($ok < 0) {
+		die "*** no candidates for $res! ***\n";
             } else {
                 logm("processed $res (shareix=$got->{Shareix})");
 		push @got, $got;
@@ -314,17 +319,19 @@ sub plan () {
 	logm("best at $planned->{Start} is ".showposs(\@reqlist));
 	die unless $planned;
 
-        my $allok=0;
+        my $worstok=0;
         if ($mayalloc && !$planned->{Start}) {
-            $allok=1;
+            $worstok=1;
 
             alloc_prep();
 
             foreach my $req (@reqlist) {
                 my ($ok, $got) = alloc_1res($req->{Ident});
+		$worstok = $ok if $ok < $worstok;
                 if (!$ok) {
                     logm("failed to allocate $req->{Ident}!");
-                    $allok=0;
+                } elsif ($ok < 0) {
+		    logm("*** no candidates for $req->{Ident}! ***");
                 } else {
                     $req->{GotShareix}= $got->{Shareix};
 		    push @got, $got;
@@ -332,9 +339,12 @@ sub plan () {
             }
         }
 
-        if ($allok) {
+        if ($worstok > 0) {
             logm("allocated, notifying...");
-        } else {
+        } elsif ($worstok < 0) {
+	    logm("*** problems, maybe missing resources? ***");
+	    return (0, undef);
+	} else {
             logm("booking...");
         }
 
@@ -346,7 +356,7 @@ sub plan () {
                 Start => $planned->{Start},
                 End => $planned->{Start} + $duration,
             };
-            if ($allok) {
+            if ($worstok > 0) {
                 $book->{Allocated}= {
                     Task => $tid,
                     Shareix => $req->{GotShareix},
@@ -355,7 +365,7 @@ sub plan () {
             push @bookings, $book;
         }
 
-        return ($allok, { Bookings => \@bookings });
+        return ($worstok, { Bookings => \@bookings });
     });
     loggot(@got);
 }
-- 
1.7.10.4

  parent reply	other threads:[~2015-12-17 17:06 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-17 17:06 [OSSTEST PATCH 1/9] README.dev: Document the blessings Ian Jackson
2015-12-17 17:06 ` [OSSTEST PATCH 2/9] mg-schema-test-database: Provide some timeouts which are better for testing Ian Jackson
2015-12-17 17:19   ` Ian Campbell
2015-12-17 17:06 ` [OSSTEST PATCH 3/9] mg-schema-test-database: Wipe previous local plan data Ian Jackson
2015-12-17 17:22   ` Ian Campbell
2015-12-17 17:37     ` Ian Jackson
2015-12-17 17:42       ` Ian Campbell
2015-12-17 17:50         ` Ian Jackson
2015-12-17 18:11           ` Ian Campbell
2015-12-17 17:06 ` [OSSTEST PATCH 4/9] mg-schema-test-database: Borrow shares properly Ian Jackson
2015-12-17 17:26   ` Ian Campbell
2015-12-17 17:43     ` Ian Jackson
2015-12-17 18:08       ` Ian Campbell
2015-12-17 17:06 ` [OSSTEST PATCH 5/9] ms-planner: Improve an error message Ian Jackson
2015-12-17 17:26   ` Ian Campbell
2015-12-17 17:06 ` [OSSTEST PATCH 6/9] db_retry: Suppress an "exiting via last" warning Ian Jackson
2015-12-17 17:31   ` Ian Campbell
2015-12-17 17:48     ` Ian Jackson
2015-12-17 18:10       ` Ian Campbell
2015-12-17 18:38         ` Ian Jackson
2015-12-18 11:14           ` Ian Campbell
2015-12-18 14:39             ` Ian Jackson
2015-12-17 17:06 ` [OSSTEST PATCH 7/9] Executive DB retry: Avoid an undefined warning Ian Jackson
2015-12-17 17:31   ` Ian Campbell
2015-12-17 17:06 ` Ian Jackson [this message]
2015-12-17 17:33   ` [OSSTEST PATCH 8/9] mg-allocate: Better error handling when no candidates Ian Campbell
2015-12-17 17:06 ` [OSSTEST PATCH 9/9] mg-allocate: In planner mode, pre-check the arguments Ian Jackson
2015-12-17 17:33   ` Ian Campbell
2015-12-17 17:18 ` [OSSTEST PATCH 1/9] README.dev: Document the blessings Ian Campbell
2015-12-17 17:59   ` Ian Jackson
2015-12-17 18:12     ` Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1450371968-27997-8-git-send-email-ian.jackson@eu.citrix.com \
    --to=ian.jackson@eu.citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.