-
Notifications
You must be signed in to change notification settings - Fork 36
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
Modified refresh client to calculate the shortest token expiry #1190
Conversation
a8be34c
to
40a5de6
Compare
Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com>
if err != nil { | ||
return 0, errors.WithStack(err) | ||
} | ||
var minTimeout = time.Duration(math.MaxInt64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var minTimeout = time.Duration(math.MaxInt64) | |
var minTimeout time.Duration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't initialize minTimeout
, it will always be 0
. It's initialized with max possible duration so that it's always greater than any value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the case when there no segments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
timeout := clockTime.Until(expireTime) | ||
log.FromContext(ctx).Infof("expiration after %s at %s", timeout.String(), expireTime.UTC()) | ||
timeout := clockTime.Until(expireTime) | ||
log.FromContext(ctx).Infof("expiration after %s at %s", timeout.String(), expireTime.UTC()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.FromContext(ctx).Infof("expiration after %s at %s", timeout.String(), expireTime.UTC()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
if timeout < minTimeout { | ||
minTimeout = timeout | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
} | |
log.FromContext(ctx).Infof("expiration after %s at %s", timeout.String(), expireTime.UTC()) | |
if timeout <= 0 { | |
return 1, nil | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
if timeout <= 0 { | ||
return 1, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if timeout <= 0 { | |
return 1, nil | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
return 0, errors.WithStack(err) | ||
} | ||
var minTimeout = time.Duration(math.MaxInt64) | ||
for _, seg := range conn.GetPath().GetPathSegments() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for _, seg := range conn.GetPath().GetPathSegments() { | |
for _, segment := range conn.GetPath().GetPathSegments() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
ExpectedRefreshTimeoutMax: 20*time.Minute + time.Second, | ||
ExpectedRefreshTimeoutMin: 20*time.Minute - time.Second, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use const time range.
ExpectedRefreshTimeoutMax: 20*time.Minute + time.Second, | |
ExpectedRefreshTimeoutMin: 20*time.Minute - time.Second, | |
ExpectedRefreshTimeout: 20*time.Minute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apply this to other places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
timeNow, err := time.Parse("2006-01-02 15:04:05", "2009-11-10 23:00:00") | ||
require.NoError(t, err) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
time.Date()
is not returning error.
timeNow, err := time.Parse("2006-01-02 15:04:05", "2009-11-10 23:00:00") | |
require.NoError(t, err) | |
timeNow := time.Date(/*todo*/) | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@edwarnicke We are thinking to solve #1189 with this PR. |
Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com>
Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@edwarnicke Could you have a look?
…k@main PR link: networkservicemesh/sdk#1190 Commit: 8e96470 Author: Sol-0 Date: 2021-12-10 00:07:40 +0700 Message: - Modified refresh client to calculate the shortest token expiry (#1190) * Modified refresh client to calculate the shortest token expiry Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@main PR link: networkservicemesh/sdk#1190 Commit: 8e96470 Author: Sol-0 Date: 2021-12-10 00:07:40 +0700 Message: - Modified refresh client to calculate the shortest token expiry (#1190) * Modified refresh client to calculate the shortest token expiry Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@main PR link: networkservicemesh/sdk#1190 Commit: 8e96470 Author: Sol-0 Date: 2021-12-10 00:07:40 +0700 Message: - Modified refresh client to calculate the shortest token expiry (#1190) * Modified refresh client to calculate the shortest token expiry Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@main PR link: networkservicemesh/sdk#1190 Commit: 8e96470 Author: Sol-0 Date: 2021-12-10 00:07:40 +0700 Message: - Modified refresh client to calculate the shortest token expiry (#1190) * Modified refresh client to calculate the shortest token expiry Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@main PR link: networkservicemesh/sdk#1190 Commit: 8e96470 Author: Sol-0 Date: 2021-12-10 00:07:40 +0700 Message: - Modified refresh client to calculate the shortest token expiry (#1190) * Modified refresh client to calculate the shortest token expiry Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@main PR link: networkservicemesh/sdk#1190 Commit: 8e96470 Author: Sol-0 Date: 2021-12-10 00:07:40 +0700 Message: - Modified refresh client to calculate the shortest token expiry (#1190) * Modified refresh client to calculate the shortest token expiry Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@main PR link: networkservicemesh/sdk#1190 Commit: 8e96470 Author: Sol-0 Date: 2021-12-10 00:07:40 +0700 Message: - Modified refresh client to calculate the shortest token expiry (#1190) * Modified refresh client to calculate the shortest token expiry Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@main PR link: networkservicemesh/sdk#1190 Commit: 8e96470 Author: Sol-0 Date: 2021-12-10 00:07:40 +0700 Message: - Modified refresh client to calculate the shortest token expiry (#1190) * Modified refresh client to calculate the shortest token expiry Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@main PR link: networkservicemesh/sdk#1190 Commit: 8e96470 Author: Sol-0 Date: 2021-12-10 00:07:40 +0700 Message: - Modified refresh client to calculate the shortest token expiry (#1190) * Modified refresh client to calculate the shortest token expiry Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
Signed-off-by: Oleg Solodkov oleg.solodkov@xored.com
Description
Refresh client calculates the shortest token expiry and sets refresh time according to that value
Issue link
Fixes #1189
How Has This Been Tested?
Types of changes