Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Routing: Fix issues with invalid metric update on routing policy. #1125

Merged
merged 1 commit into from
Oct 17, 2019

Conversation

eloycoto
Copy link
Contributor

Due to the changes in APIAP in 3Scale, a service can have multiple
backends(using routing policy) and multiple mapping rules can be hit and
it creates a bad behaviour around metrics reported to Apisonator.

This commit adds ownership on routing and mapping rules, where a
ownership can be used to filter the mapping rules that you want to
report. Here an example:

Routing policy:

path      backend           owner
----------------------------------
/foo/bar  http://1.1.1.1/   t1
/foo      http://2.2.2.2/   t2

Mapping rules:

path      metric        owner
-----------------------------------
/foo      hits          t2
/foo/bar  barMetric     t1

In this case, due to the request is going to /foo/bar the metric that
will be updated will be barMetric and it'll use 2.2.2.2 backend, the
mapping rules to match will filter by the owner, in this case, t2.

@eloycoto eloycoto requested a review from a team as a code owner October 14, 2019 16:35
@@ -123,7 +124,8 @@ function _M.from_proxy_rule(proxy_rule)
proxy_rule.querystring_parameters,
proxy_rule.metric_system_name,
proxy_rule.delta,
proxy_rule.last
proxy_rule.last,
tonumber(proxy_rule.owner_id)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you really want to use owner_id here instead of the proposed backend_id, then you will also need owner_type. That's because the proxy rule can belong to a product (owner_type == "Proxy") or to a backend (owner_type == "BackendApi"). In the first case, it should be considered for the match despite owner_id, while in the latter case, only if owner_id matches the one of the routing.

gateway/src/apicast/mapping_rule.lua Show resolved Hide resolved
gateway/src/apicast/mapping_rule.lua Show resolved Hide resolved
gateway/src/apicast/policy/routing/rule.lua Show resolved Hide resolved
gateway/src/apicast/usage.lua Outdated Show resolved Hide resolved
spec/policy/routing/routing_spec.lua Show resolved Hide resolved
gateway/src/apicast/upstream.lua Outdated Show resolved Hide resolved
gateway/src/apicast/mapping_rules_matcher.lua Show resolved Hide resolved
gateway/src/apicast/proxy.lua Outdated Show resolved Hide resolved
gateway/src/apicast/proxy.lua Outdated Show resolved Hide resolved
@eloycoto eloycoto force-pushed the RoutingIssues branch 5 times, most recently from 2b34620 to e91ee50 Compare October 16, 2019 14:38
@eloycoto eloycoto requested a review from davidor October 16, 2019 14:43
@davidor
Copy link
Contributor

davidor commented Oct 16, 2019

I've reviewed the latest changes. I think the PR looks good except for this #1125 (comment) I think it's still an issue.

@eloycoto
Copy link
Contributor Author

Due to the changes in APIAP in 3Scale, a service can have multiple
backends(using routing policy) and multiple mapping rules can be hit and
it creates a bad behaviour around metrics reported to Apisonator.

This commit adds a ownership field on routing and mapping rules, where a
ownership can be used to filter the mapping rules that you want to
report. Here an example:

Routing policy:

```
path      backend           owner
----------------------------------
/foo/bar  http://1.1.1.1/   t1
/foo      http://2.2.2.2/   t2
```

Mapping rules:

```
path      metric        owner
-----------------------------------
/foo      hits          t2
/foo/bar  barMetric     t1
```

In this case, due to the request is going to /foo/bar the metric that
will be updated will be `barMetric` and it'll use `2.2.2.2` backend, the
mapping rules to match will filter by the owner, in this case, t2.

Signed-off-by: Eloy Coto <[email protected]>
@eloycoto eloycoto merged commit b6aaa3b into 3scale:master Oct 17, 2019
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.

3 participants