This is an automated email from the ASF dual-hosted git repository.

rrm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 582de97b38 Add better logging for origin_server_auth (#11885)
582de97b38 is described below

commit 582de97b3897156e0038f2e374f36022b950900e
Author: Jasmine Emanouel <[email protected]>
AuthorDate: Thu Dec 12 04:22:10 2024 +1100

    Add better logging for origin_server_auth (#11885)
---
 plugins/origin_server_auth/origin_server_auth.cc | 31 +++++++++++++-----------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/plugins/origin_server_auth/origin_server_auth.cc 
b/plugins/origin_server_auth/origin_server_auth.cc
index ec9b28cb42..609d575c30 100644
--- a/plugins/origin_server_auth/origin_server_auth.cc
+++ b/plugins/origin_server_auth/origin_server_auth.cc
@@ -230,12 +230,12 @@ public:
     /* Check mandatory parameters first */
     if (versions::gcpv1 == _version && (!_token || !(_token_len > 0))) {
       Dbg(dbg_ctl, "version = %s; keyid = %s", versionString(), _keyid);
-      TSWarning("[%s] missing mandatory configs for version: %s", PLUGIN_NAME, 
versionString());
+      TSWarning("[%s] missing mandatory configs for version: %s in file: %s", 
PLUGIN_NAME, versionString(), _conf_fname);
       return false;
     } else if ((versions::awsv2 == _version || versions::awsv4 == _version) &&
                (!_secret || !(_secret_len > 0) || !_keyid || !(_keyid_len > 
0))) {
       Dbg(dbg_ctl, "version = %s; keyid = %s; secret = %s", versionString(), 
_keyid, _secret);
-      TSWarning("[%s] missing mandatory configs for version: %s", PLUGIN_NAME, 
versionString());
+      TSWarning("[%s] missing mandatory configs for version: %s in file: %s", 
PLUGIN_NAME, versionString(), _conf_fname);
       return false;
     }
 
@@ -632,7 +632,7 @@ S3Config::parse_config(const std::string &config_fname)
       } else if (key_str == "expiration") {
         set_expiration(val_str.c_str());
       } else {
-        TSWarning("[%s] unknown config key: %s", PLUGIN_NAME, key_str.c_str());
+        TSWarning("[%s] unknown config key: %s in file: %s", PLUGIN_NAME, 
key_str.c_str(), config_fname.c_str());
       }
     }
   }
@@ -1096,11 +1096,11 @@ config_reloader(TSCont cont, TSEvent /* event 
ATS_UNUSED */, void *edata)
   Dbg(dbg_ctl, "reloading configs");
   S3Config *s3 = static_cast<S3Config *>(TSContDataGet(cont));
   s3->check_current_action(edata);
-
-  S3Config *file_config = gConfCache.get(s3->conf_fname());
+  S3Config   *file_config  = gConfCache.get(s3->conf_fname());
+  std::string config_fname = makeConfigPath(file_config->conf_fname());
 
   if (!file_config || !file_config->valid()) {
-    TSError("[%s] invalid configuration. Check mandatory fields. Scheduling 
reload", PLUGIN_NAME);
+    TSError("[%s] invalid configuration in file: %s. Check mandatory fields. 
Scheduling reload", PLUGIN_NAME, config_fname.c_str());
     long delay = 1 << s3->incr_invalid_file_count();
     s3->schedule_conf_reload(delay);
     return TS_ERROR;
@@ -1120,13 +1120,14 @@ config_reloader(TSCont cont, TSEvent /* event 
ATS_UNUSED */, void *edata)
                      
std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count();
     if (time_diff > 0) {
       long delay = cal_reload_delay(time_diff);
-      Dbg(dbg_ctl, "scheduling config reload with %ld seconds delay", delay);
+      TSNote("scheduling config reload with %ld seconds delay for file: %s", 
delay, config_fname.c_str());
       s3->reset_conf_reload_count();
       s3->schedule_conf_reload(delay);
     } else {
-      Dbg(dbg_ctl, "config expiration time is in the past, re-checking in 1 
minute");
-      if (s3->incr_conf_reload_count() == 10) {
-        TSError("[%s] tried to reload config automatically but failed, please 
try manual reloading the config", PLUGIN_NAME);
+      Dbg(dbg_ctl, "config expiration time for file: %s is in the past, 
re-checking in 1 minute", config_fname.c_str());
+      if (s3->incr_conf_reload_count() % 10 == 0) {
+        TSError("[%s] tried to reload config automatically but failed, please 
try manual reloading the config file: %s",
+                PLUGIN_NAME, config_fname.c_str());
       }
       s3->schedule_conf_reload(60);
     }
@@ -1220,26 +1221,28 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, 
char * /* errbuf ATS_UNUSE
   if (file_config) {
     s3->copy_changes_from(file_config);
   }
+
+  std::string config_fname = makeConfigPath(s3->conf_fname());
   // Make sure the configuration is valid
   if (!s3->valid()) {
-    TSError("[%s] invalid configuration. Check mandatory fields.", 
PLUGIN_NAME);
+    TSError("[%s] invalid configuration file: %s. Check mandatory fields.", 
PLUGIN_NAME, config_fname.c_str());
     *ih = nullptr;
     return TS_ERROR;
   }
 
   if (s3->expiration() == 0) {
-    Dbg(dbg_ctl, "disabling auto config reload");
+    Dbg(dbg_ctl, "disabling auto config reload for file: %s", 
config_fname.c_str());
   } else {
     // auto reload is scheduled to be 5 minutes before the expiration time to 
get some headroom
     long time_diff = s3->expiration() -
                      
std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count();
     if (time_diff > 0) {
       long delay = cal_reload_delay(time_diff);
-      Dbg(dbg_ctl, "scheduling config reload with %ld seconds delay", delay);
+      TSNote("[%s] scheduling config reload with %ld seconds delay for file: 
%s", PLUGIN_NAME, delay, config_fname.c_str());
       s3->reset_conf_reload_count();
       s3->schedule_conf_reload(delay);
     } else {
-      Dbg(dbg_ctl, "config expiration time is in the past, re-checking in 1 
minute");
+      Dbg(dbg_ctl, "config expiration time for file %s is in the past, 
re-checking in 1 minute", config_fname.c_str());
       s3->schedule_conf_reload(60);
     }
   }

Reply via email to