-
Notifications
You must be signed in to change notification settings - Fork 111
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
proposal: extensions #353
proposal: extensions #353
Conversation
Hi @yuval-k. Thanks for your PR. I'm waiting for a istio member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
Allow extending the behavior of ztunnel by invoking it as a library with extensions.
bef31cd
to
75f9a2e
Compare
/retest |
/retest |
/retest |
/retest |
examples/extension.rs
Outdated
|
||
impl Extension for ExampleExtension { | ||
fn on_listen(&self, l: &tokio::net::TcpListener, _: ListenerType) { | ||
print!("ExampleExtension: Listening on {}", l.local_addr().unwrap()); |
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.
You might want to use the logging macros instead
|
||
pub fn entry(extension: Option<Box<dyn Extension + Sync + Send>>) -> anyhow::Result<()> { | ||
telemetry::setup_logging(); | ||
let config: config::Config = config::parse_config(extension)?; |
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.
I think it should be placed after the match below
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.
this part of was moved as is from main.rs
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.
I think with any extensibility mechanism, we need:
- Very very clear and explicit bounds, to avoid this creeping from 4 callbacks to 400
- Multiple usages by different vendors/users that validate the abstraction picked is correct
So far I have chatted with 3 folks about this (including you and myself), and 2/3 of them would not be supported by this model. Its perfectly fine to have folks need customization beyond what extensibility we provide out of the box - there will always be folks with super bespoke use cases that we can't and should not bend over backwards to meet.
However, I would like to at least see some other user that could implement there desired extensions via this mechanism. If not, it may make sense to wait until we have reached that point before prematurely merging anything.
I do think in general this seems like a plausible extension mechanism, though
@howardjohn can you explain the scenarios of extensions from 2/3 you mentioned that would not fit? |
More invasive changes like different transport protocols, custom tweaks to how we do HBONE, different copying mechanisms, etc. Its a bit vague, though, for all involved I think - which is another reason not to rush things |
Is the extended featureset so broad that the waypoints cannot capture all datapaths? Normally, network functions could be chained, which is essentially what waypoints do to enhance L7 processing. Why not adopt the similar model for ztunnels and run traffic through a chain of coprocessors? The protocol is sufficient to express it, and the running out of process has many flexibility benefits. |
I think that some extensions (like tweaks to HBONE) will require ztunnel extensions vs out of process ones. As far as the API itself, these extensions are not an istio user-facing api, but rather an istio vendor-facing api (similar to envoy filters in that regard). As such, I think it's ok to treat extensions as an internal API, and allow it to be re-factored/broken without notice (as long as the same use-cases are still enabled, i.e. downstream code will still work after it adapts to the new API). This is similar to envoy's extension development model (i.e. the stable config is the |
HBONE is the only stable specification we have here, so I'm hoping we don't make vendor-specific customizations to it. |
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
(xposting some comments from #251)
|
Signed-off-by: Benjamin Leggett <[email protected]>
A different perspective: I think we have close to consensus that we should keep ztunnel minimal in the Istio distribution and have a stable common protocol. This will allow integrations and interop - including other implementations of the protocol, for example in proxyless or native implementations in different languages or non-istio implementations ( and outside of K8S ). While I don't think a hook would help - having a relatively stable API in ztunnel that allows different parts to be reused is not bad. For example a rust application outside of k8s ( or on a k8s cluster where user doesn't have permissions to set ztunnel/cni) should be able to reuse the ztunnel code for connecting to XDS and getting PTR-DS, as well as the code to It is not clear if such code should be ztunnel or another crate that is focused on providing a library-like API and used With a stable API - it should be possible to customize and hook with far more flexibility and still use common code |
One thing I would note is that we are already pretty near to hitting the There are other ways to fix that specific issue of course, but ultimately I think a hook API there makes a lot more sense than piling more and more stuff into those same handlers for whatever the next Arguably L4 metrics could have been implemented with some variant of the extension API proposed here. If more things like the L4 metrics implementation come along, I think we might need to revisit the "extension hooks don't simplify core handlers" argument before we proceed to jam more things into the core TCP connection handlers every time we want to add a feature that needs to hook into the TCP connection primitives.
Not against that - my personal stance on librarifying existing apps is "don't maintain separate libraries unless and until you have real consumers of those separate libraries" - if we have a ztunnel-external dep (or someone can make a compelling argument for why we need to split out an external lib to support one) - then let's do it. |
Allow extending the behaviour of ztunnel by invoking it as a library with extensions.