cs-adjust-flight: Add jobs-rename command which applies a perlop to job names
PATCH v2 1/1 cs-adjust-flight: Add jobs-rename command which applies a perlop to job names
My intention was to allow creation of adhoc jobs based on a template but modified e.g. to enable/disable XSM with a sequence something like:
./cs-adjust-flight $flight copy-jobs $template test-foo-xsm ./cs-adjust-flight $flight jobs-rename test-foo-xsm 's/-xsm$//' ./cs-adjust-flight $flight runvar-set $job enable_xsm false ./cs-adjust-flight ... update %buildjob
---
v2: s/job-rename/jobs-rename/
I left job-status alone.
--- cs-adjust-flight | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
cs-adjust-flight +24 -0
@@ -18,6 +18,7 @@ # intended-blessing <intended-blessing> # branch-set <new-branch> # job-status <job-spec> +# jobs-rename <job-spec> <perl-expr> # # <foo-spec>: # <foo-name>
@@ -371,6 +372,29 @@ END }); } +sub change__jobs_rename { + die unless @changes >= 2; + my $jobs = shift @changes; + my $perlop = shift @changes; + + my $jobq = $dbh_tests->prepare(<<END); + UPDATE jobs + SET job = ? + WHERE flight = ? AND job = ? +END + my $runvarq = $dbh_tests->prepare(<<END); + UPDATE runvars + SET job = ? + WHERE flight = ? AND job = ? +END + for_jobs($dstflight, $jobs, sub { + my ($oldjob) = @_; + my $newjob = perlop_value ($oldjob, '', $perlop, $oldjob); + print "$oldjob renamed to $newjob\n"; + $jobq->execute($newjob, $dstflight, $oldjob); + $runvarq->execute($newjob, $dstflight, $oldjob); + }) +} sub changes () { debug("CHANGES...\n");
Signature · 1 line
2.6.1
Ian Campbell writes ("[PATCH OSSTEST v2] cs-adjust-flight: Add jobs-rename command which applies a perlop to job names"):
Quoted 3 lines
My intention was to allow creation of adhoc jobs based on a template but modified e.g. to enable/disable XSM with a sequence something like:
...
Quoted 2 lines
Signed-off-by Ian Campbell <[email protected]>Acked-by Ian Jackson <[email protected]>
I know I acked this, and my next observations don't mean we shouldn't apply it as-is, but:
cs-adjust-flight END · line 384
Quoted 4 lines
cs-adjust-flight +4
-0+ UPDATE jobs + SET job = ? + WHERE flight = ? AND job = ? +END
This can be applied to flights in intended blessing play' in blessings later than constructing', or via `running:F' to running flights.
And if that happens, there might be entries in the steps table which ought also to be renamed. If you don't rename them you will trip the foreign key constraint.
I think a similar problem exists with jobs_del.
Note that this constraint is INITIALLY IMMEDIATE. If we were to make it INITIALLY DEFERRED then this code would become dangerous, because
./cs-adjust-flight F jobs-rename x 's/x/y/' copy-jobs G x
would leave F.x containing the steps from the old x but the recipe and runvars from G.x. But I don't think INITIALLY DEFERRED is a good default for constraints so this is probably not relevant.
Ian.
Quoted 17 lines · Ian Jackson
Ian Campbell writes ("[PATCH OSSTEST v2] cs-adjust-flight: Add jobs- rename command which applies a perlop to job names"):
Quoted 3 lines
My intention was to allow creation of adhoc jobs based on a template but modified e.g. to enable/disable XSM with a sequence something like:
...
Quoted 2 lines
Signed-off-by Ian Campbell <[email protected]>Acked-by Ian Jackson <[email protected]>I know I acked this, and my next observations don't mean we shouldn't apply it as-is, but:
Quoted 4 lines
+ UPDATE jobs
+ SET job = ?
+ WHERE flight = ? AND job = ?
+END
Quoted 7 lines
This can be applied to flights in intended blessing
play' in blessings later thanconstructing', or via `running:F' to running flights.And if that happens, there might be entries in the steps table which ought also to be renamed. If you don't rename them you will trip the foreign key constraint.
But fail immediately in this invocation of cs-adjust-flight with a (hopefully) comprehensible SQL error spew?
Or is that the distinction between INNTIALLY IMMEDIATE vs DEFERRED you were trying to get at?
Having stuffed the flight in this way would it have effects elsewhere (i.e. on production flights) or do you just get to keep both pieces of this particular flight?
Quoted 11 lines
I think a similar problem exists with
jobs_del.Note that this constraint is INITIALLY IMMEDIATE. If we were to make it INITIALLY DEFERRED then this code would become dangerous, because ./cs-adjust-flight F jobs-rename x 's/x/y/' copy-jobs G x would leave F.x containing the steps from the old x but the recipe and runvars from G.x. But I don't think INITIALLY DEFERRED is a good default for constraints so this is probably not relevant.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 26 lines · Ian Jackson
Ian Campbell writes ("Re: [PATCH OSSTEST v2] cs-adjust-flight: Add jobs- rename command which applies a perlop to job names"):
Quoted 7 lines · Ian Jackson
Quoted 3 lines
And if that happens, there might be entries in the steps table which ought also to be renamed. If you don't rename them you will trip the foreign key constraint.
But fail immediately in this invocation of cs-adjust-flight with a (hopefully) comprehensible SQL error spew?
Yes.
Quoted 3 lines
Or is that the distinction between INNTIALLY IMMEDIATE vs DEFERRED you were
trying to get at?Indeed. With the current (and likely future) configuration of the constraint, the UPDATE statement will fail and the transaction will not commit. So none of the updates in the invocation will take effect.
Quoted 4 lines
Having stuffed the flight in this way would it have effects elsewhere (i.e.
on production flights) or do you just get to keep both pieces of this particular flight?
Quoted 4 lines
If the constraints were changed, you might manage to use cs-adjust-flight to produce strangeness in the flight you were adjusting. If that flight were later exposed to archaeologists it might contain lies. TBH this seems far-fetched.
Indeed, especially since:
* Archaeologists typically don't look at play flights (or if you ask them to you should expect breakage).
* If a real flight somehow got into this state (via running:N or being constructing) then I would expect it would trip over the constraint before it could complete, and therefore never get to its intended blessing in the db, and would again be ignored by archaeologists in general I think?
* cs-adjust-flight already stops one from messing with a completed flight.
Ian.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel