Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jpeach
Copy link
Contributor

@jpeach jpeach commented Oct 13, 2020

If the authorization spec on the virtual host doesn't set the response
timeout, default it from the corresponding ExtensionService.

This fixes #3025.

Signed-off-by: James Peach [email protected]

If the authorization spec on the virtual host doesn't set the response
timeout, default it from the corresponding `ExtensionService`.

This fixes projectcontour#3025.

Signed-off-by: James Peach <[email protected]>
@jpeach jpeach requested review from skriss and stevesloka October 13, 2020 16:59
@codecov
Copy link

codecov bot commented Oct 13, 2020

Codecov Report

❗ No coverage uploaded for pull request base (main@5312588). Click here to learn what that means.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3026   +/-   ##
=======================================
  Coverage        ?   74.49%           
=======================================
  Files           ?       92           
  Lines           ?     5963           
  Branches        ?        0           
=======================================
  Hits            ?     4442           
  Misses          ?     1423           
  Partials        ?       98           
Impacted Files Coverage Δ
internal/dag/httpproxy_processor.go 94.15% <100.00%> (ø)

Copy link
Member

@skriss skriss left a comment

Choose a reason for hiding this comment

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

LGTM

@jpeach jpeach merged commit 47c4eb2 into projectcontour:main Oct 13, 2020
@jpeach jpeach deleted the default-auth-response-timeout branch October 13, 2020 20:11
}
svhost.AuthorizationResponseTimeout = timeout

if timeout.UseDefault() {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe collapse this into the pattern we've used before which is UseDefaultOrValue? Wondering if that might read better. Alternatively, a good place is to set the default when the extensionservice is created and have the default be there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry I didn't see this comment when I merged :-(

Maybe something like:

func (s Setting) DurationOr(t time.Duration) time.Duration {
    if s.UseDefault() {
        return t
    }

    return s.val
}

One consideration is that the natural way to do this for a timeout.Setting is probably to specify a backup time.Duration, but here we have a backup timeout.Setting.

Maybe we could add something like:

package timeout

func FirstOf(settings ...Setting) Setting {
    for _, s := range settings {
        if !s.UseDefault() {
            return s
        }
    }

    return DefaultSetting()
}

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.

Auth: ExtensionService timeout policy doesn't do anything

3 participants