Skip to contentSkip to conversation

get_hostflags: return an empty list when there is no flight/job.

PATCH In review Ian Campbell 2 participants 5 messages Jul 29, 2015 – Aug 11, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 get_hostflags: return an empty list when there is no flight/job.

From: Ian Campbell <[email protected]>

Otherwise trying to use mg-hosts mkpxedir fails with:

$ OSSTEST_CONFIG=production-config-cambridge ./mg-hosts mkpxedir -n rice-weevil
2015-07-27 10:12:28 Z serial method sympathy rice-weevil: osstser1.xs.citrite.net /root/sympathy/rice-weevil /root/sympathy/rice-weevil.log*
2015-07-27 10:12:28 Z TftpScope is default
2015-07-27 10:12:28 Z task 260549 static ianc@osstest: ianc@osstest manual
Use of uninitialized value $otherflightjob in pattern match (m//) at Osstest.pm line 308.
Use of uninitialized value $otherflightjob in pattern match (m//) at Osstest.pm line 308.
Use of uninitialized value $otherflightjob in concatenation (.) or string at Osstest.pm line 308.
 ? at Osstest.pm line 308.
---
 Osstest/TestSupport.pm | 1 +
 1 file changed, 1 insertion(+)
Osstest/TestSupport.pm +1 -0
index 4696d68..19d643a 100644
@@ -1292,6 +1292,7 @@ sub git_dir_revision ($$) {
 sub get_hostflags ($) {
     my ($ident) = @_;
     # may be run outside transaction, or with flights locked
+    return () unless $flight && $job;
     my $flags= get_runvar_default('all_hostflags',     $job, '').','.
                get_runvar_default("${ident}_hostflags", $job, '');
     return grep /./, split /\,/, $flags;
Signature · 1 line
2.1.4
#1 lore raw

Ian Campbell writes ("[PATCH OSSTEST] get_hostflags: return an empty list when there is no flight/job."):

Quoted 3 lines

From: Ian Campbell <[email protected]>

Otherwise trying to use mg-hosts mkpxedir fails with:

I think your proposed fix is incorrect. It is wrong to call get_hostflags outside the context of a job, because get_hostflags is supposed to return the job's host flags for that ident.

The bug was introduced by me in 11e788f7 "JobDB/Executive: Improve an internal `die' error", where a refactoring meant that we always call get_hostflags.

How about this instead ?

Osstest/JobDB/Executive.pm +1 -1
index 1ec947e..cc52f57 100644
@@ -128,7 +128,7 @@ sub host_check_allocated ($$) { #method
         $ho->{Shared} &&
         $ho->{Shared}{State} eq 'ready';
     my $harness = get_harness_rev();
-    my @flags = get_hostflags($ho->{Ident});
+    my @flags = defined($job) ? get_hostflags($ho->{Ident}) : qw(OUTSIDE-JOB);
     $ho->{SharedReady}=
 	$ho->{SharedMaybeOthers} &&
         !! (grep { $_." ".$harness eq "share-".$ho->{Shared}{Type} }

Ian.

author Acked-by
#2 lore raw
Quoted 31 lines · Ian Jackson

Ian Campbell writes ("[PATCH OSSTEST] get_hostflags: return an empty list when there is no flight/job."):

Quoted 3 lines

From: Ian Campbell <[email protected]>

Otherwise trying to use mg-hosts mkpxedir fails with:

I think your proposed fix is incorrect. It is wrong to call get_hostflags outside the context of a job, because get_hostflags is supposed to return the job's host flags for that ident.

The bug was introduced by me in 11e788f7 "JobDB/Executive: Improve an internal `die' error", where a refactoring meant that we always call get_hostflags.

How about this instead ?

Osstest/JobDB/Executive.pm +1 -2
index 1ec947e..cc52f57 100644
@@ -128,7 +128,7 @@ sub host_check_allocated ($$) { #method
         $ho->{Shared} &&
         $ho->{Shared}{State} eq 'ready';
     my $harness = get_harness_rev();
-    my @flags = get_hostflags($ho->{Ident});
+    my @flags = defined($job) ? get_hostflags($ho->{Ident}) : qw(OUTSIDE
-JOB);
     $ho->{SharedReady}=
 	$ho->{SharedMaybeOthers} &&
         !! (grep { $_." ".$harness eq "share-".$ho->{Shared}{Type} }
Quoted 1 line

LGTM, I suppose the use of the OUTSIDE-JOB sentinel value is just for the benefit of the reader of the following die() should it occur.

Ian.

author Acked-by
#3 lore raw
Quoted 34 lines · Ian Campbell
Quoted 33 lines · Ian Jackson

Ian Campbell writes ("[PATCH OSSTEST] get_hostflags: return an empty list
when there is no flight/job."):

Quoted 3 lines

From: Ian Campbell <[email protected]>

Otherwise trying to use mg-hosts mkpxedir fails with:

I think your proposed fix is incorrect. It is wrong to call get_hostflags outside the context of a job, because get_hostflags is supposed to return the job's host flags for that ident.

The bug was introduced by me in 11e788f7 "JobDB/Executive: Improve an internal `die' error", where a refactoring meant that we always call get_hostflags.

How about this instead ?

Osstest/JobDB/Executive.pm +1 -1
index 1ec947e..cc52f57 100644
@@ -128,7 +128,7 @@ sub host_check_allocated ($$) { #method
         $ho->{Shared} &&
         $ho->{Shared}{State} eq 'ready';
     my $harness = get_harness_rev();
-    my @flags = get_hostflags($ho->{Ident});
+    my @flags = defined($job) ? get_hostflags($ho->{Ident}) : 

qw(OUTSIDE

Osstest/JobDB/Executive.pm +0 -1
-JOB);
     $ho->{SharedReady}=
 	$ho->{SharedMaybeOthers} &&
         !! (grep { $_." ".$harness eq "share-".$ho->{Shared}{Type} }
Quoted 6 lines
Quoted 1 line

LGTM, I suppose the use of the OUTSIDE-JOB sentinel value is just for the benefit of the reader of the following die() should it occur.

I fabricated some sort of commit message and pushed to pretest.

commit 2e51119a34d06162b69275f38010130193d5501e

Author: Ian Jackson <[email protected]>
Date:   Wed Aug 5 11:42:10 2015 +0100

Executive: Support host_check_allocated outside a job.

When called outside a job there are no hostflags, so get_hostflags cannot be used. Instead assume a new pseudo-flag "OUTSIDE-JOB" when there is no $job.

Otherwise uses of select_host such as "mg-hosts mkpxedir" fail.

[ ijc -- wrong commit message ]
Osstest/JobDB/Executive.pm +1 -1
index 1ec947e..cc52f57 100644
@@ -128,7 +128,7 @@ sub host_check_allocated ($$) { #method
         $ho->{Shared} &&
         $ho->{Shared}{State} eq 'ready';
     my $harness = get_harness_rev();
-    my @flags = get_hostflags($ho->{Ident});
+    my @flags = defined($job) ? get_hostflags($ho->{Ident}) : qw(OUTSIDE-JOB);
     $ho->{SharedReady}=
 	$ho->{SharedMaybeOthers} &&
         !! (grep { $_." ".$harness eq "share-".$ho->{Shared}{Type} }
#4 lore raw
Quoted 55 lines · Ian Campbell
Quoted 34 lines · Ian Campbell
Quoted 33 lines · Ian Jackson

Ian Campbell writes ("[PATCH OSSTEST] get_hostflags: return an empty list
when there is no flight/job."):

Quoted 3 lines

From: Ian Campbell <[email protected]>

Otherwise trying to use mg-hosts mkpxedir fails with:

I think your proposed fix is incorrect. It is wrong to call get_hostflags outside the context of a job, because get_hostflags is supposed to return the job's host flags for that ident.

The bug was introduced by me in 11e788f7 "JobDB/Executive: Improve an internal `die' error", where a refactoring meant that we always call get_hostflags.

How about this instead ?

Osstest/JobDB/Executive.pm +1 -1
index 1ec947e..cc52f57 100644
@@ -128,7 +128,7 @@ sub host_check_allocated ($$) { #method
         $ho->{Shared} &&
         $ho->{Shared}{State} eq 'ready';
     my $harness = get_harness_rev();
-    my @flags = get_hostflags($ho->{Ident});
+    my @flags = defined($job) ? get_hostflags($ho->{Ident}) : 

qw(OUTSIDE

Osstest/JobDB/Executive.pm +0 -1
-JOB);
     $ho->{SharedReady}=
 	$ho->{SharedMaybeOthers} &&
         !! (grep { $_." ".$harness eq "share-".$ho->{Shared}{Type} }
Quoted 7 lines
Quoted 1 line

LGTM, I suppose the use of the OUTSIDE-JOB sentinel value is just for the
benefit of the reader of the following die() should it occur.

I fabricated some sort of commit message and pushed to pretest.

commit 2e51119a34d06162b69275f38010130193d5501e

Author: Ian Jackson <[email protected]>
Date:   Wed Aug 5 11:42:10 2015 +0100

Executive: Support host_check_allocated outside a job.

When called outside a job there are no hostflags, so get_hostflags cannot be used. Instead assume a new pseudo-flag "OUTSIDE-JOB" when there is no $job.

Quoted 5 lines

Otherwise uses of select_host such as "mg-hosts mkpxedir" fail.

[ ijc -- wrong commit message ]

I really meant wrote here, sorry. It's through the gate now though.