-
Notifications
You must be signed in to change notification settings - Fork 22
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
feature(dataplanes): add filtered XDS config to drawers #3186
feature(dataplanes): add filtered XDS config to drawers #3186
Conversation
✅ Deploy Preview for kuma-gui ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
616b635
to
876dce4
Compare
eef2826
to
6d92432
Compare
Signed-off-by: John Cowen <[email protected]>
6c11ff6
to
268c360
Compare
Signed-off-by: John Cowen <[email protected]>
268c360
to
60e74c5
Compare
Signed-off-by: John Cowen <[email protected]>
944f176
to
c42fe8d
Compare
Looks great! There's only 1 bug with clusters https://konghq.zoom.us/clips/share/A2F3MRZnZDRPSjZfT1E5bVhNRTRERWl1MnlnAQ For the inbound issue I observe: kumahq/kuma#12123 |
PR to fix up the issue with clusters is here: |
I agree with this 👍 since you speak about readability, I'd like to bring up no-nested-ternary 🙂 I think this might be a good addition to our lint rules as it enforces short and one-lined ternary expressions, which are great. But when it comes to more complex flows, I'd rather use |
More than happy to take look at it. The only thing is ternaries are about more than readability, they allow you to have type safety at runtime in javascript, which while I don't think is as important as the type safety, I believe is also a micro-performance improvement in javascript engines (but lets not get into micro-optimizations, thats side benefit) Its not so much using the ternaries, its more the avoidance of using let a = '1'
if(true) {
a = '2'
}
// a is a string vs const a = true ? '2' : '1'
// a is '1' | '2' In the second form:
So I use these inline forms a lot (and did previous to Typescript) via ternaries and inline functions for I have an example of a change a made recently that outlines this, lemme try and find it. edit: Not a ternary but its the same idea, if you take a look at this code from a recent PR (😆 oh its actually this PR): kuma-gui/packages/kuma-gui/src/test-support/mocks/src/meshes/_/dataplanes/_/_overview.ts Lines 21 to 26 in 765d9f5
In #3186 I'm changing it to this: kuma-gui/packages/kuma-gui/src/test-support/mocks/src/meshes/_/dataplanes/_/_overview.ts Lines 24 to 35 in c42fe8d
Using the inline function gives me automatic type safety both in TS at build time and JS at runtime, and honestly in this case, in avoiding the multiple if conditionals the inline-function/switch is far easier to read to my eyes at least. |
packages/kuma-gui/src/app/connections/views/ConnectionInboundSummaryXdsConfigView.vue
Outdated
Show resolved
Hide resolved
packages/kuma-gui/src/test-support/mocks/src/meshes/_/dataplanes/_/xds.ts
Show resolved
Hide resolved
packages/kuma-gui/src/test-support/mocks/src/meshes/_/dataplanes/_/xds.ts
Show resolved
Hide resolved
Yeah, I like the |
Signed-off-by: John Cowen <[email protected]>
Oh look I found a nested-ternary:
🤔 when I think about what the above file used to be like, I kinda prefer the direction it's going. I think that, the fact that we have them already, and the type/js benefits I wouldn't be super keen on adding that rule, plus the more i think about it its very similar to saying "don't use multiple conditionals inside an if statement" (i.e. If you feel super strong about it happy to reconsider, but at the moment it doesn't feel like a super important error causing problem that we might want to add a lint rule for. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👍
I think ternaries are getting unreadable a lot quicker when nesting than a complex boolean expression. But yeah, at some point it probably makes sense to outsource and group them into variables. |
Signed-off-by: John Cowen <[email protected]>
Signed-off-by: John Cowen <[email protected]>
One last thing I wanted to do here thats vaguely related to above convo, I added I'll leave this hanging for a little while today, but if I hear no more I'll go ahead and merge seeing as I already have approval on everything else. But lmk if there's anything else |
Adds XDS configuration drawers to inbounds and outbounds so show only the listeners/clusters relevant to that inbound/outbound.
Closes #3182
Closes #3181
You can run this against a local cluster by setting a cookie like the following:
note: I removed an annoying ESLint rule here https://eslint.org/docs/latest/rules/multiline-ternary#when-not-to-use-it . We don't have any conventions in regards to ternaries, do whatever works for you. Generally you've decided to use a ternary because the format you've personally chosen reads nicer - furthermore its pointless having a eslint rule to force wrapping of something that is designed for single lines. Not only that but the eslint rule we had makes these super hard to read.
Note: This will not pass lint tests and is purposefully an early WIP PRed for preview site purposes.Notes taken during work:
Adding some pseudo code to help explain the filtering/selecting we are doing:
Inbounds
I use
'127.0.0.1:0000'
below in place of the actualdataplane.networking.address
dynamic_listeners[].name === '127.0.0.1:0000'
{dynamic_active_clusters, static_clusters}.cluster.load_assignment.endpoints[].lb_endpoints[].endpoint.address.socket_address.{address:port_value} === '127.0.0.1:0000'
(I'm not totally sure we should be using this one)Note for an inbound we do not know the type of the service (i.e. is it a
_msvc_
a_mzsvc_
etc) so we can't filter by cluster name.Improvements: we should look for
inbound:ignore.ip.address:0000
use prefix/suffix because we need to be careful with ipv6.dynamic_listeners[].name === 'inbound:ignore.ip.address:0000'
dynamic_active_clusters[].cluster.name === 'ignore.host:0000'
Outbounds
I use
outbound
below in place of the actual Envoy stats name (e.g.default_demo-app_kuma-demo_default_msvc_5000
)dynamic_active_clusters[].cluster.name === <outbound>
dynamic_endpoint_configs[].endpoint_config.cluster_name === <outbound>
Note we don't have any information about a specific outbound apart from the clusterName/envoy stats prefix. We can take information from the dataplane associated with the outbound, but not the outbound itself.
Improvements:
dynamic_listeners[].name === 'outbound:<outbound>'
to be future proof with xds configs, outbound listeners should use the clustername instead of an IP/port combo kuma#12093.If we need to add more instance of filtering/selecting it would be helpful to express what needs to be done using the above examples