From patchwork Thu Dec 17 17:06:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 7875131 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4EC8E9F32E for ; Thu, 17 Dec 2015 17:09:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 774CC2047B for ; Thu, 17 Dec 2015 17:09:00 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3F14B20453 for ; Thu, 17 Dec 2015 17:08:59 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1a9c0W-0005vJ-SN; Thu, 17 Dec 2015 17:06:24 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1a9c0T-0005u7-Q7 for xen-devel@lists.xenproject.org; Thu, 17 Dec 2015 17:06:21 +0000 Received: from [85.158.143.35] by server-2.bemta-4.messagelabs.com id C3/D6-18316-D8BE2765; Thu, 17 Dec 2015 17:06:21 +0000 X-Env-Sender: prvs=7867bb76c=Ian.Jackson@citrix.com X-Msg-Ref: server-16.tower-21.messagelabs.com!1450371979!1553885!2 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 55993 invoked from network); 17 Dec 2015 17:06:20 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-16.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 17 Dec 2015 17:06:20 -0000 X-IronPort-AV: E=Sophos;i="5.20,442,1444694400"; d="scan'208";a="320065448" From: Ian Jackson To: Date: Thu, 17 Dec 2015 17:06:07 +0000 Message-ID: <1450371968-27997-8-git-send-email-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1450371968-27997-1-git-send-email-ian.jackson@eu.citrix.com> References: <1450371968-27997-1-git-send-email-ian.jackson@eu.citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: Ian Jackson , Ian Campbell Subject: [Xen-devel] [OSSTEST PATCH 8/9] mg-allocate: Better error handling when no candidates X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Ian Campbell --- 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); }