Skip to content

Conversation

@tkan145
Copy link
Contributor

@tkan145 tkan145 commented Feb 7, 2025

What

Fix https://issues.redhat.com/browse/THREESCALE-6116

More details in #1530

Verification steps

  • Build image from this branch
make runtime-image IMAGE_NAME=apicast-test
  • Get into dev-environment
cd dev-environments/plain-http-upstream
  • Edit apicast-config.json file
diff --git a/dev-environments/plain-http-upstream/apicast-config.json b/dev-environments/plain-http-upstream/apicast-config.json
index ff944273..2643bbad 100644
--- a/dev-environments/plain-http-upstream/apicast-config.json
+++ b/dev-environments/plain-http-upstream/apicast-config.json
@@ -11,6 +11,27 @@
           "host": "backend"
         },
         "policy_chain": [
+          {
+            "name": "apicast.policy.conditional",
+            "configuration": {
+              "condition": {
+                "operations": [
+                  {
+                    "left": "{{ uri }}",
+                    "left_type": "liquid",
+                    "op": "==",
+                    "right": "/log",
+                    "right_type": "plain"
+                  }
+                ]
+              },
+              "policy_chain": [
+                {
+                  "name": "apicast.policy.phase_logger"
+                }
+              ]
+            }
+          },
           {
             "name": "apicast.policy.apicast"
           }
@@ -23,6 +44,14 @@
             "delta": 1,
             "parameters": [],
             "querystring_parameters": {}
+          },
+          {
+            "http_method": "GET",
+            "pattern": "/log",
+            "metric_system_name": "hits",
+            "delta": 1,
+            "parameters": [],
+            "querystring_parameters": {}
           }
         ]
       }
  • Start gateway
make gateway IMAGE_NAME=apicast-test
  • In other terminal, fetch policies, and then filter by name
curl --resolve get.example.com:8090:127.0.0.1 -v "http://get.example.com:8090/policies" 2>/dev/null | jq '.policies.conditional'
  • The policy conditional does not exists
  • Now send another request
curl --resolve get.example.com:8080:127.0.0.1 -v "http://get.example.com:8080/log?user_key=foo"
  • You shall see phase_logger.lua:38: running phase: ... in the log

@tkan145 tkan145 requested a review from a team as a code owner February 7, 2025 03:07
Previously, the Conditional policy appeared in the portal UI but users could
not select the nested policy, making it unuseable.

It turned out that it was difficult to display the nested policy chain in the
UI, so removed it from the UI entirely
@tkan145 tkan145 force-pushed the THREESCALE-6116-conditional-policy-ui branch from 2c46421 to 2598cc2 Compare February 7, 2025 03:18
@tkan145 tkan145 merged commit 9572bf0 into 3scale:master Feb 16, 2025
14 checks passed
@tkan145 tkan145 deleted the THREESCALE-6116-conditional-policy-ui branch February 16, 2025 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants