Commit 3e568267 authored by Leigh Stoller's avatar Leigh Stoller

Fix to portal event system handling:

I noticed that when using the local portal to start an experiment, on a
cluster that is also a member of the Cloudlab federation (the Portal),
the local portal UI was not seeing the usual updates to the nodes in the
topology drawing. That is cause the events were going to the remote
Portal instead of to the local portal. This change looks at the slice
URN, specifically the domain, to decide where to send those events.
parent 3213b92a
#!/usr/bin/perl -w #!/usr/bin/perl -w
# #
# Copyright (c) 2008-2018 University of Utah and the Flux Group. # Copyright (c) 2008-2019 University of Utah and the Flux Group.
# #
# {{{GENIPUBLIC-LICENSE # {{{GENIPUBLIC-LICENSE
# #
...@@ -76,6 +76,7 @@ sub fatal($); ...@@ -76,6 +76,7 @@ sub fatal($);
# Locals # Locals
my $portalhandle; my $portalhandle;
my $genievent;
# #
# Turn off line buffering on output # Turn off line buffering on output
...@@ -218,7 +219,7 @@ if ($CLUSTER_PORTAL ne "") { ...@@ -218,7 +219,7 @@ if ($CLUSTER_PORTAL ne "") {
# #
# Tell the GeniEvent code to use this handle. # Tell the GeniEvent code to use this handle.
# #
GeniEvent->Create($portalhandle); $genievent = GeniEvent->Create($portalhandle);
} }
# #
...@@ -351,11 +352,11 @@ sub HandleNotification($$) ...@@ -351,11 +352,11 @@ sub HandleNotification($$)
my $sliver = GeniSliver->Lookup($node->genisliver_idx()); my $sliver = GeniSliver->Lookup($node->genisliver_idx());
goto done goto done
if (!$sliver); if (!$sliver);
my $slice_urn = GeniSlice->UUID2URN($sliver->slice_uuid());
goto done
if (!$slice_urn);
if ($testing || $debug) { if ($testing || $debug) {
my $slice = $sliver->GetSlice();
my $slice_urn = $slice->urn();
$slice->Flush();
if ($testing && $slice_urn !~ /purpnurp/) { if ($testing && $slice_urn !~ /purpnurp/) {
#print "Ignoring $slice_urn\n"; #print "Ignoring $slice_urn\n";
goto done; goto done;
...@@ -363,6 +364,29 @@ sub HandleNotification($$) ...@@ -363,6 +364,29 @@ sub HandleNotification($$)
} }
if ($verbose) { if ($verbose) {
print "$node_id:$objtype " . ($event ? $event : "") . "\n"; print "$node_id:$objtype " . ($event ? $event : "") . "\n";
print " $slice_urn\n";
}
#
# If we belong to a cluster (Portal) then we need to figure out where
# GeniEvent should send the event. If standalone, GeniEvent will send
# everything to the local pubsubd (where aptevent_daemon will pick them
# up).
#
if ($CLUSTER_PORTAL ne "") {
if ($slice_urn->IsOurDomain()) {
# This slice is local, so events go to the local pubsubd
# (picked up by aptevent_daemon).
$genievent->SetHandle($localhandle);
}
else {
# This slice belongs to another SA, maybe the Portal, so
# events go to the Portal. Note that being from another
# domain does not guarantee it is from the Portal, it
# might be from anyone in the federation, but sending to
# the Portal is harmless, it will throw the events away.
$genievent->SetHandle($portalhandle);
}
} }
# #
...@@ -388,6 +412,9 @@ sub HandleNotification($$) ...@@ -388,6 +412,9 @@ sub HandleNotification($$)
$oldstatus eq $newstatus) { $oldstatus eq $newstatus) {
$sliver->SendStatusEvent(); $sliver->SendStatusEvent();
} }
if ($verbose) {
print "Status for $node_id $oldstatus -> $newstatus\n";
}
} }
} }
elsif ($objtype eq TBDB_TBEVENT_FRISBEESTATUS()) { elsif ($objtype eq TBDB_TBEVENT_FRISBEESTATUS()) {
......
#!/usr/bin/perl -w #!/usr/bin/perl -w
# #
# Copyright (c) 2008-2016, 2018 University of Utah and the Flux Group. # Copyright (c) 2008-2019 University of Utah and the Flux Group.
# #
# {{{GENIPUBLIC-LICENSE # {{{GENIPUBLIC-LICENSE
# #
...@@ -129,6 +129,17 @@ sub DESTROY ...@@ -129,6 +129,17 @@ sub DESTROY
$self->{'HANDLE'} = undef; $self->{'HANDLE'} = undef;
} }
} }
sub SetHandle($$)
{
my ($self, $handle) = @_;
my $old = $self->{'HANDLE'};
$self->{'HANDLE'} = $handle;
# Mark as an external handle, we do not want to mess with it.
$self->{'EXTERNAL'} = 1;
return $old;
}
# #
# Send an event to the local pubsubd. # Send an event to the local pubsubd.
......
...@@ -364,7 +364,7 @@ sub new($$) ...@@ -364,7 +364,7 @@ sub new($$)
$self->{'id'} = $id; $self->{'id'} = $id;
$self->{'authority'} = $authority; $self->{'authority'} = $authority;
my ($domain,$subauth) = split(":", $authority, 2); my ($domain,$subauth) = split(":", $authority, 2);
$self->{'domain'} = $domain; $self->{'domain'} = lc($domain);
$self->{'subauth'} = $subauth; $self->{'subauth'} = $subauth;
if (defined($subauth)) { if (defined($subauth)) {
($project,$group) = split(":", $subauth, 2); ($project,$group) = split(":", $subauth, 2);
...@@ -396,6 +396,8 @@ sub IsRoot($) { return ($_[0]->IsAuthority() && ...@@ -396,6 +396,8 @@ sub IsRoot($) { return ($_[0]->IsAuthority() &&
$_[0]->id() =~ /^root$/i ? 1 : 0); } $_[0]->id() =~ /^root$/i ? 1 : 0); }
sub IsUser($) { return $_[0]->type() =~ /^user$/i ? 1 : 0; } sub IsUser($) { return $_[0]->type() =~ /^user$/i ? 1 : 0; }
sub IsNode($) { return $_[0]->type() =~ /^node$/i ? 1 : 0; } sub IsNode($) { return $_[0]->type() =~ /^node$/i ? 1 : 0; }
sub IsProject($) { return $_[0]->type() =~ /^project$/i ? 1 : 0; }
sub IsOurDomain($) { return $_[0]->domain() eq lc("@OURDOMAIN@") ? 1 : 0; }
# #
# Image accessors. If we use any of these we want to parse the urn # Image accessors. If we use any of these we want to parse the urn
......
...@@ -384,6 +384,24 @@ sub Delete($) ...@@ -384,6 +384,24 @@ sub Delete($)
return 0; return 0;
} }
#
# Class method to get the slice urn from a slice uuid, without all the
# the other cruft.
#
sub UUID2URN($$)
{
my ($class, $uuid) = @_;
my $query_result =
DBQueryWarn("select urn from geni_certificates where uuid='$uuid'");
return undef
if (!defined($query_result) || !$query_result->numrows);
my ($urn) = $query_result->fetchrow_array();
return GeniHRN->new($urn);
}
# The slicename is the last token in the hrn. # The slicename is the last token in the hrn.
sub slicename($) sub slicename($)
{ {
......
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