This is an automated email from the ASF dual-hosted git repository.
masaori 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 359feb7506 Fix logging for origin_server_auth (#12115)
359feb7506 is described below
commit 359feb7506117826280eb2a83b68d6b968f25cd1
Author: Jasmine Emanouel <[email protected]>
AuthorDate: Mon Mar 24 12:42:43 2025 +1100
Fix logging for origin_server_auth (#12115)
* Fix logging for origin_server_auth
* Update test
* Update origin_server_auth.test.py
---
plugins/origin_server_auth/origin_server_auth.cc | 31 +++++++++++++---------
.../origin_server_auth/origin_server_auth.test.py | 5 ++--
.../rules/gcp-parse-test.test_input | 31 ----------------------
3 files changed, 21 insertions(+), 46 deletions(-)
diff --git a/plugins/origin_server_auth/origin_server_auth.cc
b/plugins/origin_server_auth/origin_server_auth.cc
index 7a73c2e7cf..affd975867 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 in file: %s",
PLUGIN_NAME, versionString(), _conf_fname);
+ TSWarning("[%s] missing mandatory configs for version: %s %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 in file: %s",
PLUGIN_NAME, versionString(), _conf_fname);
+ TSWarning("[%s] missing mandatory configs for version: %s %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 in file: %s", PLUGIN_NAME,
key_str.c_str(), config_fname.c_str());
+ TSWarning("[%s] unknown config key: %s %s", PLUGIN_NAME,
key_str.c_str(), config_fname.c_str());
}
}
}
@@ -1097,10 +1097,11 @@ config_reloader(TSCont cont, TSEvent /* event
ATS_UNUSED */, void *edata)
S3Config *s3 = static_cast<S3Config *>(TSContDataGet(cont));
s3->check_current_action(edata);
S3Config *file_config = gConfCache.get(s3->conf_fname());
- std::string config_fname = makeConfigPath(s3->conf_fname());
+ std::string config_fname = makeConfigPath(s3->conf_fname() == nullptr ? "" :
s3->conf_fname());
if (!file_config || !file_config->valid()) {
- TSError("[%s] invalid configuration in file: %s. Check mandatory fields.
Scheduling reload", PLUGIN_NAME, config_fname.c_str());
+ TSError("[%s] invalid configuration for version: %s %s. Check mandatory
fields. Scheduling reload", PLUGIN_NAME,
+ s3->versionString(), config_fname.c_str());
long delay = 1 << s3->incr_invalid_file_count();
s3->schedule_conf_reload(delay);
return TS_ERROR;
@@ -1113,18 +1114,20 @@ config_reloader(TSCont cont, TSEvent /* event
ATS_UNUSED */, void *edata)
}
if (s3->expiration() == 0) {
- Dbg(dbg_ctl, "disabling auto config reload");
+ Dbg(dbg_ctl, "disabling auto config reload for version: %s %s",
s3->versionString(), 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);
- TSNote("scheduling config reload with %ld seconds delay for file: %s",
delay, config_fname.c_str());
+ TSNote("scheduling config reload with %ld seconds delay for version: %s
%s", delay, s3->versionString(),
+ config_fname.c_str());
s3->reset_conf_reload_count();
s3->schedule_conf_reload(delay);
} else {
- Dbg(dbg_ctl, "config expiration time for file: %s is in the past,
re-checking in 1 minute", config_fname.c_str());
+ Dbg(dbg_ctl, "config expiration time for version: %s %s is in the past,
re-checking in 1 minute", s3->versionString(),
+ 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());
@@ -1222,27 +1225,29 @@ TSRemapNewInstance(int argc, char *argv[], void **ih,
char * /* errbuf ATS_UNUSE
s3->copy_changes_from(file_config);
}
- std::string config_fname = makeConfigPath(s3->conf_fname());
+ std::string config_fname = makeConfigPath(s3->conf_fname() == nullptr ? "" :
s3->conf_fname());
// Make sure the configuration is valid
if (!s3->valid()) {
- TSError("[%s] invalid configuration file: %s. Check mandatory fields.",
PLUGIN_NAME, config_fname.c_str());
+ TSError("[%s] invalid configuration %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 for file: %s",
config_fname.c_str());
+ Dbg(dbg_ctl, "disabling auto config reload for version: %s %s",
s3->versionString(), 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);
- TSNote("[%s] scheduling config reload with %ld seconds delay for file:
%s", PLUGIN_NAME, delay, config_fname.c_str());
+ TSNote("[%s] scheduling config reload with %ld seconds delay for
version: %s %s", PLUGIN_NAME, delay, s3->versionString(),
+ config_fname.c_str());
s3->reset_conf_reload_count();
s3->schedule_conf_reload(delay);
} else {
- Dbg(dbg_ctl, "config expiration time for file %s is in the past,
re-checking in 1 minute", config_fname.c_str());
+ Dbg(dbg_ctl, "config expiration time for version %s %s is in the past,
re-checking in 1 minute", s3->versionString(),
+ config_fname.c_str());
s3->schedule_conf_reload(60);
}
}
diff --git
a/tests/gold_tests/pluginTest/origin_server_auth/origin_server_auth.test.py
b/tests/gold_tests/pluginTest/origin_server_auth/origin_server_auth.test.py
index a884dcc897..5f00768b56 100644
--- a/tests/gold_tests/pluginTest/origin_server_auth/origin_server_auth.test.py
+++ b/tests/gold_tests/pluginTest/origin_server_auth/origin_server_auth.test.py
@@ -79,7 +79,6 @@ class OriginServerAuthTest:
})
self.ts.Setup.CopyAs('rules/v4-parse-test.test_input',
Test.RunDirectory)
- self.ts.Setup.CopyAs('rules/gcp-parse-test.test_input',
Test.RunDirectory)
self.ts.Disk.remap_config.AddLine(
f'map http://www.example.com/s3-bucket
http://127.0.0.1:{self.server.Variables.Port}/s3-bucket \
@@ -89,7 +88,9 @@ class OriginServerAuthTest:
self.ts.Disk.remap_config.AddLine(
f'map http://www.example.com/gcp
http://127.0.0.1:{self.server.Variables.Port}/gcp \
@plugin=origin_server_auth.so \
- @pparam=--config
@pparam={Test.RunDirectory}/gcp-parse-test.test_input')
+ @pparam=--access_key @pparam=1234567 \
+ @pparam=--session_token
@pparam=hkMsi6/bfHyBKrSeM/H0hoXeyx8z1yZ/mJ0c+B/TqYx=tTJDjnQWtul38Z9iVJjeH1HB4VT2c=2o3yE3o=I9kmFs/lJDR85qWjB8e5asY/WbjyRpbAzmDipQpboIcYnUYg55bxrQFidV/q8gZa5A9MpR3n=op1C0lWjeBqcEJxpevNZxteSQTQfeGsi98Cdf+On=/SINVlKrNhMnmMsDOLMGx1YYt9d4UsRg1jtVrwxL4Vd/F7aHCZySAXKv+1rkhACR023wpa3dhp+xirGJxSO9LWwvcrTdM4xJo4RS8B40tGENOJ1NKixUJxwN/6og58Oft/u==uleR89Ja=7zszK2H7tX3DqmEYNvNDYQh/7VBRe5otghQtPwJzWpXAGk+Vme4hPPM5K6axH2LxipXzRiIV=oxNs0upKNu1FvuzbCQmkQdKQVmXl0344v
[...]
+ @pparam=--version @pparam=gcpv1')
def test_s3_origin_remap(self):
'''
diff --git
a/tests/gold_tests/pluginTest/origin_server_auth/rules/gcp-parse-test.test_input
b/tests/gold_tests/pluginTest/origin_server_auth/rules/gcp-parse-test.test_input
deleted file mode 100644
index e947a671eb..0000000000
---
a/tests/gold_tests/pluginTest/origin_server_auth/rules/gcp-parse-test.test_input
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Test empty lines
-
-# Test space in front
- access_key=1234567
-
-# long line, space behind
-session_token=hkMsi6/bfHyBKrSeM/H0hoXeyx8z1yZ/mJ0c+B/TqYx=tTJDjnQWtul38Z9iVJjeH1HB4VT2c=2o3yE3o=I9kmFs/lJDR85qWjB8e5asY/WbjyRpbAzmDipQpboIcYnUYg55bxrQFidV/q8gZa5A9MpR3n=op1C0lWjeBqcEJxpevNZxteSQTQfeGsi98Cdf+On=/SINVlKrNhMnmMsDOLMGx1YYt9d4UsRg1jtVrwxL4Vd/F7aHCZySAXKv+1rkhACR023wpa3dhp+xirGJxSO9LWwvcrTdM4xJo4RS8B40tGENOJ1NKixUJxwN/6og58Oft/u==uleR89Ja=7zszK2H7tX3DqmEYNvNDYQh/7VBRe5otghQtPwJzWpXAGk+Vme4hPPM5K6axH2LxipXzRiIV=oxNs0upKNu1FvuzbCQmkQdKQVmXl0344vngngrgN7wkEfrYtmKwICmpAS0cbW9jdSCl
[...]
-
-version=gcpv1
-
-# Test a key without value
-virtual_host
-
-