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

Question on Refresh behavior #1185

Closed
sol-0 opened this issue Dec 1, 2021 · 5 comments
Closed

Question on Refresh behavior #1185

sol-0 opened this issue Dec 1, 2021 · 5 comments
Assignees
Labels
question Further information is requested

Comments

@sol-0
Copy link
Contributor

sol-0 commented Dec 1, 2021

Question

Hi @edwarnicke ,

I was checking how refresh mechanism works in NSM during issue #839 investigation, and I think refresh might be broken in the case when different mesh elements (nsmgr, forwarders, etc.) have different token expiry.

I checked your changes in this PR and saw that, e.g. in NSMgr server refresh was removed, so after that I also checked your discussion with Vladimir and found your response:
"...We could do as you suggested and compute that in refresh. I'm tempted though to do it in updatetoken by clamping down expiretime to the smallest in the path on the return direction of the path." - could you please share whether anything was done here? As I couldn't find a place in the code where this case is handled.

Also, if you don't mind, could you please describe how refresh mechanism is working currently?

@sol-0 sol-0 changed the title Refresh Behavior Question on Refresh behavior Dec 1, 2021
@denis-tingaikin
Copy link
Member

/сс @edwarnicke

@denis-tingaikin denis-tingaikin added the question Further information is requested label Dec 1, 2021
@edwarnicke
Copy link
Member

@sol-0 Delighted to talk you through it :)

Let's start with the Client Chain. It includes a opts.refreshClient in the chain. By default, that opts.refreshClient is refresh.NewClient.

However, if the user passes client.WithoutRefresh() then opts.refreshClient is set to null.NewClient which is a noop.

This brings us around to the first central feature of refresh: It should only be performed by non-passthrough clients.
If a client is part of a passthrough chain element (like NSMgr, or a Forwarder, or cmd-nse-firewall-vpp it should be using the client.WithoutRefresh() option to not do refresh. Refresh is driven from the start of the chain, not the middle.

The refresh chain element on Request computes the time after which it should send a refresh request which is roughly 1/3 the time remaining till expiration plus a little bit of noise.

The refresh chain element creates a cancelCtx cancels any old cancelCtx from previous request and stores the new cancelCtx.

From there a go routine is spawned to send the refresh at the computed time and, if it does not succeed, keep trying to send it.

Note: if cancelCtx has been canceled (either by Close or a new Request) the go routine exits.

The comment you so astutely noted is that we should probably clamp down the expireTime to the earliest time in the chain.
IMHO the best way to do that is to have updatetoken compare its expireTime to the expireTime of the next PathSegment after it in the Path, and pick the earliest.

@denis-tingaikin
Copy link
Member

denis-tingaikin commented Dec 1, 2021

The comment you so astutely noted is that we should probably clamp down the expireTime to the earliest time in the chain.
IMHO the best way to do that is to have updatetoken compare its expireTime to the expireTime of the next PathSegment after it in the Path, and pick the earliest.

I think we need to implement this. I see that it can be super useful for interdomain scenarios where two or more clusters can have a totally different spire setup.

@edwarnicke Do you mind if we'll create an issue and describe a potential technical solution for this?

@edwarnicke
Copy link
Member

@denis-tingaikin Please do

@sol-0
Copy link
Contributor Author

sol-0 commented Dec 2, 2021

@edwarnicke ,
thanks a lot for really helpful and in-depth explanation!

@denis-tingaikin ,
I've added a new issue #1189 based on this discussion.

@sol-0 sol-0 closed this as completed Dec 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants