Commit 1ca84a0d authored by David Johnson's avatar David Johnson

Bugfix, and protect switch flashes via feature.

We now protect switch reloads via the SwitchFlash feature.  We
don't really give people a lot of advance warning about this,
and we wait long enough that it will irritatingly fail your
experiment swapin.  Ideally we should check before anything
starts happening, but we don't know if we *have* to reload
until we see what's on the nswitch node that gets allocated
to us... and by the time nodes are allocated, I think they
end up having to go through reloading if *any* of them fails.
Not sure though.

Also fixup handling of multiple libossetup_switch ops; if one
fails, abort the list instead of continuing on.
parent fa00dff7
......@@ -230,11 +230,11 @@ sub PreSetupReload($$)
if ($rowref->{partition} == $newpart) {
if ($newimageid == $rowref->{imageid}
&& $newosid == $rowref->{osid}) {
tbinfo "$self UpdatePartitions($node_id): not forcing reload because new and current images are the same!\n";
tbinfo "$self PreSetupReload($node_id): not forcing reload because new and current images are the same!\n";
return 0;
}
else {
tbinfo "$self UpdatePartitions($node_id): forcing reload because new and current images are different!\n";
tbinfo "$self PreSetupReload($node_id): forcing reload because new and current images are different!\n";
$self->nodeflag($nodeobject,'force',1);
}
......@@ -243,6 +243,24 @@ sub PreSetupReload($$)
}
}
#
# We have to check to see if the user can really do a reload -- if not,
# we have to bail, unfortunately! It's unfortunate because we have now
# failed the swapin when we probably should detect it much sooner.
#
if ($self->nodeflag($nodeobject,'force',1)) {
if (!EmulabFeatures->FeatureEnabled("SwitchFlash",
$self->nodeflag($nodeobject,'user'),
$self->nodeflag($nodeobject,'group'),
$self->nodeflag($nodeobject,'experiment'))) {
tberror "$self PreSetupReload($node_id): you do not have permission to flash switches!\n";
return -1;
}
require libosload_new;
# XXX -- @nodelist
$self->loadobj(libosload_new->New());
}
#
# If we're really gonna do it, then save our state so we can restore
# if it seems like our load failed.
......
......@@ -546,6 +546,12 @@ sub LightUpNodes($@)
$self->group(),
$self->experiment())) {
($self->loadobj())->debug($self->debug());
# add a few more things for feature checks down the line:
$reload_args{user} = $self->user();
$reload_args{group} = $self->group();
$reload_args{experiment} = $self->experiment();
$pid = ($self->loadobj())->osload(\%reload_args, $reload_failures);
$coderef = sub {
my $childpid = shift;
......@@ -1316,6 +1322,12 @@ sub AddNode($$)
$self->group(),
$self->experiment())) {
($parent->loadobj())->debug($self->debug());
# add a few more things for feature checks down the line:
$reload_args{user} = $self->user();
$reload_args{group} = $self->group();
$reload_args{experiment} = $self->experiment();
($parent->loadobj())->osload(\%reload_args, $reload_failures);
}
else {
......
......@@ -219,6 +219,12 @@ sub LightUpNodes($@)
$parent->group(),
$parent->experiment())) {
($parent->loadobj())->debug($parent->debug());
# add a few more things for feature checks down the line:
$reload_args{user} = $parent->user();
$reload_args{group} = $parent->group();
$reload_args{experiment} = $parent->experiment();
$pid = ($parent->loadobj())->osload(\%reload_args,$reload_failures);
print STDERR "$self: kicking off wait for osload pid $pid\n";
$coderef = sub {
......@@ -372,8 +378,8 @@ sub WaitDone($@)
print STDERR "$self: WaitDone: $node_id,$setupstatus,$eventstate\n";
if ($eventstate eq TBDB_NODESTATE_ISUP()) {
if ($eventstate eq TBDB_NODESTATE_ISUP()
&& $setupstatus == $libossetup::SETUP_OKAY) {
#
# If there is another op in our list, keep going with that op --
# i.e., keep the node in our todo list!
......@@ -412,6 +418,21 @@ sub WaitDone($@)
if ($node->_setupoperation() != $libossetup::NOSTATE);
next;
}
elsif ($setupstatus != $libossetup::SETUP_OKAY) {
#
# Our last op failed; don't continue!
#
my $op = shift @{$self->{OPLIST}->{$node_id}};
my $opname = "RELOAD";
if ($op == $libossetup::RECONFIG) {
$opname = "RECONFIG";
}
elsif ($op == $libossetup::REBOOT) {
$opname = "REBOOT";
}
tbwarn "$self WaitDone: $node_id failed $opname; NOT doing more ops!\n";
$self->{OPLIST}->{$node_id} = [];
}
#
# If we had an error, don't continue! SUPER method handles that.
......
......@@ -123,6 +123,7 @@ $force = 1
# experiment. To get all free nodes, must use sched_reload.
#
my $experiment;
my $group;
if (defined($options{"e"})) {
usage()
if (@ARGV);
......@@ -138,6 +139,7 @@ if (defined($options{"e"})) {
die("*** $0:\n".
" No such experiment $pid/$eid!\n");
}
$group = $experiment->GetGroup();
if (! (@nodes = $experiment->NodeList(0, 1))) {
die("*** $0:\n".
" There are no nodes in $pid/$eid!\n");
......@@ -162,7 +164,12 @@ else {
if (!$node->IsReserved()) {
die("*** $0:\n".
" Node $nodeid is not reserved; reserve it first!\n");
}
}
else {
$experiment = $node->Reservation();
$group = $experiment->GetGroup();
}
push(@nodes, $node);
}
}
......@@ -338,7 +345,7 @@ $osloadargs{'swapinfo'} = 1;
$osloadargs{'usecurrent'} = $usecurrent;
my $user = User->ThisUser();
if (EmulabFeatures->FeatureEnabled("NewOsload",$user,undef,$experiment)) {
if (EmulabFeatures->FeatureEnabled("NewOsload",$user,$group,$experiment)) {
require libosload_new;
my $loadobj = libosload_new->New();
$loadobj->debug($debug);
......@@ -354,6 +361,11 @@ if (EmulabFeatures->FeatureEnabled("NewOsload",$user,undef,$experiment)) {
#
$osloadargs{'reconfig'} = $reconfig;
# add a few more things for feature checks down the line:
$osloadargs{user} = $user;
$osloadargs{group} = $group;
$osloadargs{experiment} = $experiment;
exit($loadobj->osload(\%osloadargs, \%failednodes));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment