Skip to contentSkip to conversation

allocation / test fixes

PATCH New Ian Jackson 1 participant 7 messages Oct 4, 2021

lore
Share & tools
lore
#0 lore raw

cover allocation / test fixes

These patches fix problems detected while doing maintenance work.

1 host lifecycle: Use correct taskid column for runvar reconstruction

In principle this might affect any job that picks up a host that was messed with by a stale task. It could even cause production flights to fail. I think this is a bugfix we want in production.

My Release Manager hat agrees.

2 mg-repro-setup: Promote an error test to before builds (nfc) 3 mg-allocate: Break out sub precheck (nfc)
4 mg-allocate: Add --dry-run mode
5 mg-allocate: feasibility check: print a reassuring message 6 mg-repro-setup: Check allocation feasibility at the start

These are fixes to manual and ad-hoc maintenance commands. They don't have any effect on db or host contents. So they have no release implications.

Therefore, all six:

I will push them to pretest shortly.

#1 lore raw

PATCH 1/6 host lifecycle: Use correct taskid column for runvar reconstruction

t.taskid might be NULL since the task may have been deleted.

---
 Osstest/JobDB/Executive.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Osstest/JobDB/Executive.pm +1 -1
index 097c8d75b..c5db2691b 100644
@@ -542,7 +542,7 @@ END
 
     my $scanq = $dbh_tests->prepare(<<END);
 	   SELECT h.flight, h.job, h.isprep, h.ident, h.stepno,
-                  t.live, t.taskid,
+                  t.live, h.taskid,
                   h2.lcseq later_notprep
 	     FROM host_lifecycle h
         LEFT JOIN host_lifecycle h2
Signature · 1 line
2.20.1
#2 lore raw

PATCH 2/6 mg-repro-setup: Promote an error test to before builds (nfc)

In reply to Ian Jackson
---
 mg-repro-setup | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
mg-repro-setup +9 -7
index 374176f03..56d27d4ef 100755
@@ -253,6 +253,15 @@ while [ $# -ne 0 ]; do
 	esac
 done
 
+if [ "${alloc_idents[*]}" ]; then
+        if [ x"$OSSTEST_TASK" = x ]; then
+                # We would have to make a dynamic task and hold the
+                #  fd for it in this script.  Would be quite awkward.
+                echo >&2 'cannot hand-allocate in a way that will free'
+                exit 1
+        fi
+fi
+
 flight=$(./cs-adjust-flight new:$blessing)
 progress "new flight is $flight"
 
@@ -281,13 +290,6 @@ if $statictask; then
 fi
 
 if [ "${alloc_idents[*]}" ]; then
-        if [ x"$OSSTEST_TASK" = x ]; then
-                # We would have to make a dynamic task and hold the
-                #  fd for it in this script.  Would be quite awkward.
-                echo >&2 'cannot hand-allocate in a way that will free'
-                exit 1
-        fi
-
 	progress "allocating ${alloc_idents[*]} ..."
 	alloc_output=tmp/$flight.allocations
 	./mg-allocate \
Signature · 1 line
2.20.1
#3 lore raw

PATCH 3/6 mg-allocate: Break out sub precheck (nfc)

In reply to Ian Jackson
---
 mg-allocate | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
mg-allocate +8 -6
index 14c46e0cc..8eca59e2c 100755
@@ -647,14 +647,16 @@ if (defined $donate_spec) {
 	if grep { m/^!/ } @ARGV;
 }
 
+sub precheck () {
+    logm("pre-checking resources (dry run)...");
+    local $Osstest::TestSupport::logm_prefix = $logm_prefix.' (precheck)';
+    execute(1);
+}
+
 if ($duration) {
     die "--donate and --steal are incompatible with the planning system\n"
-	if @steal_specs || defined $donate_spec;
-    {
-	logm("pre-checking resources (dry run)...");
-	local $Osstest::TestSupport::logm_prefix = $logm_prefix.' (precheck)';
-	execute(1);
-    };
+        if @steal_specs || defined $donate_spec;
+    precheck();
     plan();
 } else {
     execute();
Signature · 1 line
2.20.1
#4 lore raw

PATCH 4/6 mg-allocate: Add --dry-run mode

In reply to Ian Jackson
---
 mg-allocate | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
mg-allocate +8 -1
index 8eca59e2c..7dc2c7650 100755
@@ -26,6 +26,8 @@
 #   -U             allocate with high priority (makes sense with
 #                  specified duration only)
 #
+#   --dry-run      Do not actually allocate, just check feasibility.
+#
 #   --as <task-spec>
 #                  Run as the task <task-spec> (rather than looking
 #                  at OSSTEST_TASK).  Allocation will allocate
@@ -93,6 +95,7 @@ $|=1;
 
 our $tid;
 our %magictask;
+our $dry_run;
 our $list_only;
 our $donate_spec;
 our $donate_taskid;
@@ -536,6 +539,8 @@ while (@ARGV && $ARGV[0] =~ m/^[-0-9]/) {
         } elsif (s/^\-l/-/ || s/^--list$/--/) {
 	    $list_only++;
 	    die "-l may be repeated only thrice\n" if $list_only > 3;
+        } elsif (s/^--dry-run$/-/) {
+	    $dry_run= 1;
         } elsif (s/^--as$/-/) {
 	    die "--as needs task\n" unless @ARGV;
 	    $ENV{OSSTEST_TASK} = shift @ARGV;
@@ -653,7 +658,9 @@ sub precheck () {
     execute(1);
 }
 
-if ($duration) {
+if ($dry_run) {
+    precheck();
+} elsif ($duration) {
     die "--donate and --steal are incompatible with the planning system\n"
         if @steal_specs || defined $donate_spec;
     precheck();
Signature · 1 line
2.20.1
#5 lore raw

PATCH 5/6 mg-allocate: feasibility check: print a reassuring message

In reply to Ian Jackson
---
 mg-allocate | 1 +
 1 file changed, 1 insertion(+)
mg-allocate +1 -0
index 7dc2c7650..e700be185 100755
@@ -393,6 +393,7 @@ sub execute (;$) {
 
 	if ($dryrun) {
 	    db_retry_abort();
+	    logm("allocation feasible in principle (subject to planning)");
 	    return;
 	}
         if (!$allok) {
Signature · 1 line
2.20.1
#6 lore raw

PATCH 6/6 mg-repro-setup: Check allocation feasibility at the start

In reply to Ian Jackson
---
 mg-repro-setup | 11 +++++++++++
 1 file changed, 11 insertions(+)
mg-repro-setup +11 -0
index 56d27d4ef..895f29963 100755
@@ -260,6 +260,17 @@ if [ "${alloc_idents[*]}" ]; then
                 echo >&2 'cannot hand-allocate in a way that will free'
                 exit 1
         fi
+
+	set +e
+	alloc_output=$(
+		./mg-allocate --dry-run $duration "${alloc_specs[@]}" 2>&1
+	)
+	alloc_rc=$?
+	set -e
+	test $alloc_rc = 0 ||
+	fail "requested allocation(s) infeasible:
+$alloc_output
+"
 fi
 
 flight=$(./cs-adjust-flight new:$blessing)
Signature · 1 line
2.20.1