Skip to content

timeout: take the minimum expiration time of pathSegments#1439

Open
glazychev-art wants to merge 2 commits intonetworkservicemesh:mainfrom
glazychev-art:timeout
Open

timeout: take the minimum expiration time of pathSegments#1439
glazychev-art wants to merge 2 commits intonetworkservicemesh:mainfrom
glazychev-art:timeout

Conversation

@glazychev-art
Copy link
Copy Markdown
Contributor

@glazychev-art glazychev-art commented Mar 23, 2023

Description

The previous implementation took into account only the previous segment. This is mistake.
For example:
NSC (1min) ---> NSMgr (5min) ---> Fwd (5min) --->...
If NSC and NSMgr die, then the Fwd timeout will work only after 5 minutes. But authorize policies look at the whole path, so an error will occur when closing (the client token has already expired).

Issue link

networkservicemesh/deployments-k8s#8882

How Has This Been Tested?

  • Added unit testing to cover
  • Tested manually
  • Tested by integration testing
  • Have not tested

Types of changes

  • Bug fix
  • New functionality
  • Documentation
  • Refactoring
  • CI

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 23, 2023

Codecov Report

❗ No coverage uploaded for pull request base (main@2502d93). Click here to learn what that means.
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1439   +/-   ##
=======================================
  Coverage        ?   70.28%           
=======================================
  Files           ?      242           
  Lines           ?    11006           
  Branches        ?        0           
=======================================
  Hits            ?     7736           
  Misses          ?     2770           
  Partials        ?      500           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Copy Markdown
Member

@denis-tingaikin denis-tingaikin left a comment

Choose a reason for hiding this comment

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

I think these changes make sense, but it is not required. It's about optimization.

@edwarnicke What do you think?

func after(ctx context.Context, conn *networkservice.Connection) time.Duration {
clockTime := clock.FromContext(ctx)

var minTimeout *time.Duration
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
var minTimeout *time.Duration
var minTimeout time.Duration = 1

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.

we can't set 1 here because we won't find a value less than that in Path segments

Comment on lines +110 to +112
if minTimeout == nil {
minTimeout = new(time.Duration)
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if minTimeout == nil {
minTimeout = new(time.Duration)
}

minTimeout = new(time.Duration)
}

*minTimeout = timeout
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
*minTimeout = timeout
minTimeout = timeout

Comment on lines +119 to +121
if minTimeout == nil || *minTimeout <= 0 {
return 1
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if minTimeout == nil || *minTimeout <= 0 {
return 1
}

}
log.FromContext(ctx).Infof("expiration after %s at %s", minTimeout.String(), expireTime.UTC())

return *minTimeout
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
return *minTimeout
return minTimeout

return &empty.Empty{}, err
}

func after(ctx context.Context, conn *networkservice.Connection) time.Duration {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we need to rename it.

For example,

Suggested change
func after(ctx context.Context, conn *networkservice.Connection) time.Duration {
func minTokenTimeout(ctx context.Context, conn *networkservice.Connection) time.Duration {

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
Signed-off-by: Artem Glazychev <artem.glazychev@xored.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.

4 participants