From patchwork Wed Jul 6 15:31:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 9216523 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E3EA4607D9 for ; Wed, 6 Jul 2016 15:34:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D506A2684F for ; Wed, 6 Jul 2016 15:34:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C955E26AE3; Wed, 6 Jul 2016 15:34:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 20EFF2684F for ; Wed, 6 Jul 2016 15:34:23 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKonp-0006Nt-W4; Wed, 06 Jul 2016 15:31:53 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKonn-0006NZ-VS for xen-devel@lists.xenproject.org; Wed, 06 Jul 2016 15:31:52 +0000 Received: from [85.158.139.211] by server-10.bemta-5.messagelabs.com id C6/4C-12215-7642D775; Wed, 06 Jul 2016 15:31:51 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupikeJIrShJLcpLzFFi42JxWrrBXjdNpTb c4NZRM4vvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPv1ja2gsMaFT8/FDQwTpXvYuTkkBDwl7j/ bjYjiM0moCvRtOUvWxcjB4eIgIrE7b0GIGFmgRKJxbumsIOEhQUiJCZMMAAxWYAq/t4QAangF fCU+PHhPhPEQDmJ88d/MoPYnAJeEqt2LGcBsYWAal69us0M0iokoCYxd308RKugxMmZT1ggFk lIHHzxAqxEQoBb4m+3/QRGvllIqmYhqVrAyLSKUb04tagstUjXQi+pKDM9oyQ3MTNH19DAVC8 3tbg4MT01JzGpWC85P3cTIzCMGIBgB+PBZudDjJIcTEqivCzfqsOF+JLyUyozEosz4otKc1KL DzHKcHAoSfCKKteGCwkWpaanVqRl5gADGiYtwcGjJML7WgkozVtckJhbnJkOkTrFqCglznsDJ CEAksgozYNrg0XRJUZZKWFeRqBDhHgKUotyM0tQ5V8xinMwKgnzXgSZwpOZVwI3/RXQYiagxT 9dqkEWlyQipKQaGKtd+XPMmBZdExX4ferdxXzbnS9Xb67reCS0S3Xvhq2REetkvXZuetW84t9 UbnGv6FoX9SiWzddXq35j9goUnVu8lP1/Z4K76csmoerHq3zVWheUseV137XfcT93hlJ6zoXL yaVnz0SXHKn7diJg35e6OLfC44IZipO59hdHL1EuvlOZ/dWcX4mlOCPRUIu5qDgRAOxuh26dA gAA X-Env-Sender: prvs=98829954f=Ian.Jackson@citrix.com X-Msg-Ref: server-13.tower-206.messagelabs.com!1467819106!33149535!3 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 11265 invoked from network); 6 Jul 2016 15:31:50 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-13.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 6 Jul 2016 15:31:50 -0000 X-IronPort-AV: E=Sophos;i="5.28,319,1464652800"; d="scan'208";a="371579377" From: Ian Jackson To: Date: Wed, 6 Jul 2016 16:31:13 +0100 Message-ID: <1467819074-16310-8-git-send-email-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1467819074-16310-1-git-send-email-ian.jackson@eu.citrix.com> References: <1467819074-16310-1-git-send-email-ian.jackson@eu.citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: Wei Liu , Ian Jackson Subject: [Xen-devel] [OSSTEST PATCH 7/8] ts-hosts-allocate-Executive: Support diverse-CLASS hostflag X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Specifically: * Parse it out of the hostflags when constructing the hid * Look for the `hostalloc-diverse-FLIGHT-CLASS' ClientNote in the resource plan, to avoid inappropriately planning to reuse hosts. * Look for the `diversehosts_CLASS' runvar in other jobs in this flight, to find out who might have allocated with the same CLASS. (This sort of duplicates information in *hostflags and *host, but digging the information out of the latter two would be very tiresome.) * Check each of the above for each candidate host. * Set the ClientNote when we are preparing a booking. * Set the runvar when we do the allocation. * Document the ClientNote. Signed-off-by: Ian Jackson CC: Wei Liu --- README.planner | 3 +++ ts-hosts-allocate-Executive | 59 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/README.planner b/README.planner index 80c2506..bb18432 100644 --- a/README.planner +++ b/README.planner @@ -335,3 +335,6 @@ Note key name (key in ClientNotes): Note value format: (none yet defined) + +hostalloc-diverse-- + { => 'info for debug', ... } diff --git a/ts-hosts-allocate-Executive b/ts-hosts-allocate-Executive index d4a96d5..72283de 100755 --- a/ts-hosts-allocate-Executive +++ b/ts-hosts-allocate-Executive @@ -213,7 +213,7 @@ sub compute_hids () { our %equivs; foreach my $ident (@ARGV) { - my $hid= { Conds => { host => [] } }; + my $hid= { Conds => { host => [] }, Diverse => [] }; my $override_use; if ($ident =~ m/\=/) { $hid->{OverrideUse}= $'; #' @@ -251,6 +251,11 @@ sub compute_hids () { my $equiv= $hid->{Equiv}= $equivs{$formalclass}; print DEBUG "HID $ident FLAG $flag EQUIV $equiv->{Wanted}\n"; next; + } elsif ($flag =~ m/^diverse-/) { + my $dclass= $'; #' + push @{ $hid->{Diverse} }, $dclass; + print DEBUG "HID $ident FLAG $flag DIVERSE $dclass\n"; + next; } elsif ($flag =~ m/^\w+:/) { my (@c) = split /:/, $flag; my $o; @@ -322,9 +327,40 @@ END LIMIT 1; END + # we are looking for other jobs where the runvar diversehosts_CLASS + # (a space-separated list of hostnames) has been set + my $diverseq = $dbh_tests->prepare(<{Diverse} }) { + print DEBUG "HID $hid->{Ident} DIVERSE $dclass:"; + # look for allocated + $diverseq->execute($flight, "diversehosts_$dclass"); + my ($djob, $dhosts) = $diverseq->fetchrow_array(); + my $excl = sub { + my ($dh,$why) = @_; + print DEBUG " $dh ($why)"; + $diverse_excluded{$dclass}{$dh} = $why; + }; + if (defined $dhosts) { + $excl->($_, "alloc'd job $job") foreach split / /, $dhosts; + } + # look for booked + my $notekey = "hostalloc-diverse-$flight-$dclass"; + my $booked = $plan->{ClientNotes}{$notekey}; + $excl->($_, "boooked ".$booked->{$_}) foreach sort keys %$booked; + print DEBUG ".\n"; + } + CANDIDATE: while (my $candrow= $findhostsq->fetchrow_hashref()) { $candrow->{Warnings}= [ ]; @@ -375,6 +411,13 @@ END "specified host lacks flags @missingflags"; } + foreach my $dclass (@{ $hid->{Diverse} }) { + my $excl = $diverse_excluded{$dclass}{ $candrow->{resname} }; + next unless defined $excl; + print DEBUG "$dbg excluded by diverse-$dclass ($excl)\n"; + next CANDIDATE unless defined $use; + } + foreach my $c (@{ $hid->{Conds}{$candrow->{restype}} }) { if (!$c->check($candrow->{restype}, $candrow->{resname})) { print DEBUG "$dbg failed $c condition\n"; @@ -629,6 +672,13 @@ sub alloc_hosts () { my $use= $r{ $hid->{Ident} }; next if defined $use; store_runvar($hid->{Ident}, $sel->{resname}); + foreach my $dclass (@{ $hid->{Diverse} }) { + my $drk = "diversehosts_$dclass"; + my %dused; + $dused{$_} = 1 foreach split / /, ($r{$drk} // ''); + $dused{$sel->{resname}} = 1; + store_runvar($drk, join ' ', sort keys %dused); + } } logm("host allocation: all successful and recorded."); @@ -697,6 +747,7 @@ sub attempt_allocation { sub compute_booking_list () { my @bookings; + my %cnotes; foreach my $hid (@hids) { my $sel= $hid->{Selected}; my $alloc= $hid->{Allocated}; @@ -712,8 +763,12 @@ sub compute_booking_list () { $book->{Start}= $best->{Start}; $book->{End}= $best->{Start} + $best->{Duration}; push @bookings, $book; + foreach my $dclass (@{ $hid->{Diverse} }) { + my $notekey = "hostalloc-diverse-$flight-$dclass"; + $cnotes{$notekey}{$sel->{resname}} = "$job $hid->{Ident}"; + } } - return { Bookings => \@bookings }; + return { Bookings => \@bookings, ClientNotes => \%cnotes }; } #---------- actually allocate things ----------