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

bnolsen 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 75ce27ec67 parent_select plugin: look in ats config dir for yaml 
config if path is relative (#9764)
75ce27ec67 is described below

commit 75ce27ec6771ce6ed928ce24daa21ee308fd4b69
Author: Brian Olsen <[email protected]>
AuthorDate: Thu Jun 1 14:57:30 2023 -0600

    parent_select plugin: look in ats config dir for yaml config if path is 
relative (#9764)
    
    * parent_select plugin: look in ats config dir for yaml config if path is 
relative
    
    * update autests to exercise parent_select.so relpath yaml config
    
    * shrink the amount of code changed
    
    ---------
    
    Co-authored-by: Brian Olsen <[email protected]>
---
 doc/admin-guide/files/strategies.yaml.en.rst              |  2 +-
 plugins/experimental/parent_select/parent_select.cc       | 15 +++++++++++----
 .../parent_select_optional_scheme_matching.test.py        |  4 +---
 .../pluginTest/parent_select/parent_select_peer.test.py   |  2 +-
 .../pluginTest/parent_select/parent_select_peer2.test.py  |  4 +---
 5 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/doc/admin-guide/files/strategies.yaml.en.rst 
b/doc/admin-guide/files/strategies.yaml.en.rst
index 7b78395e09..f5b8443c17 100644
--- a/doc/admin-guide/files/strategies.yaml.en.rst
+++ b/doc/admin-guide/files/strategies.yaml.en.rst
@@ -34,7 +34,7 @@ Traffic Server uses the :file:`strategies.yaml` file only 
when one or more
 remap lines in remap.config specifies the use of a strategy with the @strategy 
tag.
 remap.config Example::
 
-  map http://www.foo.com http://www.bar.com @strategy='mid-tier-north'
+  map http://www.foo.com http://www.bar.com @strategy=mid-tier-north
 
 After you modify the :file:`strategies.yaml` file, run the 
:option:`traffic_ctl config reload`
 command to apply your changes.
diff --git a/plugins/experimental/parent_select/parent_select.cc 
b/plugins/experimental/parent_select/parent_select.cc
index 0408ac39e8..6ed8f5b783 100644
--- a/plugins/experimental/parent_select/parent_select.cc
+++ b/plugins/experimental/parent_select/parent_select.cc
@@ -25,6 +25,7 @@
 #include <iostream>
 #include <map>
 #include <memory>
+#include <filesystem>
 #include <fstream>
 #include <cstdlib>
 #include <cstring>
@@ -271,10 +272,16 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, 
char *errbuff, int errbuff
     return TS_ERROR;
   }
 
-  const char *remap_from       = argv[0];
-  const char *remap_to         = argv[1];
-  const char *config_file_path = argv[2];
-  const char *strategy_name    = argv[3];
+  const char *remap_from                     = argv[0];
+  const char *remap_to                       = argv[1];
+  std::filesystem::path config_file_path_obj = argv[2];
+  const char *strategy_name                  = argv[3];
+
+  if (config_file_path_obj.is_relative()) {
+    config_file_path_obj = std::filesystem::path(TSConfigDirGet()) / 
config_file_path_obj;
+  }
+
+  const char *const config_file_path = config_file_path_obj.c_str();
 
   TSDebug(PLUGIN_NAME, "%s %s Loading parent selection strategy file %s for 
strategy %s", remap_from, remap_to, config_file_path,
           strategy_name);
diff --git 
a/tests/gold_tests/pluginTest/parent_select/parent_select_optional_scheme_matching.test.py
 
b/tests/gold_tests/pluginTest/parent_select/parent_select_optional_scheme_matching.test.py
index 4df05036b2..fd0362528d 100755
--- 
a/tests/gold_tests/pluginTest/parent_select/parent_select_optional_scheme_matching.test.py
+++ 
b/tests/gold_tests/pluginTest/parent_select/parent_select_optional_scheme_matching.test.py
@@ -106,9 +106,7 @@ s.AddLines([
     "      - *g1"])
 
 ts.Disk.remap_config.AddLine(
-    "map http://dummy.com http://not_used @plugin=parent_select.so @pparam=" +
-    ts.Variables.CONFIGDIR +
-    "/strategies.yaml @pparam=the-strategy")
+    "map http://dummy.com http://not_used @plugin=parent_select.so 
@pparam=strategies.yaml @pparam=the-strategy")
 
 tr = Test.AddTestRun()
 tr.Processes.Default.StartBefore(server)
diff --git 
a/tests/gold_tests/pluginTest/parent_select/parent_select_peer.test.py 
b/tests/gold_tests/pluginTest/parent_select/parent_select_peer.test.py
index deec6a2d34..fcc8d7594b 100644
--- a/tests/gold_tests/pluginTest/parent_select/parent_select_peer.test.py
+++ b/tests/gold_tests/pluginTest/parent_select/parent_select_peer.test.py
@@ -135,7 +135,7 @@ for i in range(num_peer):
         #"        - passive",
     ])
 
-    suffix = f" @plugin=parent_select.so 
@pparam={ts.Variables.CONFIGDIR}/strategies.yaml @pparam=the-strategy 
@plugin=cachekey.so @pparam=--uri-type=remap 
@pparam=--capture-prefix=/(.*):(.*)/$1/"
+    suffix = " @plugin=parent_select.so @pparam=strategies.yaml 
@pparam=the-strategy @plugin=cachekey.so @pparam=--uri-type=remap 
@pparam=--capture-prefix=/(.*):(.*)/$1/"
     ts.Disk.remap_config.AddLines([
         "map http://dummy.com http://not_used"; + suffix,
         "map http://not_used http://also_not_used"; + suffix,
diff --git 
a/tests/gold_tests/pluginTest/parent_select/parent_select_peer2.test.py 
b/tests/gold_tests/pluginTest/parent_select/parent_select_peer2.test.py
index 25a7f9f634..48a6f6078b 100644
--- a/tests/gold_tests/pluginTest/parent_select/parent_select_peer2.test.py
+++ b/tests/gold_tests/pluginTest/parent_select/parent_select_peer2.test.py
@@ -128,9 +128,7 @@ for i in range(num_peer):
     for i in range(num_upstream):
         prefix = f"http://ts_upstream{i}:{ts_upstream[i].Variables.port}/";
         ts.Disk.remap_config.AddLine(
-            f"map {prefix} {prefix} @plugin=parent_select.so @pparam=" +
-            ts.Variables.CONFIGDIR +
-            "/strategies.yaml @pparam=the-strategy")
+            f"map {prefix} {prefix} @plugin=parent_select.so 
@pparam=strategies.yaml @pparam=the-strategy")
 
 tr = Test.AddTestRun()
 tr.Processes.Default.StartBefore(server)

Reply via email to