You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by ro...@apache.org on 2020/11/06 21:58:13 UTC
[trafficcontrol] branch master updated: t3c should use the --dir
option when calling atstccfg in order (#5251)
This is an automated email from the ASF dual-hosted git repository.
rob 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 24bbf64 t3c should use the --dir option when calling atstccfg in order (#5251)
24bbf64 is described below
commit 24bbf64d460620bf13510009c0c67ff4519655c2
Author: John J. Rushford <jr...@apache.org>
AuthorDate: Fri Nov 6 14:56:44 2020 -0700
t3c should use the --dir option when calling atstccfg in order (#5251)
to set the ATS configuration directory for config files that
have a relative or not 'Path'. Also, this re-orders the rpm
package check to occur before any config files are request from
traffic ops.
---
traffic_ops_ort/t3c/config/config.go | 23 +++++++++++++++--------
traffic_ops_ort/t3c/t3c.go | 14 ++++++--------
traffic_ops_ort/t3c/torequest/torequest.go | 1 +
3 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/traffic_ops_ort/t3c/config/config.go b/traffic_ops_ort/t3c/config/config.go
index 642c9d1..b17ef08 100644
--- a/traffic_ops_ort/t3c/config/config.go
+++ b/traffic_ops_ort/t3c/config/config.go
@@ -33,6 +33,7 @@ import (
)
var TSHome string = "/opt/trafficserver"
+var TSConfigDir string = "/opt/trafficserver/etc/trafficserver"
const (
StatusDir = "/opt/ort/status"
@@ -248,25 +249,31 @@ func GetCfg() (Cfg, error) {
if *toPassPtr == "" {
toPass = os.Getenv("TO_PASS")
}
+
// set TSHome
+ var tsHome = ""
if *tsHomePtr != "" {
- TSHome = *tsHomePtr
- fmt.Printf("\nset TSHome from command line: '%s'\n\n", TSHome)
+ tsHome = *tsHomePtr
+ fmt.Printf("set TSHome from command line: '%s'\n\n", TSHome)
}
- if *tsHomePtr == "" {
- tsHome := os.Getenv("TS_HOME") // check for the environment variable.
+ if *tsHomePtr == "" { // evironment or rpm check.
+ tsHome = os.Getenv("TS_HOME") // check for the environment variable.
if tsHome != "" {
- fmt.Printf("\nset TSHome from TS_HOME environment variable '%s'\n\n", TSHome)
+ fmt.Printf("set TSHome from TS_HOME environment variable '%s'\n", TSHome)
} else { // finally check using the config file listing from the rpm package.
tsHome = GetTSPackageHome()
if tsHome != "" {
- TSHome = tsHome
- fmt.Printf("\nset TSHome from the RPM config file list '%s'\n\n", TSHome)
+ fmt.Printf("set TSHome from the RPM config file list '%s'\n", tsHome)
} else {
- fmt.Printf("\nno override for TSHome was found, using the configured default: '%s'\n\n", TSHome)
+ fmt.Printf("no override for TSHome was found, using the configured default: '%s'\n", TSHome)
}
}
}
+ if tsHome != "" {
+ TSHome = tsHome
+ TSConfigDir = tsHome + "/etc/trafficserver"
+ fmt.Printf("TSHome: %s, TSConfigDir: %s\n", TSHome, TSConfigDir)
+ }
usageStr := "basic usage: t3c --traffic-ops-url=myurl --traffic-ops-user=myuser --traffic-ops-password=mypass --cache-host-name=my-cache"
if strings.TrimSpace(toURL) == "" {
diff --git a/traffic_ops_ort/t3c/t3c.go b/traffic_ops_ort/t3c/t3c.go
index 5dd8484..6df1a6d 100644
--- a/traffic_ops_ort/t3c/t3c.go
+++ b/traffic_ops_ort/t3c/t3c.go
@@ -113,14 +113,6 @@ func main() {
}
}
- log.Debugf("Preparing to fetch the config files for %s, cfg.RunMode: %s, syncdsUpdate: %s\n", cfg.CacheHostName, cfg.RunMode, syncdsUpdate)
-
- err = trops.GetConfigFileList()
- if err != nil {
- log.Errorf("Unable to continue: %s\n", err)
- os.Exit(ConfigFilesError)
- }
-
if cfg.RunMode == config.Revalidate {
log.Infoln("======== Revalidating, no package processing needed ========")
} else {
@@ -139,6 +131,12 @@ func main() {
}
}
+ log.Debugf("Preparing to fetch the config files for %s, cfg.RunMode: %s, syncdsUpdate: %s\n", cfg.CacheHostName, cfg.RunMode, syncdsUpdate)
+ err = trops.GetConfigFileList()
+ if err != nil {
+ log.Errorf("Unable to continue: %s\n", err)
+ os.Exit(ConfigFilesError)
+ }
syncdsUpdate, err = trops.ProcessConfigFiles()
if err != nil {
log.Errorf("Error while processing config files: %s\n", err.Error())
diff --git a/traffic_ops_ort/t3c/torequest/torequest.go b/traffic_ops_ort/t3c/torequest/torequest.go
index b413142..305be62 100644
--- a/traffic_ops_ort/t3c/torequest/torequest.go
+++ b/traffic_ops_ort/t3c/torequest/torequest.go
@@ -212,6 +212,7 @@ func (r *TrafficOpsReq) atsTcExecCommand(cmdstr string, queueState int, revalSta
}
args := []string{
+ "--dir=" + config.TSConfigDir,
"--traffic-ops-timeout-milliseconds=" + strconv.FormatInt(int64(r.Cfg.TOTimeoutMS), 10),
"--traffic-ops-disable-proxy=" + strconv.FormatBool(r.Cfg.ReverseProxyDisable),
"--traffic-ops-user=" + r.Cfg.TOUser,