This is an automated email from the ASF dual-hosted git repository.
rawlin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new 8920302 Add ORT TO timeout option (#4606)
8920302 is described below
commit 8920302320637128e8c8f742e27eb862c909680f
Author: Robert O Butts <[email protected]>
AuthorDate: Tue Apr 7 10:21:06 2020 -0600
Add ORT TO timeout option (#4606)
Exposes the existing atstccfg Traffic Ops timeout as an ORT option.
Also changes the default timeout back to 30s, to match what ORT has
been forever.
---
traffic_ops/ort/atstccfg/config/config.go | 2 +-
traffic_ops/ort/traffic_ops_ort.pl | 26 +++++++++++++++++---------
2 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/traffic_ops/ort/atstccfg/config/config.go
b/traffic_ops/ort/atstccfg/config/config.go
index 1265714..de841d1 100644
--- a/traffic_ops/ort/atstccfg/config/config.go
+++ b/traffic_ops/ort/atstccfg/config/config.go
@@ -88,7 +88,7 @@ func GetCfg() (Cfg, error) {
logLocationWarnPtr := flag.StringP("log-location-warning", "w",
"stderr", "Where to log warnings. May be a file path, stdout, stderr, or null.")
logLocationInfoPtr := flag.StringP("log-location-info", "i", "stderr",
"Where to log information messages. May be a file path, stdout, stderr, or
null.")
toInsecurePtr := flag.BoolP("traffic-ops-insecure", "s", false,
"Whether to ignore HTTPS certificate errors from Traffic Ops. It is HIGHLY
RECOMMENDED to never use this in a production environment, but only for
debugging.")
- toTimeoutMSPtr := flag.IntP("traffic-ops-timeout-milliseconds", "t",
60000, "Timeout in seconds for Traffic Ops requests.")
+ toTimeoutMSPtr := flag.IntP("traffic-ops-timeout-milliseconds", "t",
30000, "Timeout in seconds for Traffic Ops requests.")
versionPtr := flag.BoolP("version", "v", false, "Print version
information and exit.")
listPluginsPtr := flag.BoolP("list-plugins", "l", false, "Print the
list of plugins.")
helpPtr := flag.BoolP("help", "h", false, "Print usage information and
exit")
diff --git a/traffic_ops/ort/traffic_ops_ort.pl
b/traffic_ops/ort/traffic_ops_ort.pl
index 9f39579..51711ef 100755
--- a/traffic_ops/ort/traffic_ops_ort.pl
+++ b/traffic_ops/ort/traffic_ops_ort.pl
@@ -40,6 +40,7 @@ my $reval_in_use = 0;
my $rev_proxy_disable = 0;
my $skip_os_check = 0;
my $override_hostname_short = '';
+my $to_timeout_ms = 30000;
GetOptions( "dispersion=i" => \$dispersion, # dispersion (in seconds)
"retries=i" => \$retries,
@@ -48,6 +49,7 @@ GetOptions( "dispersion=i" => \$dispersion, #
dispersion (in seconds)
"rev_proxy_disable=i" => \$rev_proxy_disable,
"skip_os_check=i" => \$skip_os_check,
"override_hostname_short=s" => \$override_hostname_short,
+ "to_timeout_ms=i" => \$to_timeout_ms,
);
if ( $#ARGV < 1 ) {
@@ -149,6 +151,11 @@ if ($override_hostname_short ne '') {
}
chomp($hostname_short);
+my $atstccfg_timeout_arg='';
+if (length $to_timeout_ms > 0) {
+ $atstccfg_timeout_arg =
"--traffic-ops-timeout-milliseconds=$to_timeout_ms";
+}
+
my $atstccfg_cmd = '/opt/ort/atstccfg';
my $TMP_BASE = "/tmp/ort";
@@ -307,6 +314,7 @@ sub usage {
print "\t rev_proxy_disable=<0|1> => bypass the reverse proxy
even if one has been configured Default = 0.\n";
print "\t skip_os_check=<0|1> => bypass the check for a
supported CentOS version. Default = 0.\n";
print "\t override_hostname_short=<text> => override the short
hostname of the OS for config generation. Default = ''.\n";
+ print "\t to_timeout_ms=<time> => the Traffic Ops request
timeout in milliseconds. Default = 30000 (30 seconds).\n";
print
"====-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-====\n";
exit 1;
}
@@ -733,7 +741,7 @@ sub send_update_to_trops {
$reval_str='true';
}
- my $response = `$atstccfg_cmd --traffic-ops-user='$TO_USER'
--traffic-ops-password='$TO_PASS' --traffic-ops-url='$TO_URL'
--cache-host-name='$hostname_short' --log-location-error=stderr
--log-location-warning=stderr --log-location-info=null
--set-queue-status=$upd_str --set-reval-status=$reval_str 2>$atstccfg_log_path`;
+ my $response = `$atstccfg_cmd $atstccfg_timeout_arg
--traffic-ops-user='$TO_USER' --traffic-ops-password='$TO_PASS'
--traffic-ops-url='$TO_URL' --cache-host-name='$hostname_short'
--log-location-error=stderr --log-location-warning=stderr
--log-location-info=null --set-queue-status=$upd_str
--set-reval-status=$reval_str 2>$atstccfg_log_path`;
my $atstccfg_exit_code = $?;
if ($atstccfg_exit_code != 0) {
( $log_level >> $ERROR ) && printf("ERROR sending update status
with atstccfg (via Traffic Ops). See $atstccfg_log_path.\n");
@@ -743,7 +751,7 @@ sub send_update_to_trops {
}
sub get_update_status {
- my $upd_ref = `$atstccfg_cmd --traffic-ops-user='$TO_USER'
--traffic-ops-password='$TO_PASS' --traffic-ops-url='$TO_URL'
--cache-host-name='$hostname_short' --log-location-error=stderr
--log-location-warning=stderr --log-location-info=null --get-data=update-status
2>$atstccfg_log_path`;
+ my $upd_ref = `$atstccfg_cmd $atstccfg_timeout_arg
--traffic-ops-user='$TO_USER' --traffic-ops-password='$TO_PASS'
--traffic-ops-url='$TO_URL' --cache-host-name='$hostname_short'
--log-location-error=stderr --log-location-warning=stderr
--log-location-info=null --get-data=update-status 2>$atstccfg_log_path`;
my $atstccfg_exit_code = $?;
if ($atstccfg_exit_code != 0) {
( $log_level >> $ERROR ) && printf("ERROR getting update status
from atstccfg (via Traffic Ops). See $atstccfg_log_path.\n");
@@ -754,7 +762,7 @@ sub get_update_status {
##Some versions of Traffic Ops had the 1.3 API but did not have the
use_reval_pending field. If this field is not present, exit.
if ( !defined( $upd_json->{'use_reval_pending'} ) ) {
- my $info_ref = `$atstccfg_cmd --traffic-ops-user='$TO_USER'
--traffic-ops-password='$TO_PASS' --traffic-ops-url='$TO_URL'
--cache-host-name='$hostname_short' --log-location-error=stderr
--log-location-warning=stderr --log-location-info=null --get-data=system-info
2>$atstccfg_log_path`;
+ my $info_ref = `$atstccfg_cmd $atstccfg_timeout_arg
--traffic-ops-user='$TO_USER' --traffic-ops-password='$TO_PASS'
--traffic-ops-url='$TO_URL' --cache-host-name='$hostname_short'
--log-location-error=stderr --log-location-warning=stderr
--log-location-info=null --get-data=system-info 2>$atstccfg_log_path`;
my $atstccfg_exit_code = $?;
if ($atstccfg_exit_code != 0) {
( $log_level >> $ERROR ) && printf("ERROR Unable to get
status of use_reval_pending parameter. Stopping.\n");
@@ -809,7 +817,7 @@ sub check_revalidate_state {
( $log_level >> $ERROR ) && print "ERROR Traffic Ops is
signaling that no revalidations are waiting to be applied.\n";
}
- my $stj = `$atstccfg_cmd --traffic-ops-user='$TO_USER'
--traffic-ops-password='$TO_PASS' --traffic-ops-url='$TO_URL'
--cache-host-name='$hostname_short' --log-location-error=stderr
--log-location-warning=stderr --log-location-info=null --get-data=statuses
2>$atstccfg_log_path`;
+ my $stj = `$atstccfg_cmd $atstccfg_timeout_arg
--traffic-ops-user='$TO_USER' --traffic-ops-password='$TO_PASS'
--traffic-ops-url='$TO_URL' --cache-host-name='$hostname_short'
--log-location-error=stderr --log-location-warning=stderr
--log-location-info=null --get-data=statuses 2>$atstccfg_log_path`;
my $atstccfg_exit_code = $?;
if ( $atstccfg_exit_code != 0 ) {
( $log_level >> $ERROR ) && print "Statuses URL:
returned $stj! Skipping creation of status file.\n";
@@ -928,7 +936,7 @@ sub check_syncds_state {
( $log_level >> $ERROR ) && print "ERROR Traffic Ops is
signaling that no update is waiting to be applied.\n";
}
- my $stj = `$atstccfg_cmd --traffic-ops-user='$TO_USER'
--traffic-ops-password='$TO_PASS' --traffic-ops-url='$TO_URL'
--cache-host-name='$hostname_short' --log-location-error=stderr
--log-location-warning=stderr --log-location-info=null --get-data=statuses
2>$atstccfg_log_path`;
+ my $stj = `$atstccfg_cmd $atstccfg_timeout_arg
--traffic-ops-user='$TO_USER' --traffic-ops-password='$TO_PASS'
--traffic-ops-url='$TO_URL' --cache-host-name='$hostname_short'
--log-location-error=stderr --log-location-warning=stderr
--log-location-info=null --get-data=statuses 2>$atstccfg_log_path`;
my $atstccfg_exit_code = $?;
if ( $atstccfg_exit_code != 0 ) {
( $log_level >> $ERROR ) && print "Statuses URL:
returned $stj! Skipping creation of status file.\n";
@@ -1570,7 +1578,7 @@ sub get_cfg_file_list {
$atstccfg_reval_arg = '--revalidate-only';
}
- my $result = `$atstccfg_cmd --traffic-ops-user='$TO_USER'
--traffic-ops-password='$TO_PASS' --traffic-ops-url='$TO_URL'
--cache-host-name='$host_name' $atstccfg_reval_arg --log-location-error=stderr
--log-location-warning=stderr --log-location-info=null 2>$atstccfg_log_path`;
+ my $result = `$atstccfg_cmd $atstccfg_timeout_arg
--traffic-ops-user='$TO_USER' --traffic-ops-password='$TO_PASS'
--traffic-ops-url='$TO_URL' --cache-host-name='$host_name' $atstccfg_reval_arg
--log-location-error=stderr --log-location-warning=stderr
--log-location-info=null 2>$atstccfg_log_path`;
my $atstccfg_exit_code = $?;
if ($atstccfg_exit_code != 0) {
( $log_level >> $ERROR ) && printf("ERROR getting config files
from atstccfg via Traffic Ops. See $atstccfg_log_path for details\n");
@@ -1646,7 +1654,7 @@ sub parse_multipart_config_files {
sub get_header_comment {
my $toolname;
- my $result = `$atstccfg_cmd --traffic-ops-user='$TO_USER'
--traffic-ops-password='$TO_PASS' --traffic-ops-url='$TO_URL'
--cache-host-name='$hostname_short' --log-location-error=stderr
--log-location-warning=stderr --log-location-info=null --get-data=system-info
2>$atstccfg_log_path`;
+ my $result = `$atstccfg_cmd $atstccfg_timeout_arg
--traffic-ops-user='$TO_USER' --traffic-ops-password='$TO_PASS'
--traffic-ops-url='$TO_URL' --cache-host-name='$hostname_short'
--log-location-error=stderr --log-location-warning=stderr
--log-location-info=null --get-data=system-info 2>$atstccfg_log_path`;
my $atstccfg_exit_code = $?;
if ($atstccfg_exit_code != 0) {
( $log_level >> $ERROR ) && printf("ERROR Unable to get
system info. Stopping.\n");
@@ -1824,7 +1832,7 @@ sub process_packages {
my $proceed = 0;
- my $result = `$atstccfg_cmd --traffic-ops-user='$TO_USER'
--traffic-ops-password='$TO_PASS' --traffic-ops-url='$TO_URL'
--cache-host-name='$hostname_short' --log-location-error=stderr
--log-location-warning=stderr --log-location-info=null --get-data=packages
2>$atstccfg_log_path`;
+ my $result = `$atstccfg_cmd $atstccfg_timeout_arg
--traffic-ops-user='$TO_USER' --traffic-ops-password='$TO_PASS'
--traffic-ops-url='$TO_URL' --cache-host-name='$hostname_short'
--log-location-error=stderr --log-location-warning=stderr
--log-location-info=null --get-data=packages 2>$atstccfg_log_path`;
my $atstccfg_exit_code = $?;
if ($atstccfg_exit_code != 0) {
( $log_level >> $FATAL ) && print "FATAL Error getting package
list from Traffic Ops!\n";
@@ -2070,7 +2078,7 @@ sub process_chkconfig {
my $proceed = 0;
- my $result = `$atstccfg_cmd --traffic-ops-user='$TO_USER'
--traffic-ops-password='$TO_PASS' --traffic-ops-url='$TO_URL'
--cache-host-name='$hostname_short' --log-location-error=stderr
--log-location-warning=stderr --log-location-info=null --get-data=chkconfig
2>$atstccfg_log_path`;
+ my $result = `$atstccfg_cmd $atstccfg_timeout_arg
--traffic-ops-user='$TO_USER' --traffic-ops-password='$TO_PASS'
--traffic-ops-url='$TO_URL' --cache-host-name='$hostname_short'
--log-location-error=stderr --log-location-warning=stderr
--log-location-info=null --get-data=chkconfig 2>$atstccfg_log_path`;
my $atstccfg_exit_code = $?;
if ($atstccfg_exit_code != 0) {
( $log_level >> $FATAL ) && print "FATAL Error getting package
list from Traffic Ops!\n";