Skip to content
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

timeout: take the minimum expiration time of pathSegments #1439

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

glazychev-art
Copy link
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

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
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
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
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
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
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
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
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

@@ -97,3 +92,34 @@ func (s *timeoutServer) Close(ctx context.Context, conn *networkservice.Connecti
}
return &empty.Empty{}, err
}

func after(ctx context.Context, conn *networkservice.Connection) time.Duration {
Copy link
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 {

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