You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2017/03/16 21:09:00 UTC
[02/29] incubator-trafficcontrol git commit: prevent syncds from
running if parent_reval_pending is flagged
prevent syncds from running if parent_reval_pending is flagged
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/d26bc224
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/d26bc224
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/d26bc224
Branch: refs/heads/master
Commit: d26bc22421ccca24677cda6767477a4cd7d93344
Parents: 70a1384
Author: Derek Gelinas <de...@cable.comcast.com>
Authored: Wed Feb 22 12:42:38 2017 -0500
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Thu Mar 16 15:08:23 2017 -0600
----------------------------------------------------------------------
traffic_ops/bin/traffic_ops_ort.pl | 100 +++++++++++++++++++++++---------
1 file changed, 71 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d26bc224/traffic_ops/bin/traffic_ops_ort.pl
----------------------------------------------------------------------
diff --git a/traffic_ops/bin/traffic_ops_ort.pl b/traffic_ops/bin/traffic_ops_ort.pl
index 772da98..451ebff 100755
--- a/traffic_ops/bin/traffic_ops_ort.pl
+++ b/traffic_ops/bin/traffic_ops_ort.pl
@@ -846,6 +846,8 @@ sub check_syncds_state {
$syncds_update = $UPDATE_TROPS_NEEDED;
my $parent_pending = ( defined( $upd_json->[0]->{'parent_pending'} ) ) ? $upd_json->[0]->{'parent_pending'} : undef;
+ my $parent_reval_pending = ( defined( $upd_json->[0]->{'parent_reval_pending'} ) ) ? $upd_json->[0]->{'parent_reval_pending'} : undef;
+
if ( !defined($parent_pending) ) {
( $log_level >> $ERROR ) && print "ERROR Update URL: $url did not have an parent_pending key.\n";
if ( $script_mode != $SYNCDS ) {
@@ -856,40 +858,80 @@ sub check_syncds_state {
exit 1;
}
}
- if ( $parent_pending == 1 && $wait_for_parents == 1) {
- ( $log_level >> $ERROR ) && print "ERROR Traffic Ops is signaling that my parents need an update.\n";
- if ( $script_mode == $SYNCDS ) {
- if ( $dispersion > 0 ) {
- ( $log_level >> $WARN ) && print "WARN In syncds mode, sleeping for " . $dispersion . "s to see if the update my parents need is cleared.\n";
- for ( my $i = $dispersion; $i > 0; $i-- ) {
- ( $log_level >> $WARN ) && print ".";
- sleep 1;
+ if ( defined($parent_reval_pending) ) {
+ ( $log_level >> $DEBUG ) && print "DEBUG Parent Reval Pending key exists!\n";
+ if ( ( $parent_pending == 1 || $parent_reval_pending == 1 ) && $wait_for_parents == 1 ) {
+ ( $log_level >> $ERROR ) && print "ERROR Traffic Ops is signaling that my parents need an update.\n";
+ if ( $script_mode == $SYNCDS ) {
+ if ( $dispersion > 0 ) {
+ ( $log_level >> $WARN ) && print "WARN In syncds mode, sleeping for " . $dispersion . "s to see if the update my parents need is cleared.\n";
+ for ( my $i = $dispersion; $i > 0; $i-- ) {
+ ( $log_level >> $WARN ) && print ".";
+ sleep 1;
+ }
+ }
+
+ ( $log_level >> $WARN ) && print "\n";
+ $upd_ref = &lwp_get($url);
+ if ( $upd_ref =~ m/^\d{3}$/ ) {
+ ( $log_level >> $ERROR ) && print "ERROR Update URL: $url returned $upd_ref. Exiting, not sure what else to do.\n";
+ exit 1;
+ }
+ $upd_json = decode_json($upd_ref);
+ $parent_pending = ( defined( $upd_json->[0]->{'parent_pending'} ) ) ? $upd_json->[0]->{'parent_pending'} : undef;
+ if ( !defined($parent_pending) ) {
+ ( $log_level >> $ERROR ) && print "ERROR Invalid JSON for $url. Exiting, not sure what else to do.\n";
+ }
+ if ( $parent_pending == 1 ) {
+ ( $log_level >> $ERROR ) && print "ERROR My parents still need an update, bailing.\n";
+ exit 1;
+
+ }
+ else {
+ ( $log_level >> $DEBUG ) && print "DEBUG The update on my parents cleared; continuing.\n";
}
}
-
- ( $log_level >> $WARN ) && print "\n";
- $upd_ref = &lwp_get($url);
- if ( $upd_ref =~ m/^\d{3}$/ ) {
- ( $log_level >> $ERROR ) && print "ERROR Update URL: $url returned $upd_ref. Exiting, not sure what else to do.\n";
- exit 1;
- }
- $upd_json = decode_json($upd_ref);
- $parent_pending = ( defined( $upd_json->[0]->{'parent_pending'} ) ) ? $upd_json->[0]->{'parent_pending'} : undef;
- if ( !defined($parent_pending) ) {
- ( $log_level >> $ERROR ) && print "ERROR Invalid JSON for $url. Exiting, not sure what else to do.\n";
- }
- if ( $parent_pending == 1 ) {
- ( $log_level >> $ERROR ) && print "ERROR My parents still need an update, bailing.\n";
- exit 1;
-
- }
- else {
- ( $log_level >> $DEBUG ) && print "DEBUG The update on my parents cleared; continuing.\n";
- }
+ }
+ else {
+ ( $log_level >> $DEBUG ) && print "DEBUG Traffic Ops is signaling that my parents do not need an update, or wait_for_parents == 0.\n";
}
}
else {
- ( $log_level >> $DEBUG ) && print "DEBUG Traffic Ops is signaling that my parents do not need an update, or wait_for_parents == 0.\n";
+ if ( $parent_pending == 1 && $wait_for_parents == 1 ) {
+ ( $log_level >> $ERROR ) && print "ERROR Traffic Ops is signaling that my parents need an update.\n";
+ if ( $script_mode == $SYNCDS ) {
+ if ( $dispersion > 0 ) {
+ ( $log_level >> $WARN ) && print "WARN In syncds mode, sleeping for " . $dispersion . "s to see if the update my parents need is cleared.\n";
+ for ( my $i = $dispersion; $i > 0; $i-- ) {
+ ( $log_level >> $WARN ) && print ".";
+ sleep 1;
+ }
+ }
+
+ ( $log_level >> $WARN ) && print "\n";
+ $upd_ref = &lwp_get($url);
+ if ( $upd_ref =~ m/^\d{3}$/ ) {
+ ( $log_level >> $ERROR ) && print "ERROR Update URL: $url returned $upd_ref. Exiting, not sure what else to do.\n";
+ exit 1;
+ }
+ $upd_json = decode_json($upd_ref);
+ $parent_pending = ( defined( $upd_json->[0]->{'parent_pending'} ) ) ? $upd_json->[0]->{'parent_pending'} : undef;
+ if ( !defined($parent_pending) ) {
+ ( $log_level >> $ERROR ) && print "ERROR Invalid JSON for $url. Exiting, not sure what else to do.\n";
+ }
+ if ( $parent_pending == 1 ) {
+ ( $log_level >> $ERROR ) && print "ERROR My parents still need an update, bailing.\n";
+ exit 1;
+
+ }
+ else {
+ ( $log_level >> $DEBUG ) && print "DEBUG The update on my parents cleared; continuing.\n";
+ }
+ }
+ }
+ else {
+ ( $log_level >> $DEBUG ) && print "DEBUG Traffic Ops is signaling that my parents do not need an update, or wait_for_parents == 0.\n";
+ }
}
}
elsif ( $script_mode == $SYNCDS && $upd_pending != 1 ) {