Skip to content
This repository has been archived by the owner on May 27, 2021. It is now read-only.

If Normandy admin is not available, read from the public Normandy API #298

Open
mythmon opened this issue Jul 10, 2018 · 5 comments
Open

Comments

@mythmon
Copy link
Contributor

mythmon commented Jul 10, 2018

In #297, we're adding the availability of the Normandy Admin to the state. Based on that information, we should fetch data from the read-only server when appropriate. This covers reading the value from state and acting accordingly, and also reacting accordingly to the value changing.

@emceeaich
Copy link

This would be useful.

@peterbe
Copy link
Contributor

peterbe commented Feb 22, 2019

We chatted about this and made a tentative plan.

In #682 we sprinkled in a bunch of code near actions that are about writing. E.g. creating a recipe, or approval an approval request. Basically, the presence of a button depends on your logged-in state. Also, for pages that you shouldn't be able to reach (like the Add Recipe page) instead of hiding any buttons we show an error. E.g. https://github.com/mozilla/delivery-console/pull/682/files#diff-abfcdeea0dfbf8ee4054cc011c3ca76dR57

In all places where we do that, we should also check that your VPN connection is valid/working. So it'll be something like this:

// Component <AddRecipe/>

render() {
  if (!userProfile) {
    return <AuthenticationAlert description="You must be logged in to create an extension." />
  } else if (!vpnActive) {
    return <AuthenticationAlert description="You must be on the VPN to make any changes" />
  }
  ... // as before
}

peterbe added a commit to peterbe/delivery-console that referenced this issue Feb 22, 2019
peterbe added a commit to peterbe/delivery-console that referenced this issue Feb 22, 2019
@peterbe
Copy link
Contributor

peterbe commented Feb 26, 2019

One concern I have is that if you're not on the VPN you might be losing out because what you see is out of date.

According to the docs...

"The public server is served through a CDN with a cache time of a few minutes."

So, if you're not on the VPN, DC will use the "Public Read-only API server" which might always be a bit old.

We could try to use text to explain this to the users. But users don't read. They might; if it's a loud "flash message" near the top of the page.
Our saving grace is that if the VPN isn't working, the little VPN button near the top is going to be red which will raise some thoughts.

@mythmon
Copy link
Contributor Author

mythmon commented Feb 26, 2019

I don't think the CDN delay is a big deal. The cache headers on https://normandy.cdn.mozilla.net/api/v3/recipe/ say it will only be cached for 30 seconds, which doesn't seem like a large burden. (I realize this is contrary to what I wrote in the docs, I was intentionally being vague there).

If this is a problem, I think we could include a small badge that says the data is up-to-date as of the value of the Date header of the request. That might actually be worth doing anyways, because it can help with stale pages that have been open a while.

@peterbe
Copy link
Contributor

peterbe commented Mar 11, 2019

It only just now occurred to me the brilliance of the issue title here. The read-only URL would only be used if the read-write URL (aka. through VPN) is NOT available.

That means that we won't have the potential caching problem @mythmon mentioned here. I.e. if you've managed to make a XHR POST over the VPN, then continue to do all reads from the VPN URL henceforth.

peterbe added a commit to peterbe/delivery-console that referenced this issue Mar 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants