Skip to content

Commit

Permalink
fix(dataplanes): correct MeshService regexp based matching (#3240)
Browse files Browse the repository at this point in the history
Sometimes clusterNames can have hashes after the port. This means some
of our clusterName matching is a little too strict.

This PR remove the "end of line" match from our `_msvc_` regexp matching
to make sure we also match services with hashes after the port.

Closes #3238

---------

Signed-off-by: John Cowen <[email protected]>
Signed-off-by: John Cowen <[email protected]>
Co-authored-by: Charly Molter <[email protected]>
  • Loading branch information
johncowen and lahabana authored Dec 3, 2024
1 parent 73c3d1a commit c3c7164
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Feature: mesh / dataplanes / connections / clusterNames
Scenario: MeshServices type clusterNames with hashes are matched correctly
Given the CSS selectors
| Alias | Selector |
| outbound | [data-testid='dataplane-outbound'] |
And the URL "/meshes/mesh-name/dataplanes/edge-gateway-546b7bbbc9-mkhx6.kuma-demo/stats" responds with
"""
body: |
cluster.default_demo-app_kuma-demo_default_msvc_5000-5d788f7a87b92639.upstream_rq_tx_reset: 0
"""
When I visit the "/meshes/mesh-name/data-planes/edge-gateway-546b7bbbc9-mkhx6.kuma-demo/overview?inactive" URL
And the "$outbound" element contains "default_demo-app_kuma-demo_default_msvc_5000-5d788f7a87b92639"

Scenario: MeshServices type clusterNames without hashes are matched correctly
Given the CSS selectors
| Alias | Selector |
| outbound | [data-testid='dataplane-outbound'] |
And the URL "/meshes/mesh-name/dataplanes/edge-gateway-546b7bbbc9-mkhx6.kuma-demo/stats" responds with
"""
body: |
cluster.default_demo-app_kuma-demo_default_msvc_5000.upstream_rq_tx_reset: 0
"""
When I visit the "/meshes/mesh-name/data-planes/edge-gateway-546b7bbbc9-mkhx6.kuma-demo/overview?inactive" URL
And the "$outbound" element contains "default_demo-app_kuma-demo_default_msvc_5000"

2 changes: 1 addition & 1 deletion packages/kuma-gui/src/app/connections/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const appProtocols = ['http', 'tcp', 'grpc'] as const
// `_` followed by 1 to 5 digits followed by a `.`
const trailingPortRe = /_\d{1,5}\./
const trailingPortRe2 = /_\d{1,5}/
const meshServiceRe = /_(mz|m|ext){1}svc_\d{1,5}$/
const meshServiceRe = /_(mz|m|ext){1}svc_\d{1,5}(-[a-z0-9]+)?$/

export const Stat = {
fromCollection(items: string) {
Expand Down

0 comments on commit c3c7164

Please sign in to comment.