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

How does config rotation work? #31

Open
ehaydenr opened this issue Jan 8, 2024 · 3 comments
Open

How does config rotation work? #31

ehaydenr opened this issue Jan 8, 2024 · 3 comments
Labels

Comments

@ehaydenr
Copy link

ehaydenr commented Jan 8, 2024

I'm thinking of the following scenario:

  • t=0 OHTTP Gateway gives config A to mirror with validity of 10 mins
  • t=5min OHTTP Gateway wants to rotate config to config B
  • t=6min client fetches config from OHTTP gateway, gets config B
  • t=6min client goes to mirror and is provided config A because it's still valid in cache. Inconsistency

If the client is checking multiple mirrors, a similar inconsistency could happen since mirrors will be refreshing their cache at different times.

@chris-wood
Copy link
Collaborator

This seems like a misconfiguration for the gateway since they specified a validity window that was longer than that which was actually used in practice. I think the expectation is that the cache validity must always be less than the lifetime of the resource.

@ehaydenr
Copy link
Author

ehaydenr commented Jan 8, 2024

What would a valid rotation timeline look like?

If I'm an OHTTP gateway that normally advertises a 10 minute validity window, do I have to disable caching of my configuration altogether for at least 10 minutes so no mirrors cache while I rotate?

Even if I did that, I think there's still this race condition:

  • right before gateway config rotation, client fetches from gateway (tiny/no validity window)
  • gateway rotates
  • client goes to mirror, gets the new config.. inconsistency

@chris-wood
Copy link
Collaborator

@ehaydenr by gateway are you referring to an OHTTP gateway, or the origin which provides the source of truth for a resource?

In any case, I think you're right that this race condition will exist even if there were no cache controls on the resource. Probably the simplest way to deal with this is for clients to retry their request to the gateway after the mirror to see if the resource has changed. Since the error path here depends on client policy, i.e., does it treat mismatches as failures and abort, does it retry the whole flow, etc, I think it's reasonable to treat this as an edge case that implementations work around.

@tfpauly, thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants