Skip to content

feat(translator): implement timeout in ClientTrafficPolicy#2667

Merged
arkodg merged 10 commits intoenvoyproxy:mainfrom
yaelSchechter:timeouts
Feb 22, 2024
Merged

feat(translator): implement timeout in ClientTrafficPolicy#2667
arkodg merged 10 commits intoenvoyproxy:mainfrom
yaelSchechter:timeouts

Conversation

@yaelSchechter
Copy link
Copy Markdown
Contributor

What type of PR is this?
Implement Timeout in ClientTrafficPolicy

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #2598

Signed-off-by: Yael Shechter <yael.shechter@sap.com>
@yaelSchechter yaelSchechter requested a review from a team as a code owner February 21, 2024 13:27
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 21, 2024

Codecov Report

Attention: 33 lines in your changes are missing coverage. Please review.

Comparison is base (4c79ef9) 63.38% compared to head (d1cd4bf) 63.41%.

Files Patch % Lines
internal/ir/zz_generated.deepcopy.go 0.00% 32 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2667      +/-   ##
==========================================
+ Coverage   63.38%   63.41%   +0.02%     
==========================================
  Files         119      119              
  Lines       19098    19156      +58     
==========================================
+ Hits        12106    12147      +41     
- Misses       6193     6212      +19     
+ Partials      799      797       -2     

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

@yaelSchechter yaelSchechter marked this pull request as draft February 21, 2024 13:36
return err
}

if httpIR.Timeout == nil {
Copy link
Copy Markdown
Contributor

@liorokman liorokman Feb 21, 2024

Choose a reason for hiding this comment

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

Small nit, but maybe this is slightly more readable as a switch statement:

    switch {
        case httpIR.Timeout == nil:
                      httpIR.Timeout = &ir.ClientTimeout{}
                      fallthrough
         case httpIR.Timeout.HTTP == nil:
                      httpIR.Timeout.HTTP = &ir.HTTPClientTimeout{}                      
    }

    httpIR.Timeout.HTTP.RequestReceivedTimeout = &metav1.Duration{
                                 Duration: d,
    }

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.

Thanks, Lior
I think that this suggestion offers a cleaner structure, but is it a convention for implementing switch cases? I'm not sure that all readers are familiar with the fallthrough keyword.

Copy link
Copy Markdown
Contributor

@liorokman liorokman Feb 21, 2024

Choose a reason for hiding this comment

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

The fallthrough keyword is part of the language - readers should be familiar with the language.

But this can also be written without it:

    switch {
        case httpIR.Timeout == nil:
                      httpIR.Timeout = &ir.ClientTimeout{
                              HTTP: &ir.HTTPClientTimeout{},
                      }
         case httpIR.Timeout.HTTP == nil:
                      httpIR.Timeout.HTTP = &ir.HTTPClientTimeout{}
    }

    httpIR.Timeout.HTTP.RequestReceivedTimeout = &metav1.Duration{
                                 Duration: d,
    }

Copy link
Copy Markdown
Contributor

@liorokman liorokman left a comment

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: Yael Shechter <yael.shechter@sap.com>
Signed-off-by: Yael Shechter <yael.shechter@sap.com>
Signed-off-by: Yael Shechter <yael.shechter@sap.com>
Signed-off-by: Yael Shechter <yael.shechter@sap.com>
Signed-off-by: Yael Shechter <yael.shechter@sap.com>
Signed-off-by: Yael Shechter <yael.shechter@sap.com>
@yaelSchechter yaelSchechter marked this pull request as ready for review February 22, 2024 15:32
@zirain
Copy link
Copy Markdown
Member

zirain commented Feb 22, 2024

/retest

Copy link
Copy Markdown
Member

@zirain zirain left a comment

Choose a reason for hiding this comment

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

LGTM, looking for doc and e2e with following PRs.

@arkodg arkodg merged commit c30d037 into envoyproxy:main Feb 22, 2024
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.

Add timeouts support to clientTrafficPolicy

4 participants