README.dev: Document the blessings
PATCH 4/9 mg-schema-test-database: Borrow shares properly
In reply to Ian Jackson--- mg-schema-test-database | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
mg-schema-test-database +12 -2
@@ -448,12 +448,22 @@ END done # As we copy, we note everything we're not borrowing as - # belonging to the parent db. + # belonging to the parent db. We borrow shares of a shared + # resource. If we borrow only some rather than all of the + # shares, neither DB will be able to unshare it. + + # In principle it might be possible to actually use different + # shares of the same resource with different dbs. However the + # `sharetype' contains the osstest revision, which prevents + # sharing between test and real versions of osstest code. + cat >>$t.import <<END $(make_xdbref_task $maindbname 'not borrowed' '' PARENT) UPDATE resources SET owntaskid = $(taskid xdbref $maindbname) - WHERE owntaskid != $(borrowtaskid $task); + WHERE owntaskid != $(borrowtaskid $task) + AND owntaskid != $(taskid magic shared) + AND owntaskid != $(taskid magic preparing); COMMIT; END
Signature · 1 line
1.7.10.4
PATCH 1/9 README.dev: Document the blessings
--- README.dev | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+)
README.dev +101 -0
@@ -232,3 +232,104 @@ probably are after a reboot) by looking for processes relating to the lists flight,job combinations and then: $ ./mg-hosts previoustasks --clear + + +Flight blessings and the blessed-* host flags +============================================= + +Both flights and hosts have a `blessing'. + +Blessings are used: + + * To avoid accidentally tools operating on flights which are in the + wrong phase of their existence. + + * To control which automatic archaeologists will look at which + flights. (Archeaology tools take arguments to control which + blessings they will consider.) + + * To control which hosts are considered suitable for use with which + flight. (Flights with blessing `foo' use only hosts which have + flag `blessed-foo'.) + +Each flight has a `blessing' and an `intended blessing'. The +`intended blessing' is what the flight is going to be blessed as when +its execution has completed. The intended blessing controls host +allocation. + +(Normally the `intended blessing' is the same as the bless argument to +sg-execute-flight aka the -B argument to mg-execute-flight.) + +These are the principal (intended) blessings: + + * `real': Flights which are fully production runs. They use only + clean working trees with no `funny' environment variables, and + versions of osstest intended for production. The data from such + flights is used, where applicable, to control production push gate + decisions, etc. + + `blessed-real' hosts are fully production-ready. + + * `play': Playground. Flights may use weird software, dirty working + trees, strange environment variables, and so on. It does not make + sense to point archaeology tools at such flights. + + `blessed-play' hosts may be partially or completely nonfunctional, + or strange in some way. For this reason `play' flights should not + normally use the automatic host allocator. + + * `adhoc': Special-purpose flights. They should be run with software + nearly as clean as `real': the version of the software used may not + be a branch intended for-production, but any enhancements or + modifications should not leave false or misleading information in + the history database. + + `blessed-adhoc' hosts are just as good as `blessed-real' ones. + + The `adhoc' blessing exists mostly to protect the main production + workflow from unintentional violations (for example, unexpectedly + buggy historical flight data). + + * `commission-<something>': Flights used for testing that a + particular subset of the hosts are working properly. The hosts to + be tested should be blessed `commission-whatever' during + commissioning, and that blessing removed and replaced with `real' + when the hosts are ready. + + * `real-bisect' and `adhoc-bisect': These are found only as the + blessing of finished flights. (This is achieved by passing *-adhoc + to sg-execute-flight.) This allows the archaeologist tools to + distinguish full flights from bisection steps. + + The corresponding intended blessing (as found in the `intended' + column of the flights table) is `real'. So the hosts used by the + automatic host allocator are those flagged `blessed-real' or + `blessed-adhoc' - there are no separate blessed-*-bisect hostflags. + +There are also blessings for unfinished flights: + + * `constructing': The flight metadata (jobs, runvars, etc.) is still + being populated. The tools for flight construction (and flight + construct editing) generally insist that they operate only on + flights in this state. + + * `running': At least one of the jobs in this flight has started. + Flight execution software will generally (perhaps via standard + library calls) mark a flight `running' if they find it + `constructing', and refuse to operate on other flights. + + * `broken': Something went catastrophically wrong. + +Note that osstest is generally `crash-only software': nothing will +`clean up' a crashed flight and set its blessing to `broken'. Flights +which were in progress once upon a time but never completed, because +they crashed, are simply left with whatever blessing they had at the +time. + +There is a special exception to the tools' flight status checks: any +flight whose blessing contains `play' can be operated on out of order. + +Flights blessings can be manually changed with cs-flight-bless. Eg + ./cs-flight-bless FLIGHT broken-real real +updates FLIGHT to be marked `broken' rather than `real'. This can be +useful if a flight's data is misleading to the archaeologists.
Signature · 1 line
1.7.10.4
PATCH 3/9 mg-schema-test-database: Wipe previous local plan data
Whatever is in the user's cwd is unlikely to correspond to anything real. In principle it might be possible to obtain an official copy from the real daemons, and massage it, or something, but that's a lot of work.
Instead, just remove it when we start the test db daemons.
In principle it would be more correct to remove it when we set up the test db, because it is at that point that we create the new view of the world. Removing the old plan data when we start daemons means that if the user, who is testing, restarts the daemons, the newly-created queue daemon does not have information about allocations made with the previous daemon, and instead regards those allocations as rogue.
However, removing the file only when the daemons are started means that if the user has saved a data-plan.pl in their cwd for some other reason we don't remove it unless the user is actually going to run the daemons. So I think this is preferable.
--- mg-schema-test-database | 2 ++ 1 file changed, 2 insertions(+)
mg-schema-test-database +2 -0
@@ -553,6 +553,8 @@ daemons) withtest \ exec_resetting_sigint ./ms-queuedaemon & + rm -f data-plan.pl + wait ;;
Signature · 1 line
1.7.10.4
PATCH 5/9 ms-planner: Improve an error message
In reply to Ian JacksonI experienced this `die' due to mg-schema-test-database failing to borrow shared hosts properly, and added this Dumper for debugging.
I have not bothered to improve any of the other quite terse `die's in ms-planner.
--- ms-planner | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
ms-planner +3 -1
@@ -319,7 +319,9 @@ END my ($reso, $shareix) = ($`, $1); my $share= $currentshare{$reso}; - die unless !!$share == !!$shareix; + die Dumper($reskey, $reso, $shareix, + $plan->{Allocations}{$reskey}, $currentshare{$reso}) + unless !!$share == !!$shareix; if ($share && $share->{OnlyPreparing}) { delete $plan->{Allocations}{$reskey};
Signature · 1 line
1.7.10.4
PATCH 6/9 db_retry: Suppress an "exiting via last" warning
In reply to Ian JacksonThis warning appears when db_retry_abort is used, since 2b069b6c "Database locking: Perl: Retry all deadlocks in PostgreSQL".
--- Osstest.pm | 1 + 1 file changed, 1 insertion(+)
Osstest.pm +1 -0
@@ -299,6 +299,7 @@ sub db_retry ($$$;$$) { $r= &$body; if ($db_retry_stop) { $dbh->rollback(); + no warnings qw(exiting); last if $db_retry_stop eq 'abort'; next; }
Signature · 1 line
1.7.10.4
PATCH 7/9 Executive DB retry: Avoid an undefined warning
In reply to Ian JacksonIf something other than the DB statements inside need_retry throws an exception, ->err will normally be undef (because $dbh_tests->begin_work will clear it, if nothing else).
--- Osstest/JobDB/Executive.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Osstest/JobDB/Executive.pm +1 -1
@@ -50,7 +50,7 @@ sub begin_work ($$$) { #method sub need_retry ($$$) { my ($jd, $dbh,$committing) = @_; return - $dbh_tests->err()==7 && + ($dbh_tests->err() // 0)==7 && ($dbh_tests->state =~ m/^40P01/); # DEADLOCK DETECTED }
Signature · 1 line
1.7.10.4
PATCH 8/9 mg-allocate: Better error handling when no candidates
In reply to Ian JacksonSpot 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.
--- mg-allocate | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-)
mg-allocate +17 -7
@@ -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); }
Signature · 1 line
1.7.10.4
PATCH 9/9 mg-allocate: In planner mode, pre-check the arguments
In reply to Ian JacksonNow, attempting to allocate a nonexistent host fails immediately with a sensible message, rather than queueing up and then reporting the message only later:
mariner:testing.git> OSSTEST_CONFIG=/u/iwj/.xen-osstest/config:local-config.test-database_iwj ./mg-allocate -U 1h spong
2015-12-17 17:05:14 Z pre-checking resources (dry run)... 2015-12-17 17:05:14 Z (precheck) task 196916 static iwj@mariner: iwj@mariner manual
*** no candidates for spong! ***
mariner:testing.git>
--- mg-allocate | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
mg-allocate +12 -1
@@ -238,7 +238,8 @@ sub loggot { foreach @got; } -sub execute () { +sub execute (;$) { + my ($dryrun) = @_; my @got; db_retry($dbh_tests, \@all_lock_tables, sub {
@@ -259,10 +260,15 @@ sub execute () { } } + if ($dryrun) { + db_retry_abort(); + return; + } if (!$allok) { die "allocation/deallocation unsuccessful\n"; } }); + return if $dryrun; loggot(@got); logm("done."); }
@@ -388,6 +394,11 @@ while (@ARGV && $ARGV[0] =~ m/^[-0-9]/) { } if ($duration) { + { + logm("pre-checking resources (dry run)..."); + local $Osstest::TestSupport::logm_prefix = $logm_prefix.' (precheck)'; + execute(1); + }; plan(); } else { execute();
Signature · 1 line
1.7.10.4
PATCH 2/9 mg-schema-test-database: Provide some timeouts which are better for testing
In reply to Ian JacksonThe default timeouts mean that after starting a test db queue daemon and a test db allocation attempt, we have to wait two minutes.
Lower timeouts increase the risk that we might lose noncritical races and allocate resources to the `wrong' tasks. And they reduce the duration of an outage which will cause a planned allocation attempt to fail.
I think we don't care about those problems for test instances.
--- mg-schema-test-database | 2 ++ 1 file changed, 2 insertions(+)
mg-schema-test-database +2 -0
@@ -336,6 +336,8 @@ QueueDaemonHost $ctrlhost OwnerDaemonPort ${ctrlports%,*} QueueDaemonPort ${ctrlports#*,} ExecutiveDbOwningRoleRegexp .* +QueueDaemonHoldoff 3 +QueueDaemonRetry 5 END mv -f $tcfg.tmp $tcfg
Signature · 1 line
1.7.10.4
Quoted 19 lines · Ian Jackson
Signed-off-by Ian Jackson <[email protected]>---
README.dev | 101
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++1 file changed, 101 insertions(+)README.dev +0
-0@@ -232,3 +232,104 @@ probably are after a reboot) by looking forprocesses relating to the
lists flight,job combinations and then:$ ./mg-hosts previoustasks --clearREADME.dev +4
-0+ + +Flight blessings and the blessed-* host flags +=============================================
README.dev probably are after a reboot) by looking for processes relating to the · line 248
Quoted 10 lines
README.dev +10
-0+ +Both flights and hosts have a `blessing'. + +Blessings are used: + + * To avoid accidentally tools operating on flights which are in the + wrong phase of their existence. + + * To control which automatic archaeologists will look at which + flights. (Archeaology tools take arguments to control which
Archaeology
README.dev probably are after a reboot) by looking for processes relating to the · line 258
Quoted 10 lines
+ blessings they will consider.)
README.dev +9
-0+ + * To control which hosts are considered suitable for use with which + flight. (Flights with blessing `foo' use only hosts which have + flag `blessed-foo'.) + +Each flight has a `blessing' and an `intended blessing'. The +`intended blessing' is what the flight is going to be blessed as when +its execution has completed. The intended blessing controls host +allocation.
I think this could also usefully mention that blessing' is the current blessing, which may go through several phases during the life of the flight, hopefully culminating in being set to intended blessing' if the flight is successful and that the archaeology tools only look at blessing' and never intended blessing'
README.dev probably are after a reboot) by looking for processes relating to the · line 261
Quoted 2 lines
README.dev +2
-0+(Normally the `intended blessing' is the same as the bless argument to +sg-execute-flight aka the -B argument to mg-execute-flight.)
How does this interact with the intended blessing passed to cs-flight- create?
Quoted 4 lines
+ *
real-bisect' andadhoc-bisect': These are found only as the + blessing of finished flights. (This is achieved by passing *-adhoc + to sg-execute-flight.) This allows the archaeologist tools to + distinguish full flights from bisection steps.
I don't follow the reference to *-adhoc here, since it matches neither real-bisect' nor adhoc-bisect'.
README.dev probably are after a reboot) by looking for processes relating to the · line 334
Quoted 6 lines
README.dev +6
-0+There is a special exception to the tools' flight status checks: any +flight whose blessing contains `play' can be operated on out of order. + +Flights blessings can be manually changed with cs-flight-bless. Eg + ./cs-flight-bless FLIGHT broken-real real +updates FLIGHT to be marked `broken' rather than `real'. This can be
The example says broken-real' but the text says broken' (if the text didn't quote the `broken' it probably wouldn't matter.
Maybe mention the need to pass the current blessing as a safety catch, since it is part of the example command?
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [OSSTEST PATCH 2/9] mg-schema-test-database: Provide some timeouts which are better for testing
In reply to Ian JacksonQuoted 11 lines · Ian Jackson
The default timeouts mean that after starting a test db queue daemon and a test db allocation attempt, we have to wait two minutes.
Lower timeouts increase the risk that we might lose noncritical races and allocate resources to the `wrong' tasks. And they reduce the duration of an outage which will cause a planned allocation attempt to fail.
I think we don't care about those problems for test instances.
Signed-off-by Ian Jackson <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [OSSTEST PATCH 3/9] mg-schema-test-database: Wipe previous local plan data
In reply to Ian JacksonQuoted 15 lines · Ian Jackson
Whatever is in the user's cwd is unlikely to correspond to anything real. In principle it might be possible to obtain an official copy from the real daemons, and massage it, or something, but that's a lot of work.
Instead, just remove it when we start the test db daemons.
In principle it would be more correct to remove it when we set up the test db, because it is at that point that we create the new view of the world. Removing the old plan data when we start daemons means that if the user, who is testing, restarts the daemons, the newly-created queue daemon does not have information about allocations made with the previous daemon, and instead regards those allocations as rogue.
Quoted 6 lines
However, removing the file only when the daemons are started means that if the user has saved a data-plan.pl in their cwd for some other reason we don't remove it unless the user is actually going to run the daemons. So I think this is preferable.
Signed-off-by Ian Jackson <[email protected]>
Would it make sense to remove data-projection.pl too? I suppose it isn't consumed anywhere so is more or less harmless.
OOI do these test mode daemons do anything sensible with resource- {plan,projection}.html and summary.html? Looks like they would clobber things in $c{WebspaceFile}, which might be surprising to a user with two test instances on the go. But that's a pretty obscure corner case I suspect...
Quoted 14 lines
---
mg-schema-test-database | 2 ++1 file changed, 2 insertions(+)mg-schema-test-database +0
-0@@ -553,6 +553,8 @@ daemons) withtest \
exec_resetting_sigint./ms-queuedaemon &mg-schema-test-database +2
-0+ rm -f data-plan.pl +
Quoted 3 lines
wait
;;
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [OSSTEST PATCH 4/9] mg-schema-test-database: Borrow shares properly
In reply to Ian JacksonQuoted 13 lines · Ian Jackson
Signed-off-by Ian Jackson <[email protected]>---
mg-schema-test-database | 14 ++++++++++++--1 file changed, 12 insertions(+), 2 deletions(-)mg-schema-test-database +0
-0@@ -448,12 +448,22 @@ ENDdone
# As we copy, we note everything we're not borrowing as
mg-schema-test-database END · line 453
Quoted 4 lines
mg-schema-test-database +3
-1- # belonging to the parent db. + # belonging to the parent db. We borrow shares of a shared + # resource. If we borrow only some rather than all of the + # shares, neither DB will be able to unshare it.
This is what actually happens, rather than this comment explaining a thing we are avoiding, right?
I ask because although the text (and the use of "properly" in the subject) seems pretty clear it's the former I was surprised to find this code was borrowing partial shares and therefore setting up such a situation. Given the caveat below would it not be better to just never allow this? I suppose that given the list of tasks to borrow came from the user this might be considered a "keep both pieces" situation.
Quoted 14 lines
mg-schema-test-database +6
-0+ + # In principle it might be possible to actually use different + # shares of the same resource with different dbs. However the + # `sharetype' contains the osstest revision, which prevents + # sharing between test and real versions of osstest code. +cat >>$t.import <<END
$(make_xdbref_task $maindbname 'not borrowed' '' PARENT) UPDATE resources
SET owntaskid = $(taskid xdbref $maindbname)mg-schema-test-database +3
-1- WHERE owntaskid != $(borrowtaskid $task); + WHERE owntaskid != $(borrowtaskid $task) + AND owntaskid != $(taskid magic shared) + AND owntaskid != $(taskid magic preparing);
Quoted 3 lines
COMMIT;
END
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [OSSTEST PATCH 5/9] ms-planner: Improve an error message
In reply to Ian JacksonQuoted 7 lines · Ian Jackson
I experienced this `die' due to mg-schema-test-database failing to borrow shared hosts properly, and added this Dumper for debugging.
I have not bothered to improve any of the other quite terse `die's in ms-planner.
Signed-off-by Ian Jackson <[email protected]>
Re: [OSSTEST PATCH 6/9] db_retry: Suppress an "exiting via last" warning
In reply to Ian JacksonQuoted 2 lines · Ian Jackson
This warning appears when
db_retry_abortis used, since2b069b6c"Database locking: Perl: Retry all deadlocks in PostgreSQL".
Is the reason for not turning this into a return related to the fact this is within an eval, not a proper sub? But then I'm not really sure why it is warning (I suppose eval has some sub like properties?).
Related to https://rt.perl.org/Public/Bug/Display.html?id=29238 perhaps.
Quoted 10 lines
Signed-off-by Ian Jackson <[email protected]>---
Osstest.pm | 1 +1 file changed, 1 insertion(+)Osstest.pm +0
-0
Osstest.pm sub db_retry ($$$;$$) { · line 305
Quoted 7 lines
Osstest.pm +1
-0@@ -299,6 +299,7 @@ sub db_retry ($$$;$$) { $r= &$body; if ($db_retry_stop) { $dbh->rollback(); + no warnings qw(exiting); last if $db_retry_stop eq 'abort'; next; }
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [OSSTEST PATCH 7/9] Executive DB retry: Avoid an undefined warning
In reply to Ian JacksonQuoted 5 lines · Ian Jackson
If something other than the DB statements inside
need_retrythrows an exception, ->err will normally be undef (because $dbh_tests->begin_work will clear it, if nothing else).Signed-off-by Ian Jackson <[email protected]>
Quoted 14 lines
---
Osstest/JobDB/Executive.pm | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)Osstest/JobDB/Executive.pm +0
-0@@ -50,7 +50,7 @@ sub begin_work ($$$) { #method sub need_retry ($$$) { my ($jd, $dbh,$committing) = @_;return
Osstest/JobDB/Executive.pm +1
-1- $dbh_tests->err()==7 && + ($dbh_tests->err() // 0)==7 &&
Quoted 3 lines
($dbh_tests->state =~ m/^40P01/); # DEADLOCK DETECTED }
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [OSSTEST PATCH 8/9] mg-allocate: Better error handling when no candidates
In reply to Ian JacksonQuoted 16 lines · Ian Jackson
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 messagePreviously it would simply say `nothing available'.
Implement this as follows:
- Report lack of candidates as $ok=-1 fromalloc_1rescand
- Inalloc_1res, return this -1 as with any non-zero $ok
- Handle the new $ok at all the call sites, in particular
- Inplan(), renameallok' toworstok' and have it be the worst relevant $ok value. If $ok gives -1, return undef, rather than a booking list, to the allocator core.
Quoted 1 line
Signed-off-by Ian Jackson <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [OSSTEST PATCH 9/9] mg-allocate: In planner mode, pre-check the arguments
In reply to Ian JacksonQuoted 6 lines · Ian Jackson
Now, attempting to allocate a nonexistent host fails immediately with a sensible message, rather than queueing up and then reporting the message only later:
mariner:testing.git> OSSTEST_CONFIG=/u/iwj/.xen-osstest/config:local- config.test-database_iwj ./mg-allocate -U 1h spong
Quoted 7 lines
2015-12-17 17:05:14 Z pre-checking resources (dry run)... 2015-12-17 17:05:14 Z (precheck) task 196916 static iwj@mariner: iwj@mariner manual
*** no candidates for spong! ***
mariner:testing.git>Signed-off-by Ian Jackson <[email protected]>
Re: [OSSTEST PATCH 3/9] mg-schema-test-database: Wipe previous local plan data
In reply to Ian CampbellIan Campbell writes ("Re: [OSSTEST PATCH 3/9] mg-schema-test-database: Wipe previous local plan data"):
Quoted 1 line
Acked-by Ian Campbell <[email protected]>
Thanks.
Quoted 2 lines
Would it make sense to remove data-projection.pl too? I suppose it isn't consumed anywhere so is more or less harmless.
Precisely.
Quoted 5 lines
OOI do these test mode daemons do anything sensible with resource- {plan,projection}.html and summary.html? Looks like they would clobber things in $c{WebspaceFile}, which might be surprising to a user with two test instances on the go. But that's a pretty obscure corner case I suspect...
If you don't run it as the same user, this is not a problem, because the default WebspaceFile has $HOME in it. I guess it might be possible to have something check for this.
I would like to leave this for another day. I don't see us running test instances as the osstest user.
Ian.
Re: [OSSTEST PATCH 4/9] mg-schema-test-database: Borrow shares properly
In reply to Ian CampbellIan Campbell writes ("Re: [OSSTEST PATCH 4/9] mg-schema-test-database: Borrow shares properly"):
Quoted 9 lines · Ian Jackson
mg-schema-test-database END · line 453
Quoted 5 lines
# As we copy, we note everything we're not borrowing as
mg-schema-test-database +3
-1- # belonging to the parent db. + # belonging to the parent db. We borrow shares of a shared + # resource. If we borrow only some rather than all of the + # shares, neither DB will be able to unshare it.This is what actually happens, rather than this comment explaining a thing we are avoiding, right?
Yes.
Quoted 4 lines
I ask because although the text (and the use of "properly" in the subject) seems pretty clear it's the former I was surprised to find this code was borrowing partial shares and therefore setting up such a situation. Given the caveat below would it not be better to just never allow this?
I have added this to the commit message:
Previously, the test database would be generated in a broken state:
resources share-host/foo/{1,2,...} exist but the resource host/foo/0 is allocated to magic/xdbref rather than to magic/shared. This causes various resource allocation machinery to crash. (Even if the host is entirely un-borrowed.)
I guess it might be possible for mg-schema-test-database to check that either none or all of the shares of a host are being borrowed, but I don't think it's worth it. The osstest git hash in the sharetype will in practice mostly prevent undesirable sharing of the same resource between test and real db instances.
Quoted 2 lines
I suppose that given the list of tasks to borrow came from the user this might be considered a "keep both pieces" situation.
Yes. This partial sharing can only affect you if you have allocated individual shares to the task you say you want to borrow from.
Ian.
Re: [OSSTEST PATCH 3/9] mg-schema-test-database: Wipe previous local plan data
In reply to Ian JacksonQuoted 19 lines · Ian Jackson
Ian Campbell writes ("Re: [OSSTEST PATCH 3/9] mg-schema-test-database:
Wipe previous local plan data"):Quoted 1 line
Acked-by Ian Campbell <[email protected]>Thanks.
Quoted 3 lines
Would it make sense to remove data-projection.pl too? I suppose it isn't
consumed anywhere so is more or less harmless.Precisely.
Quoted 6 lines
OOI do these test mode daemons do anything sensible with resource- {plan,projection}.html and summary.html? Looks like they would clobber things in $c{WebspaceFile}, which might be surprising to a user with two
test instances on the go. But that's a pretty obscure corner case I suspect...
Quoted 2 lines
If you don't run it as the same user, this is not a problem, because the default WebspaceFile has $HOME in it.
Right, I should have been clearer, I meant clobber things in the user's WebspaceFile if they run two test instance at the same time.
Quoted 5 lines
I guess it might be
possible to have something check for this.I would like to leave this for another day. I don't see us running test instances as the osstest user.
In any case another day is fine, it's pretty obscure for sure.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [OSSTEST PATCH 6/9] db_retry: Suppress an "exiting via last" warning
In reply to Ian CampbellIan Campbell writes ("Re: [OSSTEST PATCH 6/9] db_retry: Suppress an "exiting via last" warning"):
Quoted 7 lines · Ian Jackson
Quoted 2 lines
This warning appears when
db_retry_abortis used, since2b069b6c"Database locking: Perl: Retry all deadlocks in PostgreSQL".Is the reason for not turning this into a return related to the fact this is within an eval, not a proper sub? But then I'm not really sure why it is warning (I suppose eval has some sub like properties?).
I think it's a warning because eval does not trap last's (nor return's). This means that if you think `eval' can be used to make try-finally, you will be disappointed.
(Unlike, in Tcl, say, where break' and continue' and indeed `return' are implemented as exceptions.)
Why would return' be better ? It would still generate the same warning. Leaving the loop via last' seems less heavyweight than using `return' and less likely to produce bugs in future patches whose authors don't spot the non-local exit.
Quoted 1 line
Related to https://rt.perl.org/Public/Bug/Display.html?id=29238 perhaps.
I don't think so, although there seems to be a fair amount of confusion there.
Ian.
Re: [OSSTEST PATCH 3/9] mg-schema-test-database: Wipe previous local plan data
In reply to Ian CampbellIan Campbell writes ("Re: [OSSTEST PATCH 3/9] mg-schema-test-database: Wipe previous local plan data"):
Quoted 6 lines · Ian Jackson
Quoted 2 lines
If you don't run it as the same user, this is not a problem, because the default WebspaceFile has $HOME in it.
Right, I should have been clearer, I meant clobber things in the user's WebspaceFile if they run two test instance at the same time.
Ah, right. I think the first person who wants to do that can do something to separate out the WebspaceFiles :-). It's not likely that you wouldn't notice that you had a problem.
Ian.
Ian Campbell writes ("Re: [OSSTEST PATCH 1/9] README.dev: Document the blessings"):
Quoted 11 lines · Ian Jackson
Review
Quoted 4 lines
(quoted diff) +4
-0+Each flight has a `blessing' and an `intended blessing'. The +`intended blessing' is what the flight is going to be blessed as when +its execution has completed. The intended blessing controls host +allocation.I think this could also usefully mention that
blessing' is the current blessing, which may go through several phases during the life of the flight, hopefully culminating in being set tointended blessing' if the flight is successful and that the archaeology tools only look atblessing' and neverintended blessing'
Yes.
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+(Normally the `intended blessing' is the same as the bless argument to +sg-execute-flight aka the -B argument to mg-execute-flight.)How does this interact with the intended blessing passed to cs-flight- create?
So actually there a flight has three blessings.
Quoted 7 lines
Quoted 4 lines
+ *
real-bisect' andadhoc-bisect': These are found only as the + blessing of finished flights. (This is achieved by passing *-adhoc + to sg-execute-flight.) This allows the archaeologist tools to + distinguish full flights from bisection steps.I don't follow the reference to *-adhoc here, since it matches neither
real-bisect' noradhoc-bisect'.
Passing *-adhoc' should read Passing *-bisect'.
Quoted 9 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+There is a special exception to the tools' flight status checks: any +flight whose blessing contains `play' can be operated on out of order. + +Flights blessings can be manually changed with cs-flight-bless. Eg + ./cs-flight-bless FLIGHT broken-real real +updates FLIGHT to be marked `broken' rather than `real'. This can beThe example says
broken-real' but the text saysbroken' (if the text didn't quote the `broken' it probably wouldn't matter.
I have clarified this.
Quoted 2 lines
Maybe mention the need to pass the current blessing as a safety catch, since it is part of the example command?
Yes.
squash! patch and complete v2, below.
Ian.
Quoted 1 line
From
73903500006c0451cc81697872096fe2d6fe02abMon Sep 17 00:00:00 2001
From: Ian Jackson <[email protected]>
Date: Thu, 17 Dec 2015 17:58:41 +0000
Subject: [OSSTEST PATCH] squash! README.dev: Document the blessings
v2: Improvements from review
--- README.dev | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-)
README.dev +24 -15
@@ -252,13 +252,17 @@ Blessings are used: flight. (Flights with blessing `foo' use only hosts which have flag `blessed-foo'.) -Each flight has a `blessing' and an `intended blessing'. The -`intended blessing' is what the flight is going to be blessed as when -its execution has completed. The intended blessing controls host -allocation. - -(Normally the `intended blessing' is the same as the bless argument to -sg-execute-flight aka the -B argument to mg-execute-flight.) +Each flight has a `blessing' (flights.blessing in the DB) and an +`intended blessing' (flights.intended). The `blessing' changes as the +flight goes through the stages of its lifecycle. The `intended +blessing' is roughly what the flight is going to be blessed as when +its execution has completed, and controls host allocation. + +There is also the blessing which the flight will actually get when it +is finished, which is not represented in the DB; rather, it is the +blessing argument to sg-execute-flight (aka the -B argument to +mg-execute-flight). Normally this is the same as the intended +blessing in the DB, except for bisection flights. These are the principal (intended) blessings:
@@ -297,9 +301,9 @@ These are the principal (intended) blessings: when the hosts are ready. * `real-bisect' and `adhoc-bisect': These are found only as the - blessing of finished flights. (This is achieved by passing *-adhoc - to sg-execute-flight.) This allows the archaeologist tools to - distinguish full flights from bisection steps. + blessing of finished flights. (This is achieved by passing + *-bisect to sg-execute-flight.) This allows the archaeologist + tools to distinguish full flights from bisection steps. The corresponding intended blessing (as found in the `intended' column of the flights table) is `real'. So the hosts used by the
@@ -320,6 +324,16 @@ There are also blessings for unfinished flights: * `broken': Something went catastrophically wrong. + * `broken-*': Conventionally set by hand when a flight needs to be + `un-blessed', perhaps because it contains data misleading to the + archaeologists. + + A flight's blessings can be manually changed with cs-flight-bless: + ./cs-flight-bless FLIGHT broken-real real + updates FLIGHT to be marked `broken' rather than `real'. + (cs-flight-bless matches the existing blessing against its final + argument, to avoid accidents.) + Note that osstest is generally `crash-only software': nothing will `clean up' a crashed flight and set its blessing to `broken'. Flights which were in progress once upon a time but never completed, because
@@ -328,8 +342,3 @@ time. There is a special exception to the tools' flight status checks: any flight whose blessing contains `play' can be operated on out of order. - -Flights blessings can be manually changed with cs-flight-bless. Eg - ./cs-flight-bless FLIGHT broken-real real -updates FLIGHT to be marked `broken' rather than `real'. This can be -useful if a flight's data is misleading to the archaeologists.
Signature · 1 line
1.7.10.4
Quoted 1 line
From
d677a8bfe576b44d28df4d5d62cbe9dec9fd5578Mon Sep 17 00:00:00 2001
From: Ian Jackson <[email protected]>
Date: Thu, 17 Dec 2015 16:51:17 +0000
Subject: [OSSTEST PATCH] README.dev: Document the blessings
---
v2: Improvements from review
--- README.dev | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+)
README.dev +110 -0
113 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Ian Campbell
Acked-byRe: [OSSTEST PATCH 4/9] mg-schema-test-database: Borrow shares properly
In reply to Ian JacksonQuoted 36 lines · Ian Jackson
Ian Campbell writes ("Re: [OSSTEST PATCH 4/9] mg-schema-test -database: Borrow shares properly"):
Quoted 4 lines · Ian Jackson
mg-schema-test-database END
Quoted 3 lines
mg-schema-test-database +1
-1# As we copy, we note everything we're not borrowing as - # belonging to the parent db. + # belonging to the parent db. We borrow shares of ashared
Quoted 1 line
Review
Quoted 1 line
(quoted diff) +1
-0+ # resource. If we borrow only some rather than all ofthe
Quoted 3 lines
mg-schema-test-database END · line 453
Quoted 1 line
mg-schema-test-database +1
-0+ # shares, neither DB will be able to unshare it.This is what actually happens, rather than this comment explaining
a thing
Quoted 1 line
we are avoiding, right?
Yes.
Quoted 4 lines
I ask because although the text (and the use of "properly" in the subject) seems pretty clear it's the former I was surprised to find this code was borrowing partial shares and therefore setting up such a situation. Given the caveat below would it not be better to just never allow this?
I have added this to the commit message:
Previously, the test database would be generated in a broken state:
resources share-host/foo/{1,2,...} exist but the resource host/foo/0 is allocated to magic/xdbref rather than to magic/shared. This causes various resource allocation machinery to crash. (Even if the host is entirely un-borrowed.)I guess it might be possible for mg-schema-test-database to check that either none or all of the shares of a host are being borrowed, but I don't think it's worth it. The osstest git hash in the sharetype will in practice mostly prevent undesirable sharing of the same resource between test and real db instances.
Quoted 5 lines
Quoted 2 lines
I suppose that given the list of tasks to borrow came from the user this might be considered a "keep both pieces" situation.
Yes. This partial sharing can only affect you if you have allocated individual shares to the task you say you want to borrow from.
Grand, with the extra commit log bit from above:
Re: [OSSTEST PATCH 6/9] db_retry: Suppress an "exiting via last" warning
In reply to Ian JacksonQuoted 16 lines · Ian Jackson
Ian Campbell writes ("Re: [OSSTEST PATCH 6/9]
db_retry: Suppress an "exiting via last" warning"):Quoted 5 lines · Ian Jackson
Quoted 2 lines
This warning appears when
db_retry_abortis used, since2b069b6c"Database locking: Perl: Retry all deadlocks in PostgreSQL".Is the reason for not turning this into a return related to the
fact this
Quoted 1 line
is within an eval, not a proper sub? But then I'm not really sure
why it is
Quoted 1 line
warning (I suppose eval has some sub like properties?).
I think it's a warning because eval does not trap
last's (norreturn's). This means that if you think `eval' can be used to make try-finally, you will be disappointed.
Quoted 8 lines
(Unlike, in Tcl, say, where
break' andcontinue' and indeed `return
are implemented as exceptions.)Why would
return' be better ? It would still generate the same warning. Leaving the loop vialast' seems less heavyweight than using `return' and less likely to produce bugs in future patches whose authors don't spot the non-local exit.
I think I'm probably confused about the scope of the eval vs {last,return} etc. In any case, that's no reason to block this patch
AFAICT: Acked-by: Ian Campbell <[email protected]>
Ian.
Quoted 8 lines
Quoted 2 lines
Related to
https://rt.perl.org/Public/Bug/Display.html?id=29238 perhaps.
I don't think so, although there seems to be a fair amount of confusion there.
Ian.
Re: [OSSTEST PATCH 3/9] mg-schema-test-database: Wipe previous local plan data
In reply to Ian JacksonQuoted 7 lines · Ian Jackson
Ian Campbell writes ("Re: [OSSTEST PATCH 3/9] mg-schema-test -database: Wipe previous local plan data"):
Quoted 2 lines · Ian Jackson
Quoted 1 line
If you don't run it as the same user, this is not a problem,
because
Quoted 2 lines
Quoted 1 line
the default WebspaceFile has $HOME in it.
Quoted 8 lines
Quoted 1 line
Right, I should have been clearer, I meant clobber things in the
user's
Quoted 1 line
WebspaceFile if they run two test instance at the same time.
Ah, right. I think the first person who wants to do that can do something to separate out the WebspaceFiles :-). It's not likely that
you wouldn't notice that you had a problem.
Agreed. Acked-by: Ian Campbell <[email protected]>
Ian Campbell
Acked-byQuoted 72 lines · Ian Jackson
Ian Campbell writes ("Re: [OSSTEST PATCH 1/9] README.dev: Document the blessings"):
Quoted 3 lines · Ian Jackson
Quoted 2 lines
+Each flight has a
blessing' and anintended blessing'. The +`intended blessing' is what the flight is going to be blessed aswhen
Quoted 1 line
Quoted 1 line
+its execution has completed. The intended blessing controls
host
Quoted 3 lines
Quoted 1 line
+allocation.
I think this could also usefully mention that `blessing' is the
current
Quoted 1 line
blessing, which may go through several phases during the life of
the
Quoted 1 line
flight, hopefully culminating in being set to `intended blessing'
if the
Quoted 1 line
flight is successful and that the archaeology tools only look at
`blessing'
Quoted 1 line
and never `intended blessing'
Yes.
Quoted 1 line
Quoted 1 line
+(Normally the `intended blessing' is the same as the bless
argument to
Quoted 3 lines
Quoted 1 line
+sg-execute-flight aka the -B argument to mg-execute-flight.)
How does this interact with the intended blessing passed to cs
-flight-
Quoted 1 line
create?
So actually there a flight has three blessings.
Quoted 2 lines
Quoted 2 lines
+ *
real-bisect' andadhoc-bisect': These are found only as the
+ blessing of finished flights. (This is achieved by passing *-adhoc
Quoted 1 line
Quoted 1 line
+ to sg-execute-flight.) This allows the archaeologist tools
to
Quoted 3 lines
Quoted 1 line
+ distinguish full flights from bisection steps.
I don't follow the reference to *-adhoc here, since it matches
neither
Quoted 1 line
real-bisect' noradhoc-bisect'.
Passing *-adhoc' should readPassing *-bisect'.Quoted 1 line
Quoted 1 line
+There is a special exception to the tools' flight status checks:
any
Quoted 1 line
Quoted 1 line
+flight whose blessing contains `play' can be operated on out of
order.
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ +Flights blessings can be manually changed with cs-flight-bless.Eg
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ ./cs-flight-bless FLIGHT broken-real real +updates FLIGHT to be marked `broken' rather than `real'. Thiscan be
Quoted 2 lines
The example says
broken-real' but the text saysbroken' (if thetext
Quoted 1 line
didn't quote the `broken' it probably wouldn't matter.
I have clarified this.
Quoted 1 line
Maybe mention the need to pass the current blessing as a safety
catch,
Quoted 1 line
since it is part of the example command?
Yes.
squash! patch and complete v2, below.
Ian.
Quoted 7 lines
From
73903500006c0451cc81697872096fe2d6fe02abMon Sep 17 00:00:00 2001
From: Ian Jackson <[email protected]>
Date: Thu, 17 Dec 2015 17:58:41 +0000
Subject: [OSSTEST PATCH] squash! README.dev: Document the blessingsv2: Improvements from review
Re: [OSSTEST PATCH 6/9] db_retry: Suppress an "exiting via last" warning
In reply to Ian CampbellIan Campbell writes ("Re: [OSSTEST PATCH 6/9] db_retry: Suppress an "exiting via last" warning"):
Quoted 9 lines · Ian Jackson
Quoted 4 lines
Why would
return' be better ? It would still generate the same warning. Leaving the loop vialast' seems less heavyweight than using `return' and less likely to produce bugs in future patches whose authors don't spot the non-local exit.I think I'm probably confused about the scope of the eval vs {last,return} etc. In any case, that's no reason to block this patch
AFAICT: Acked-by: Ian Campbell <[email protected]>
Thanks.
FYI, it's (eliding lots) like this:
sub db_retry ($$$;$$) {
for (;;) {
$pre->();
eval {
$r= &$body;
if ($db_retry_stop) {
no warnings qw(exiting);
last if $db_retry_stop eq 'abort';
next;
}
$dbh->commit();
};
last if !length $@;
}
return $r;
}The warning from perl is because when last if $db_retry_stop' happens, last' exits the eval in order to exit the outer for (;;) loop.
The same would apply for the next'. If there were any callers of db_retry_retry, they would trigger the next', which would exit the eval in order to restart the outer for.
Both of these are intentional. Perl thinks they might not be.
Thanks for all the acks. I'll maybe push this at some point, or combine it with something else. It's not urgent.
Ian.
Re: [OSSTEST PATCH 6/9] db_retry: Suppress an "exiting via last" warning
On Thu, 2015-12-17 at 18:38 +0000, Ian Jackson wrote:
Continuing purely for my own edification...
Quoted 19 lines
FYI, it's (eliding lots) like this:
sub
db_retry($$$;$$) {
for (;;) {
$pre->();
eval {
$r= &$body;
if ($db_retry_stop) {
no warnings qw(exiting); last if $db_retry_stop eq 'abort'; next;
}
$dbh->commit();
};
last if !length $@;
}
return $r;
}
Quoted 3 lines
The warning from perl is because when
last if $db_retry_stop' happens,last' exits the eval in order to exit the outer for (;;) loop.
Meaning that last (or next) will exit the eval and immediately end (or restart) the containing loop, in particular without executing the "last if !length $@;".
Quoted 1 line
Both of these are intentional. Perl thinks they might not be.
... and that's because it is a common enough mistake to think that next or last exits only the scope of the eval and therefore in this case to expect it to run "last if !length $@;", while it actually wont.
I would have expected that if you want to successfully exit (i.e. not die) the eval early and continue on with the remainder of the loop you should use return, and http://perldoc.perl.org/functions/eval.html seems to back that up ("the value returned is the value of the last expression evaluated inside the mini-program; a return statement may be also used,"), but earlier you said that return would generate the same warning, so I remain a bit confused.
According to my reading of eval.html "return if $db_retry_stop eq 'abort'" would exit the eval with $@="" ("If there was no error, $@ is set to the empty string", it mentions last and goto bypassing this, but not return). Then since length "" is false that outer last would be run insteadand we are done with the loop as we wanted. AFAICT that would avoid the warning for the inner last, but is not usable for the inner next, and in any case using last inside the eval is actually more obvious in this instance, once one thinks one understands an eval (which in my case is still debatable I think)
Ian.
Quoted 4 lines
Thanks for all the acks. I'll maybe push this at some point, or combine it with something else. It's not urgent.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [OSSTEST PATCH 6/9] db_retry: Suppress an "exiting via last" warning
Ian Campbell writes ("Re: [OSSTEST PATCH 6/9] db_retry: Suppress an "exiting via last" warning"):
Quoted 6 lines · Ian Jackson
Quoted 1 line
Both of these are intentional. Perl thinks they might not be.
... and that's because it is a common enough mistake to think that next or last exits only the scope of the eval and therefore in this case to expect it to run "last if !length $@;", while it actually wont.
Yes.
Quoted 7 lines
I would have expected that if you want to successfully exit (i.e. not die) the eval early and continue on with the remainder of the loop you should use return, and http://perldoc.perl.org/functions/eval.html seems to back that up ("the value returned is the value of the last expression evaluated inside the mini-program; a return statement may be also used,"), but earlier you said that return would generate the same warning, so I remain a bit confused.
Oh! I was confused about the effect of `return' in an eval. I expected it to exit past the eval and return out of the calling function.
Quoted 9 lines
According to my reading of eval.html "return if $db_retry_stop eq 'abort'" would exit the eval with $@="" ("If there was no error, $@ is set to the empty string", it mentions last and goto bypassing this, but not return). Then since length "" is false that outer last would be run insteadand we are done with the loop as we wanted. AFAICT that would avoid the warning for the inner last, but is not usable for the inner next, and in any case using last inside the eval is actually more obvious in this instance, once one thinks one understands an eval (which in my case is still debatable I think)
I still think this reasoning about return' is more fiddly than just saying last' or next' when we mean last' or `next'...
Particularly given that, now, there is a `no warnings qw(exiting)' to cue the reader that they may need to check the FM.
Ian.