Github user dg4prez commented on a diff in the pull request:

    
https://github.com/apache/incubator-trafficcontrol/pull/299#discussion_r106416184
  
    --- Diff: traffic_ops/bin/traffic_ops_ort.pl ---
    @@ -671,31 +748,128 @@ sub get_print_current_client_connections {
        ( $log_level >> $DEBUG ) && print "DEBUG There are currently 
$current_connections connections.\n";
     }
     
    +sub check_revalidate_state {
    +   my $sleep_override = shift;
    +
    +   my $syncds_update = 0;
    +
    +   ( $log_level >> $DEBUG ) && print "DEBUG Checking revalidate state.\n";
    +   if ( $script_mode == $REVALIDATE || $sleep_override == 1 ) {
    +           ## The herd is about to get /update/<hostname>
    +
    +           my $uri     = "/update/$hostname_short";
    +           my $upd_ref = &lwp_get($uri);
    +           if ( $upd_ref =~ m/^\d{3}$/ ) {
    +                   ( $log_level >> $ERROR ) && print "ERROR Update URL: 
$uri returned $upd_ref. Exiting, not sure what else to do.\n";
    +                   exit 1;
    +           }
    +
    +           my $upd_json = decode_json($upd_ref);
    +           my $reval_pending = ( defined( 
$upd_json->[0]->{'reval_pending'} ) ) ? $upd_json->[0]->{'reval_pending'} : 
undef;
    +           if ( !defined($reval_pending) ) {
    +                   ( $log_level >> $ERROR ) && print "ERROR Update URL: 
$uri did not have an reval_pending key.  Separated revalidation requires 
upgrading to Traffic Ops version 2.1.\n";
    +                   return($UPDATE_TROPS_NOTNEEDED);
    +           }
    +
    +           if ( $reval_pending == 1 ) {
    +                   ( $log_level >> $ERROR ) && print "ERROR Traffic Ops is 
signaling that a revalidation is waiting to be applied.\n";
    +                   $syncds_update = $UPDATE_TROPS_NEEDED;
    +
    +                   my $parent_reval_pending = ( defined( 
$upd_json->[0]->{'parent_reval_pending'} ) ) ? 
$upd_json->[0]->{'parent_reval_pending'} : undef;
    +                   if ( !defined($parent_reval_pending) ) {
    +                           ( $log_level >> $ERROR ) && print "ERROR Update 
URL: $uri did not have an parent_reval_pending key.  Separated revalidation 
requires upgrading to Traffic Ops version 2.1.  Unable to continue!\n";
    +                           return($UPDATE_TROPS_NOTNEEDED);
    +                   }
    +                   if ( $parent_reval_pending == 1 ) {
    +                           ( $log_level >> $ERROR ) && print "ERROR 
Traffic Ops is signaling that my parents need to revalidate.\n";
    +                           return($UPDATE_TROPS_NOTNEEDED);
    +                   }
    +           }
    +           elsif ( $script_mode == $REVALIDATE && $reval_pending != 1 ) {
    +                   ( $log_level >> $ERROR ) && print "ERROR In revalidate 
mode, but no update needs to be applied. I'm outta here.\n";
    +                   return($UPDATE_TROPS_NOTNEEDED);
    +           }
    +           else {
    +                   ( $log_level >> $ERROR ) && print "ERROR Traffic Ops is 
signaling that no revalidations are waiting to be applied.\n";
    +           }
    +
    +           my $stj = &lwp_get("/datastatus");
    --- End diff --
    
    The api response contains another json layer - 'response' which breaks the 
script.  It's not a big deal, but I wonder which is "correct?"


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to