Can’t enable ‘discovery’ after switching site domain then switching back - JWT mismatched user issue

I just want to post an update on the topic that was previously opened on the old Tutor discussion forums because I ran into the same issue yesterday.

There was this server I once used as a test server with the domain name I upgraded it from Koa to Lilac to Maple and then to Nutmeg.

At one point, I decided to rename the server and run tutor local quickstart with a different domain name.

I ran into the exact same problems as @edunomic because it kept complaining about the prior domain during the initialization of discovery.

Like @edunomic and @regis I couldn’t figure out what was happening…

I ran tutor local stop, closed the server and slept on it.

Today, I ran tutor local quickstart again and it worked…

Could there be a cache issue somewhere during the installation process?

I decided to try my luck again as I did have an EC2 image of the server before I tried to change its domaine name.

Here is what I did after recreating my EC2 instance.

  • docker system prune
  • tutor local stop
  • I waited 10 minutes. I suspected a cache problem.
  • I ran docker image rm for the elasticsearch images for 1.5.2 and 7.8.1 that still existed on my system (I kept the one for 7.10.1)
  • tutor local quickstart with the new domain name.

And it worked without a glitch.

I will have to try it again 2 or 3 times to convince myself, but it looks like a cache issue at some point when running quickstart with a new domain name.

I ran into this issue sometime ago. I remember I fixed by deleting and launch tutor again.

Honestly I’m in the dark here, as I don’t understand much about JWT or Discovery… Can you try to verify your theory by cleaning up the discovery cache after tutor local stop? There are two ways to do that:

  1. The nuclear option: sudo rm -rf ~/.local/share/tutor/data/redis
  2. The clean option: tutor local run discovery ./ shell -c "from django.core.cache import cache; cache.clear()

I tried the clean option after running tutor local stop and before running a new tutor local quickstart (I am testing with Nutmeg) with a new domain name and it worked. Thanks @regis

Awesome. This probably means that we should be clear the cache every time we run the discovery initialisation tasks (part of tutor local do init or tutor local launch). Do you agree @sambapete? If yes, do you want to open a PR on the tutor-discovery plugin, or should I do it?

I will run another test today, just to be sure, and I will get back to you either today or tomorrow.