Miscellaneous infrastructure fixes
cover Miscellaneous infrastructure fixes
This series contains a set of changes which probably ought to be force pushed; none of them would be properly tested by the self-push-gate.
The most important one is:
2/5 cs-bisection-step: Detect flailing
There's also a new doc:
1/5 README.planner: Document the resource planning
And a new script to help figure out where disk space is being used:
3/5 Logs: Break out logs_select etc. into new
4/5 cr-disk-report: New script
5/5 Docs (in new Docs directory) for cr-disk-report
The results of the latter can currently be found on the new colo VM here:
http://osstest.test-lab/~iwj/d/diskusage-Logs.html
http://osstest.test-lab/~iwj/d/diskusage-LogsPublish.html
Sadly they don't reveal anything particularly notable, and it looks like we simply need to increase the disk dedicated to the osstest VM.
PATCH 1/5 README.planner: Document the resource planning system
--- README.planner | 181 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 180 insertions(+), 1 deletion(-)
README.planner +180 -1
@@ -1,4 +1,183 @@ -Resource planner / scheduler +RESOURCE PLANNER (IE SCHEDULER) +=============================== + +Overall architecture +-------------------- + +Resources (eg hosts) are owned by `tasks'. As resources are allocated +and deallocated, their `owntaskid' in the database is updated. + +When a process wishes to allocate resources, it does as follows: + + - Select an appropriate task. For command-line use, the user@host + static task usually used (as specified by the OSSTEST_TASK env var) + and things fail if it doesn't actually exist. + + Automatic runs create a new ownd task for each job (in become-task + in JobDB-Executive.tcl, in sg-run-job. + + - Connect to the queue daemon and participate in the planning + process. + + +Planning +-------- + +The queue daemon sequences the planning of resource use and the +allocation of resources. This is done in a periodic planning cycle. +Planning cycles are prompted by newly available resources, new +requests for participation, and periodically. + +During each planning cycle we construct, from scratch, a complete plan +for which resources are to be used, when, by which tasks. Resources +which are free and suitable for allocation right away are planned and +allocated for immediate use. + +But, the plan extends far enough into the future to cover all +currently-foreseeable requirements for resources. This provides the +planning algorithms the most complete information about available +tradeoffs, and also provides useful output (the resource plan) for +administrators and users. + +Each planning cycle starts with the existing allocated resources. The +planning daemon records (on disk, not in the database) what expected +duration was declared with each of those allocations. (A task that +has allocated the resources it needs does not any longer participate +in the planning process, although it will retain a liveness connection +to the ms-ownerdaemon.) + +Then each interested client of ms-queuedaemon is asked - one by one, +in turn - to fill into the plan-under-construction, what resources it +intends to uses when. Clients specify the expected duration of their +use (but there is no mechanism for enforcing accuracy of these +estimates). ms-queuedaemon collates and records the provided +information and passes it on to the next client. + +If there are resources which are available right now which a client +wants to use, the client will allocate it there and then during its +planning slot. + +The queueing order is determined by the job priority value. Each +client declares its own priority. The usual basis for the priority is +is client's starting time_t. So by and large jobs execute in order. + +The main client in the planning process is +ts-hosts-allocate-Executive. That program contains the heuristics for +choosing good tests hosts under various conditions. + +Command-line users can use mg-allocate -U to obtain resources through +the planning process. mg-allocate participates with a high queue +priority so that command-line allocations will take precedence over +automatic test runs. (mg-allocate without -U bypasses the planner and +can be used to `grab' resources which happen currently to be free.) + +The distinction between `idle' and `allocatable' resources exists so +that newly-freed resources are properly offered first to the tasks at +the front of the queue. ms-ownerdaemon sets all idle resources to +allocatable at the start of each planning cycle. + + +ms-ownerdaemon and `ownd' tasks +------------------------------- + +ms-ownerdaemon helps with cleanup and does nothing else. Test runs +connect to it and obtain ephemeral `task' ids. All of the processes +which are part of the the test run retain a descriptor onto the +socket connection to ms-ownerdaemon. When the last holder of a copy +of the socket connection fd dies, ms-ownerdaemon sees the connection +close. It then sets the task to `not live' in the database. + +This means that there is no need for any explicit cleanup: tasks +which just crash have their resources freed automatically. + +If the ms-ownerdaemon fails and is restarted, the tasks which were +clients of the previous ms-owerdaemon cannot be automatically cleaned +up. The new ms-ownerdaemon will annotate them with `previous'. The +administrator can then clean them up manually, if she knows that all +the corresponding actual processes are no longer running. + + +Types of task +------------- + + * static tasks. Usual for command-line use. They are manually + created (with ./mg-hosts manual-task-create) and not normally ever + destroyed. + + * `ownd' tasks. These are used for production runs from cron and + some other mostly-automatic invocations of osstest (eg + mg-execute-flight). They are automatically created and destroyed - + see above. + + * magic task numbers with special meanings: + + magic/allocatable + + The resource is free and a process which is participating in + the planning process may allocate it to themselves by updating + the `owntaskid' in the resources table to refer to their own + task. + + magic/idle + + The resource is free but has perhaps only recently become so. + It can be allocated outside the planning process, but proceses + participating in planning should regard the resource as + unavailable. + + magic/shared + + The resource has been divided into shares. It is unavailable + in its own right without being unshared first. The individual + shares have their own owners. + + magic/preparing + + Applies only to shares of a divided resource. The share is + unavailable because the process handling the division is still + putting the resource into the proper state implied by the + sharing information (see below). + + +Sharing +------- + +Hosts can be shared between multiple clients. The first client to +decide to set up a host for sharing: + + - `Divides' the resource in the database + * allocates the host to the taskid `shared' and creates a set + of new rows in the resources table to represent the shares + (the number of shares is fixed at this point) + * initially, sets all but one of those shares to be owned by + magic/preparing + * sets the remaining share to be owned by itself + - Performs whatever actions are necessary to get the host into + a suitable state for it and others to use it (eg, installing + the OS) + - Sets the remaining shares to `idle' so that others can allocate + them + +(During planning - ie, for resources not yet available immediately - +the intent to do this can be part of the plan so that other tasks can +see and take account of it. The time necessary for preparing the host +is not currently modelled during planning.) + +Likewise a process which finds a shared resource completely idle can +unshare it. That is: + * Check that all the shares are allocatable + * Delete all the rows representing the shares + * Claim ownership of the main resource by changing the owntaskid + from `shared' to the process's own task. + +Shared resources also have a `wear' counter, which is there to arrange +that shared systems get regrooved occasionally even if nothing decides +to unshare them. + + + +DETAILED PROTOCOL NOTES +======================= ms-queuedaemon commands
Signature · 1 line
1.7.10.4
PATCH 2/5 cs-bisection-step: Detect flailing
In reply to Ian JacksonSpecifically, search for previous identical flights (on the same branch with the relevant blessings). Here `identical' means it has exactly the same set of runvars (and, hence, the same set of jobs, assuming each job has at least one runvar).
This detects various forms of looping which aren't stopped any other way.
Specifically, one relevant situation occurs if attempts to build revision (A,B,C) actually build (A,B,C') due to bugs in the build machinery (which could be bugs in osstest or in the software under test). In this case the bisector would never spot its previous attempts as relevant; instead, it would disregard them due to the mismatched versions. It would then retry the same version, until something happened to stop it.
As written here, we do not consider osstest revision as a relevant factor in `identical'. So if reason for the looping is a bug in osstest we would need to manually un-bless affected flights, as well as removing the stamp files which are used to record completion of attempted bisection.
--- cs-bisection-step | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 1 deletion(-)
cs-bisection-step +95 -1
@@ -1200,8 +1200,99 @@ END $addhost->execute($popflight, $job, $`, $'); # ' } }); +} + +sub checkrepetition () { + return unless $popflight && defined $choose; + + # Repetition check: check that there are not too many recent + # identical flights on this branch. We do this in a separate + # transaction so that we leave the broken flight in the database + # for debugging purposes. + + my $runvarsqt= sub { + return + "(SELECT job,name,val FROM runvars". + " WHERE runvars.flight=$_[0] AND NOT synth)"; +END + }; + + my $maxequalflights = 4; + + my $runvarsqt1 = $runvarsqt->('?'); + my $runvarsqt2 = $runvarsqt->('flights.flight'); + + # The SELECT 1 subquery looks for differing runvars: the two inner + # subqueries fetch all the runvars for the two flights to be + # compared and then the full outer join produces a complete list + # of all mentioned runvars (identified by (job,name)) with their + # values in each flight. The IS NOT TRUE is there so that when + # one side is NULL (runvar was missing) it still counts. + my $equalflightsqt = <<END; + SELECT flight, blessing, started FROM flights + WHERE branch=? AND $blessingscond $maxflight_cond + AND NOT EXISTS ( + SELECT 1 + FROM $runvarsqt1 r1 FULL OUTER JOIN + $runvarsqt2 r2 + USING (job,name) + WHERE (r1.val = r2.val) IS NOT TRUE + ) + AND flight >= ? + ORDER BY flight DESC + LIMIT $maxequalflights + 1; +END + + print DEBUG "equalflightsq:\n$equalflightsqt"; + my $equalflightsq = $dbh_tests->prepare($equalflightsqt); - print STDERR "Flight $popflight ready to go.\n"; + db_retry($popflight,'constructing', $dbh_tests,[qw(flights)], sub { + print STDERR "Checking for flail...\n"; + + my ($minflight) = $dbh_tests->selectrow_array(<<END, {}, $branch); + SELECT flight FROM ( + SELECT flight FROM flights + WHERE branch=? AND $blessingscond $maxflight_cond + ORDER BY flight DESC + LIMIT 100 + ) last100 ORDER BY FLIGHT ASC LIMIT 1 +END + $minflight //= 0; + print DEBUG "minflight=$minflight\n"; + + $equalflightsq->execute($branch, $popflight, $minflight); + my $nequalflights = 0; + my $explanation = ''; + while (my $identical = $equalflightsq->fetchrow_hashref()) { + $explanation .= sprintf + " %s started %s blessed %s\n", + $identical->{flight}, + show_abs_time($identical->{started}), + $identical->{blessing}; + $nequalflights++; + } + chomp $explanation; + print DEBUG "nequalflights=$nequalflights\n$explanation\n"; + if ($nequalflights > $maxequalflights) { + summary_report(<<END, <<END, 32); +Flailing - >$nequalflights identical flights to no useful effect +END +Bisector is flailing: >$nequalflights identical flights generated. +Perhaps machinery for building correct version is broken ? +Problem occurs when attempting to test this revision: + $choose->{Rtuple} + +Identical previous flights on this branch: +$explanation + $popflight just generated +END + $choose = undef; + + $dbh_tests->do(<<END, {}, $popflight); + UPDATE FLIGHTS SET blessing='broken' WHERE flight=? +END + } + }); } sub compute_exitstatus () {
@@ -1226,4 +1317,7 @@ consolidateresults(); search(); writegraph(); populateflight(); +checkrepetition(); +print STDERR "Flight $popflight ready to go.\n" + if $popflight && defined $choose; compute_exitstatus();
Signature · 1 line
1.7.10.4
PATCH 3/5 Logs: Break out logs_select etc. into new Osstest::Management
In reply to Ian JacksonWe are going to want to reuse these minor bits of cr-ensure-disk-space. Break them out into a new perl module.
We also need to rename some things to make them have names more suitable for a wider namespace, even if only selectively exported:
* @logsshopts from @sshopts (it is not the same variable as Osstest::TestSupport::sshopts).
* $loghost and $logdir from $pubhost and $pubdir).
* onloghost from ontarget.
* logcfg from dircfg.
--- Osstest/Management.pm | 72 +++++++++++++++++++++++++++++++++++++++++++++++++ cr-ensure-disk-space | 42 +++++++---------------------- 2 files changed, 81 insertions(+), 33 deletions(-) create mode 100644 Osstest/Management.pm
Osstest/Management.pm new file +72 -0
@@ -0,0 +1,72 @@ +# This is part of "osstest", an automated testing framework for Xen. +# Copyright (C) 2009-2013 Citrix Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + + +package Osstest::Management; + +use strict; +use warnings; + +use Osstest; + +BEGIN { + use Exporter (); + our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); + $VERSION = 1.00; + @ISA = qw(Exporter); + @EXPORT = qw( + ); + %EXPORT_TAGS = ( + 'logs' => [qw(logs_select onloghost logcfg + $logcfgbase $loghost $logdir @logsshopts)] + ); + + @EXPORT_OK = qw(); + + Exporter::export_ok_tags(qw(logs)); +} + +our ($logcfgbase, $loghost, $logdir); +our @logsshopts= qw(-o batchmode=yes); + +sub logs_select ($) { + ($logcfgbase) = @_; + my $cfgvalue = $c{$logcfgbase}; + return 0 unless $cfgvalue; + if ($cfgvalue =~ m/\:/) { + ($loghost, $logdir) = ($`,$'); #'); + } else { + ($loghost, $logdir) = (undef, $cfgvalue); + } + return 1; +} + +sub onloghost ($) { + my ($shellcmd) = @_; + # returns list to run that command + if (defined $loghost) { + return qw(ssh -n), @logsshopts, $loghost, $shellcmd; + } else { + return qw(sh -ec), $shellcmd; + } +} + +sub logcfg ($) { + my ($k) = @_; + return $c{"${logcfgbase}${k}"} // $c{"Logs${k}"}; +} + +1;
cr-ensure-disk-space +9 -33
83 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH 4/5 cr-disk-report: New script
In reply to Ian JacksonThis generates a report on the disk usage in the logs directory.
--- .gitignore | 2 + cr-disk-report | 336 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 338 insertions(+) create mode 100755 cr-disk-report
.gitignore +2 -0
@@ -28,3 +28,5 @@ id_rsa_osstest id_rsa_osstest.pub overlay-local images +diskusage-[A-Z]*.html +diskusage-[A-Z]*.png
cr-disk-report new file +336 -0
336 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH 5/5 Docs (in new Docs directory) for cr-disk-report
In reply to Ian JacksonThe PDF is automatically generated and linked to, when applicable.
--- .gitignore | 2 + .../diskusage-LogsPublish_build=2damd64_.png | Bin 0 -> 154 bytes Docs/cr-disk-report/graph-meaning.fig | 40 ++++++++++++++++++++ cr-disk-report | 17 ++++++++- 4 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 Docs/cr-disk-report/diskusage-LogsPublish_build=2damd64_.png create mode 100644 Docs/cr-disk-report/graph-meaning.fig
.gitignore +2 -0
@@ -1,4 +1,5 @@ *~ +*.bak tmp bisection.ps bisection.dot
@@ -30,3 +31,4 @@ overlay-local images diskusage-[A-Z]*.html diskusage-[A-Z]*.png +diskusage-[A-Z]*.pdf
Docs/cr-disk-report/diskusage-LogsPublish_build=2damd64_.png new file binary +0 -0
Docs/cr-disk-report/graph-meaning.fig new file +40 -0
@@ -0,0 +1,40 @@ +#FIG 3.2 Produced by xfig version 3.2.5b +Landscape +Center +Metric +A4 +100.00 +Single +-2 +1200 2 +2 5 0 1 0 -1 50 -1 -1 0.000 0 0 -1 0 0 5 + 0 diskusage-LogsPublish_build=2damd64_.png + 5805 3870 10797 3870 10797 5867 5805 5867 5805 3870 +2 1 0 1 0 7 40 -1 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 10845 6570 5805 6570 +2 1 0 1 0 7 40 -1 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3690 6210 3825 5850 +2 1 0 1 0 7 40 -1 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3195 3285 3600 4140 +2 1 0 1 0 7 40 -1 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 7875 3465 7875 3735 +4 0 0 50 -1 16 40 0.0000 4 480 1500 3510 5670 1153\001 +4 0 0 50 -1 17 40 0.0000 4 480 1875 3105 4725 75242\001 +4 0 0 40 -1 0 24 0.0000 4 270 1500 1890 3105 Total Kb\001 +4 0 0 40 -1 0 24 0.0000 4 360 1875 1935 6570 No. of jobs\001 +4 0 0 40 -1 0 24 0.0000 4 270 810 10620 6480 Now\001 +4 0 0 40 -1 0 24 0.0000 4 270 870 7200 6885 Time\001 +4 0 0 40 -1 0 24 0.0000 4 270 690 9180 6435 Min\001 +4 0 0 40 -1 0 24 0.0000 4 360 1110 9180 6900 Expire\001 +4 0 0 40 -1 0 24 0.0000 4 360 690 9180 7365 Age\001 +4 0 0 40 -1 0 24 0.0000 4 360 4185 6390 3420 Cumulative usage by age\001 +4 0 0 40 -1 0 24 0.0000 4 270 5565 1170 8280 Horizontal scales are all the same\001 +4 0 0 40 -1 0 24 0.0000 4 360 3180 1170 9660 - column headings\001 +4 0 0 40 -1 0 24 0.0000 4 360 2580 1170 10125 - row headings\001 +4 0 0 40 -1 0 24 0.0000 4 360 5700 1170 10590 - overall total (group all by itself)\001 +4 0 0 40 -1 0 24 0.0000 4 360 5325 1170 11055 - individual cells in many body\001 +4 0 0 40 -1 0 24 0.0000 4 360 9495 1170 9195 Vertical scales are the same within the following groups:\001
cr-disk-report +16 -1
@@ -313,7 +313,22 @@ push @o, $g; push @o, $g foreach @cols; push @o, "\n"; -prow(headcell('[<em>MiB</em><br>count]'), +my $headcell = '[<em>MiB</em><br>count]'; +if ($graphs_px) { + my $meaning_pdf = $output; + $meaning_pdf =~ s/\.html?$//i; + $meaning_pdf .= "_graph-meaning.pdf"; + open STDOUT, ">", "$meaning_pdf.tmp" or die "$meaning_pdf $!"; + $?=0; $!=0; + system 'cd Docs/cr-disk-report && fig2dev -L pdf graph-meaning.fig' + and die "$? $!"; + open STDOUT, ">/dev/null" or die $!; + rename "$meaning_pdf.tmp", "$meaning_pdf" or die "$meaning_pdf $!"; + $meaning_pdf =~ s#.*/##; + $headcell = "<a href='$meaning_pdf'>$headcell</a>"; +} + +prow(headcell($headcell), cheadcell('Branch / blessing'), map { cheadcell(encode_entities($_)) } @cols); prowdata('', headcell('Job'), spcell(\%totalinfo, '','',$totaldata),
Signature · 1 line
1.7.10.4