Skip to content

fix: don't lose timeout settings that originate from the route when translating the backend traffic policy#4095

Merged
guydc merged 3 commits intoenvoyproxy:mainfrom
liorokman:request-timeout-ignored
Aug 29, 2024
Merged

fix: don't lose timeout settings that originate from the route when translating the backend traffic policy#4095
guydc merged 3 commits intoenvoyproxy:mainfrom
liorokman:request-timeout-ignored

Conversation

@liorokman
Copy link
Copy Markdown
Contributor

Which issue(s) this PR fixes:
Fixes #4091

@liorokman liorokman requested a review from a team as a code owner August 22, 2024 07:27
@codecov
Copy link
Copy Markdown

codecov bot commented Aug 22, 2024

Codecov Report

Attention: Patch coverage is 89.74359% with 4 lines in your changes missing coverage. Please review.

Project coverage is 67.94%. Comparing base (fe07093) to head (8cbe3e8).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
internal/gatewayapi/clustersettings.go 86.20% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4095      +/-   ##
==========================================
+ Coverage   67.86%   67.94%   +0.08%     
==========================================
  Files         187      187              
  Lines       23023    23018       -5     
==========================================
+ Hits        15624    15640      +16     
+ Misses       6277     6264      -13     
+ Partials     1122     1114       -8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@liorokman
Copy link
Copy Markdown
Contributor Author

/retest

1 similar comment
@liorokman
Copy link
Copy Markdown
Contributor Author

/retest

guydc
guydc previously approved these changes Aug 22, 2024
Copy link
Copy Markdown
Contributor

@guydc guydc left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

shouldnt this have worked as well ?

Copy link
Copy Markdown
Contributor Author

@liorokman liorokman Aug 22, 2024

Choose a reason for hiding this comment

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

The problem was an ordering problem. The timeout value was lost in the original ordering because r.Traffic (which contained the value collected from the HTTPRoute was overridden in line 392 (386 in the original file).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why are we returning early here, if a route is non empty shouldnt we also compute route timeout set then and then return ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Returning early here because the policy doesn't contain any new timeout information. There's nothing to compute. The only thing that should happen is to not ignore whatever values are already in ir.Timeout due to how it was configured from the HTTPRoute resource.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think I understand the code flow now, we have two methods

  1. processTimeout - which builds out the timeout struct by processing the HTTPRoute timeout section
  2. buildTimeout - which builds out the timeout struct by processing BTP

to improve readability, my suggestion would be to rename the functions to buildRouteTimeout and buildBTPTimeout and add a 3rd func called mergeTimeouts which copies over the route timeout fields if set, and gets called in the route section

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

buildBTPTimeout is a little misleading. That function is used wherever there are ClusterSettings involved - also for things like ext-proc, ext-auth, tracing, and logging cluster definitions.

I'll make a few changes to improve readability though.

@liorokman
Copy link
Copy Markdown
Contributor Author

/retest

@liorokman
Copy link
Copy Markdown
Contributor Author

/retest

2 similar comments
@liorokman
Copy link
Copy Markdown
Contributor Author

/retest

@liorokman
Copy link
Copy Markdown
Contributor Author

/retest

arkodg
arkodg previously approved these changes Aug 28, 2024
Copy link
Copy Markdown
Contributor

@arkodg arkodg left a comment

Choose a reason for hiding this comment

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

LGTM thanks for the refactor
going forward, we are probably going to hit such situations very often where a feature will exist in the extension as well as in the core gateway api API, so we should consider following this design pattern there as well to merge the values

@arkodg arkodg requested review from a team and guydc August 28, 2024 20:16
translating the backend traffic policy

Signed-off-by: Lior Okman <lior.okman@sap.com>
Signed-off-by: Lior Okman <lior.okman@sap.com>
Signed-off-by: Lior Okman <lior.okman@sap.com>
@liorokman
Copy link
Copy Markdown
Contributor Author

/retest

Copy link
Copy Markdown
Contributor

@guydc guydc left a comment

Choose a reason for hiding this comment

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

LGTM!

@guydc guydc merged commit 262e046 into envoyproxy:main Aug 29, 2024
@liorokman liorokman deleted the request-timeout-ignored branch August 29, 2024 12:49
@arkodg
Copy link
Copy Markdown
Contributor

arkodg commented Sep 7, 2024

cherry-picking this one back is non trivial due to the refactoring, so removing the cherry-pick label for this

zhaohuabing added a commit to zhaohuabing/gateway that referenced this pull request Oct 16, 2024
…ranslating the backend traffic policy (envoyproxy#4095) (#85)

* Don't lose timeout settings that originate from the route when
translating the backend traffic policy



* Improve the readability of the timeout processing code.



* Removed some logically unreachable code.



---------


(cherry picked from commit 262e046)

Signed-off-by: Lior Okman <lior.okman@sap.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Co-authored-by: Lior Okman <lior.okman@sap.com>
zirain pushed a commit that referenced this pull request Oct 16, 2024
…he route when t… (#4450)

fix: don't lose timeout settings that originate from the route when translating the backend traffic policy (#4095) (#85)

* Don't lose timeout settings that originate from the route when
translating the backend traffic policy



* Improve the readability of the timeout processing code.



* Removed some logically unreachable code.



---------


(cherry picked from commit 262e046)

Signed-off-by: Lior Okman <lior.okman@sap.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Co-authored-by: Lior Okman <lior.okman@sap.com>
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.

Applied BackendTrafficPolicy breaks HTTPRoute request timeout

4 participants