-
Notifications
You must be signed in to change notification settings - Fork 18
Fix :Envoy Go control plane adaptation issues #86
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
Fix :Envoy Go control plane adaptation issues #86
Conversation
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.
Summary of Changes
Hello @Eeshu-Yadav, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request aims to resolve several adaptation issues within the Envoy Go control plane integration. The changes enhance the system's ability to correctly handle host rewriting specifications in routing actions and improve the robustness of filter chain configurations by providing default values where names are absent. This leads to better compatibility and stability of the control plane.
Highlights
- Envoy RouteAction: Implemented support for host_rewrite_specifier within RouteAction conversions, allowing for more flexible host rewriting configurations.
- FilterChain Naming: Ensured robustness by providing a default name for FilterChain instances when the name field is missing or empty.
- Code Stability: Addressed compilation errors and updated existing tests to reflect the new changes and ensure continued correctness.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This pull request addresses adaptation issues with the Envoy Go control plane by adding support for host_rewrite_specifier and handling missing name fields in FilterChain. The fix for the missing filter chain name is correct. However, I found a logic error in the implementation of auto_host_rewrite which could lead to incorrect behavior. My review includes a comment with a suggested fix for this issue.
| let authority_rewrite = host_rewrite_specifier | ||
| .map(|spec| match spec { | ||
| EnvoyHostRewriteSpecifier::HostRewriteLiteral(literal) => { | ||
| Authority::from_str(&literal) | ||
| .map(AuthorityRewriteSpecifier::Authority) | ||
| .map_err(|e| GenericError::from_msg_with_cause( | ||
| format!("failed to parse host rewrite literal '{literal}' as authority"), e)) | ||
| }, | ||
| EnvoyHostRewriteSpecifier::AutoHostRewrite(_) => Ok(AuthorityRewriteSpecifier::AutoHostRewrite), | ||
| EnvoyHostRewriteSpecifier::HostRewriteHeader(header) => { | ||
| match HeaderName::from_str(&header) { | ||
| Ok(_) => Ok(AuthorityRewriteSpecifier::Header(header.into())), | ||
| Err(e) => Err(GenericError::from_msg_with_cause( | ||
| format!("failed to parse host rewrite header '{header}' as header name"), e)), | ||
| } | ||
| }, | ||
| EnvoyHostRewriteSpecifier::HostRewritePathRegex(regex) => { | ||
| regex.try_into().map(AuthorityRewriteSpecifier::Regex) | ||
| }, | ||
| }) | ||
| .transpose() | ||
| .with_node("host_rewrite_specifier")?; |
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.
The current implementation of AutoHostRewrite does not correctly handle the boolean value associated with it. According to Envoy's documentation, if auto_host_rewrite is set to false, no rewrite should occur. The current code treats any presence of auto_host_rewrite as a trigger for rewriting, which is incorrect.
I suggest filtering out the auto_host_rewrite: false case before mapping the host_rewrite_specifier to ensure the correct behavior.
let authority_rewrite = host_rewrite_specifier
.filter(|spec| {
if let EnvoyHostRewriteSpecifier::AutoHostRewrite(bv) = spec {
bv.value
} else {
true
}
})
.map(|spec| match spec {
EnvoyHostRewriteSpecifier::HostRewriteLiteral(literal) => {
Authority::from_str(&literal)
.map(AuthorityRewriteSpecifier::Authority)
.map_err(|e| GenericError::from_msg_with_cause(
format!("failed to parse host rewrite literal '{literal}' as authority"), e))
},
EnvoyHostRewriteSpecifier::AutoHostRewrite(_) => Ok(AuthorityRewriteSpecifier::AutoHostRewrite),
EnvoyHostRewriteSpecifier::HostRewriteHeader(header) => {
match HeaderName::from_str(&header) {
Ok(_) => Ok(AuthorityRewriteSpecifier::Header(header.into())),
Err(e) => Err(GenericError::from_msg_with_cause(
format!("failed to parse host rewrite header '{header}' as header name"), e)),
}
},
EnvoyHostRewriteSpecifier::HostRewritePathRegex(regex) => {
regex.try_into().map(AuthorityRewriteSpecifier::Regex)
},
})
.transpose()
.with_node("host_rewrite_specifier")?;7edb1dd to
319e34e
Compare
|
@YaoZengzeng kindly review |
319e34e to
35dbe51
Compare
- Add support for host_rewrite_specifier in RouteAction conversion - Handle missing name field in FilterChain by providing default name - Fix compilation errors and update tests Signed-off-by: Eeshu-Yadav <eeshuyadav123@gmail.com>
35dbe51 to
9564ecf
Compare
| transport_socket_connect_timeout // name, | ||
| )?; | ||
| let name: CompactString = required!(name)?.into(); | ||
| let name: CompactString = if name.is_empty() { "default_filter_chain".into() } else { name.into() }; |
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.
if empty can we use ""
| let retry_policy = retry_policy.map(RetryPolicy::try_from).transpose().with_node("retry_policy")?; | ||
| let upgrade_config = upgrade_configs.try_into().with_node("upgrade_configs").ok(); | ||
| let hash_policy = convert_vec!(hash_policy)?; | ||
| let authority_rewrite = host_rewrite_specifier |
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.
can you use match
|
@hzxuzhonghu is it fine ? |
…me and refactor authority_rewrite to use match Signed-off-by: Eeshu-Yadav <eeshuyadav123@gmail.com>
463c39e to
bd20ca1
Compare
| let upgrade_config = upgrade_configs.try_into().with_node("upgrade_configs").ok(); | ||
| let hash_policy = convert_vec!(hash_policy)?; | ||
| let authority_rewrite = match host_rewrite_specifier { | ||
| Some(EnvoyHostRewriteSpecifier::AutoHostRewrite(bv)) if !bv.value => Ok(None), |
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 have never seem Ok(None), the semantic should be when bv.value = true, we need to autorewrite, and vice verse, Then how can this express branch true?
| }, | ||
| } | ||
| .map(Some), | ||
| None => Ok(None), |
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.
None instead of Ok(None)
Signed-off-by: Eeshu-Yadav <eeshuyadav123@gmail.com>
|
@hzxuzhonghu Thanks for the review! Fixed both issues:
|
|
/lgtm i guess the autorewrite does not really work during request handling, So can you file a issue to track |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hzxuzhonghu The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This commit implements the missing AutoHostRewrite functionality that was configured but not actually used during request processing. The implementation adds support for all AuthorityRewriteSpecifier variants: - AutoHostRewrite: Uses upstream cluster's authority - Authority: Uses a specific authority - Header: Uses value from a request header - Regex: Applies regex transformation to current authority Both the request URI authority and Host header are updated when authority rewriting is applied, ensuring consistent behavior across the request. Fixes the issue mentioned in PR kmesh-net#86 review where autorewrite configuration was parsed but not executed during request handling. Signed-off-by: Eeshu-Yadav <eeshuyadav123@gmail.com>
This commit implements the missing AutoHostRewrite functionality that was configured but not actually used during request processing. The implementation adds support for all AuthorityRewriteSpecifier variants: - AutoHostRewrite: Uses upstream cluster's authority - Authority: Uses a specific authority - Header: Uses value from a request header - Regex: Applies regex transformation to current authority Both the request URI authority and Host header are updated when authority rewriting is applied, ensuring consistent behavior across the request. Fixes the issue mentioned in PR kmesh-net#86 review where autorewrite configuration was parsed but not executed during request handling. Signed-off-by: Eeshu-Yadav <eeshuyadav123@gmail.com>
This commit implements the missing AutoHostRewrite functionality that was configured but not actually used during request processing. The implementation adds support for all AuthorityRewriteSpecifier variants: - AutoHostRewrite: Uses upstream cluster's authority - Authority: Uses a specific authority - Header: Uses value from a request header - Regex: Applies regex transformation to current authority Both the request URI authority and Host header are updated when authority rewriting is applied, ensuring consistent behavior across the request. Fixes the issue mentioned in PR kmesh-net#86 review where autorewrite configuration was parsed but not executed during request handling. Signed-off-by: Eeshu-Yadav <eeshuyadav123@gmail.com>
fix #38