Skip to content
This repository has been archived by the owner on Feb 26, 2019. It is now read-only.

Commit

Permalink
Fixed an issue that prevented updates from being queued on child when…
Browse files Browse the repository at this point in the history
… a parent's state is administratively changed. This resolves Comcast#1406.

(cherry picked from commit cad9d42)
  • Loading branch information
elsloo committed May 11, 2016
1 parent 74650bd commit 14b10d3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
17 changes: 12 additions & 5 deletions traffic_ops/app/lib/UI/Server.pm
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,7 @@ sub postupdatequeue {
my $host = $self->param("id");
my $cdn = $self->param("cdn");
my $cachegroup = $self->param("cachegroup");
my $wording = ($setqueue == 1) ? "Queue Updates" : "Unqueue Updates";

if ( !&is_admin($self) && !&is_oper($self) ) {
$self->flash( alertmsg => "No can do. Get more privs." );
Expand All @@ -933,15 +934,21 @@ sub postupdatequeue {

if ( defined($host) ) {
my $update;
my $message;

if ( $host eq "all" ) {
$update = $self->db->resultset('Server')->search(undef);
$message = "all servers";
}
else {
$update =
$self->db->resultset('Server')->search( { id => $host, } );
my $server = $self->db->resultset('Server')->search( { id => $host, } )->single();
my @edge_cache_groups = $self->db->resultset('Cachegroup')->search( { parent_cachegroup_id => $server->cachegroup->id } )->all();
my @cg_ids = map { $_->id } @edge_cache_groups;
$update = $self->db->resultset('Server')->search( { cachegroup => { -in => \@cg_ids } } );
$message = "children of " . $server->host_name . " in the following cachegroups: " . join(", ", map { $_->name } @edge_cache_groups);
}
$update->update( { upd_pending => $setqueue } );
&log( $self, "Flip Update bit (Queue Updates) for server(s):" . $host, "OPER" );
&log( $self, "Flip Update bit ($wording) for " . $message, "OPER" );
}
elsif ( defined($cdn) && defined($cachegroup) ) {
my @profiles;
Expand Down Expand Up @@ -977,8 +984,8 @@ sub postupdatequeue {

if ( $update->count() > 0 ) {
$update->update( { upd_pending => $setqueue } );
$self->app->log->debug("Flip Update bit (Queue Updates) for servers in CDN: $cdn, Cachegroup: $cachegroup");
&log( $self, "Flip Update bit (Queue Updates) for servers in CDN:" . $cdn . " cachegroup:" . $cachegroup, "OPER" );
$self->app->log->debug("Flip Update bit ($wording) for servers in CDN: $cdn, Cachegroup: $cachegroup");
&log( $self, "Flip Update bit ($wording) for servers in CDN:" . $cdn . " cachegroup:" . $cachegroup, "OPER" );
}
else {
$self->app->log->debug("No Queue Updates for servers in CDN: $cdn, Cachegroup: $cachegroup");
Expand Down
11 changes: 4 additions & 7 deletions traffic_ops/app/templates/server/view.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -326,22 +326,19 @@ var online_status = 'ONLINE';
var queue_updates = false;
var last_part = "?";

% if ($server_data->type->name =~ m/^MID/) {
queue_updates = true;
last_part = " *AND* queue updates on all edges?"
% }

% if ( $server_data->type->name =~ m/^EDGE/ || $server_data->type->name =~ m/^MID/ ) {
online_status = 'REPORTED';
offline_status = 'ADMIN_DOWN';
queue_updates = true;
last_part = " *AND* queue updates on all child caches?"
% }

function offline_confirm() {
var r=confirm("Set status of this machine to " + offline_status + last_part);
if (r==true) {
$.post("/server/updatestatus", { status: offline_status, id: <%= $id %> });
if ( queue_updates == true )
$.post('/postupdatequeue/edges', { setqueue: 1 });
$.post('/postupdatequeue/<%= $id %>', { setqueue: 1 });
parent.$.fancybox.close();
}
}
Expand All @@ -350,7 +347,7 @@ function online_confirm() {
if (r==true) {
$.post("/server/updatestatus", { status: online_status, id: <%= $id %> });
if ( queue_updates == true )
$.post('/postupdatequeue/edges', { setqueue: 1 });
$.post('/postupdatequeue/<%= $id %>', { setqueue: 1 });
parent.$.fancybox.close();
}
}
Expand Down

0 comments on commit 14b10d3

Please sign in to comment.