kiwix / operations

Kiwix Kubernetes Cluster
http://charts.k8s.kiwix.org/
5 stars 0 forks source link

Move youzim.it to zimit.kiwix.org #188

Closed benoit74 closed 2 months ago

benoit74 commented 2 months ago

Fix https://github.com/openzim/zimit-frontend/issues/31

Final strategy

Changes in hostnames

Previous hostname New hostname
youzim.it zimit.kiwix.org
farm.youzim.it farm.zimit.kiwix.org
api.farm.youzim.it api.farm.zimit.kiwix.org

New DNS records to create

Name  Type Value
zimit.kiwix.org CNAME services.k8s.kiwix.org
farm.zimit.kiwix.org CNAME services.k8s.kiwix.org
api.farm.zimit.kiwix.org CNAME services.k8s.kiwix.org

Web redirections

Add Web redirection in Gandi from youzim.it to zimit.kiwix.org Update existing web redirection from www.youzim.it

Email

New email address to send emails: Zimit <info@zimit.kiwix.org> technically redirected to contact+zimit@kiwix.org

DB queries

Check what should be updated and what would be the new value:

SELECT id, status, notification,
       jsonb_set(jsonb_set(notification::jsonb, '{ended, webhook, 0}', ('"' ||
                                                              replace(notification::jsonb -> 'ended' -> 'webhook' ->> 0,
                                                                      '/youzim.it/', '/zimit.kiwix.org/') ||
                                                              '"')::jsonb), '{requested, webhook, 0}', ('"' ||
                                                              replace(notification::jsonb -> 'requested' -> 'webhook' ->> 0,
                                                                      '/youzim.it/', '/zimit.kiwix.org/') ||
                                                              '"')::jsonb)
FROM task
WHERE status != 'succeeded' AND status != 'failed' AND status != 'canceled' AND notification <> '{}'::jsonb;

SELECT id,
       jsonb_set(jsonb_set(notification::jsonb, '{ended, webhook, 0}', ('"' ||
                                                              replace(notification::jsonb -> 'ended' -> 'webhook' ->> 0,
                                                                      '/youzim.it/', '/zimit.kiwix.org/') ||
                                                              '"')::jsonb), '{requested, webhook, 0}', ('"' ||
                                                              replace(notification::jsonb -> 'requested' -> 'webhook' ->> 0,
                                                                      '/youzim.it/', '/zimit.kiwix.org/') ||
                                                              '"')::jsonb)
FROM requested_task
WHERE notification <> '{}'::jsonb

Do the update:

UPDATE task
SET notification = jsonb_set(jsonb_set(notification::jsonb, '{ended, webhook, 0}', ('"' ||
                                                              replace(notification::jsonb -> 'ended' -> 'webhook' ->> 0,
                                                                      '/youzim.it/', '/zimit.kiwix.org/') ||
                                                              '"')::jsonb), '{requested, webhook, 0}', ('"' ||
                                                              replace(notification::jsonb -> 'requested' -> 'webhook' ->> 0,
                                                                      '/youzim.it/', '/zimit.kiwix.org/') ||
                                                              '"')::jsonb)
WHERE status != 'succeeded' AND status != 'failed' AND status != 'canceled' AND notification <> '{}'::jsonb;

UPDATE requested_task
SET notification = jsonb_set(jsonb_set(notification::jsonb, '{ended, webhook, 0}', ('"' ||
                                                              replace(notification::jsonb -> 'ended' -> 'webhook' ->> 0,
                                                                      '/youzim.it/', '/zimit.kiwix.org/') ||
                                                              '"')::jsonb), '{requested, webhook, 0}', ('"' ||
                                                              replace(notification::jsonb -> 'requested' -> 'webhook' ->> 0,
                                                                      '/youzim.it/', '/zimit.kiwix.org/') ||
                                                              '"')::jsonb)
WHERE notification <> '{}'::jsonb

Initial strategy (abandonned)

Previous hostname New hostname
youzim.it zimit.kiwix.org
farm.youzim.it zimit-farm.kiwix.org
api.farm.youzim.it zimit-farm-api.kiwix.org

Nota: I've changed the naming convention, because api.farm.zimit.kiwix.org means too many DNS wildcards from my perspective.

Open questions:

rgaudin commented 2 months ago

Nota: I've changed the naming convention, because api.farm.zimit.kiwix.org means too many DNS wildcards from my perspective.

What wildcard ?

rgaudin commented 2 months ago

I'd prefer we stick to the convention unless there's a valid reason not to. I'd only keep the old domain with redirect for youzim.it and coordinate with @audiodude for the deployment

benoit74 commented 2 months ago

What wildcard ?

If we stick to the convention then we need to add either wilcard CNAME DNS records or at least CNAME on the exact hosts.

benoit74 commented 2 months ago

I'd prefer we stick to the convention unless there's a valid reason not to.

Got it, reason has been exposed (new DNS records) but does not seems to be valid, I do not really mind TBH.

I'd only keep the old domain with redirect for youzim.it

I don't get it ; do you mean redirect only youzim.it and not other subdomains which are not known by end-users anyway? I'm a bit afraid of the impact regarding webhooks. But maybe we just need to fix them at DB level?

and coordinate with @audiodude for the deployment

Sure, this is why I would like to do it this week, it is going to be way easier

rgaudin commented 2 months ago

If we stick to the convention then we need to add either wilcard CNAME DNS records or at least CNAME on the exact hosts.

We use wildcards only if necessary (demo for instance). Here you'll have to create the 3 records.

I don't get it ; do you mean redirect only youzim.it and not other subdomains which are not known by end-users anyway? I'm a bit afraid of the impact regarding webhooks. But maybe we just need to fix them at DB level?

Yes, we can fix existing ones in DB… and make sure to deploy fix on wp1 at same time. We can even shutdown user services for a small duration

benoit74 commented 2 months ago

What about the email address? What should we use?

rgaudin commented 2 months ago

What about the email address? What should we use?

zimit@kiwix.org? And create a redirect of it to contact+zimit@kiwix.org?

audiodude commented 2 months ago

I don't get it ; do you mean redirect only youzim.it and not other subdomains which are not known by end-users anyway? I'm a bit afraid of the impact regarding webhooks. But maybe we just need to fix them at DB level?

Yes, we can fix existing ones in DB… and make sure to deploy fix on wp1 at same time. We can even shutdown user services for a small duration

This seems to imply that WP1 is the only consumer of the zimfarm API. Is that the case?

rgaudin commented 2 months ago

Yes, along with youzim.it that @benoit74 will take care of

audiodude commented 2 months ago

Just checked WP1 and the zimfarm URL is part of the external config. This means we can change it by simply updating the config and restarting the server, no code push needed. 👍

benoit74 commented 2 months ago

As expected, the "hackish" redirection with server-snippet is not working.

I think we should indeed serve a minimal static page with a message saying “The website has been moved to zimit.kiwix.org. If needed, please update your bookmarks. You will be automatically redirected in 5 seconds” and then redirect users after 5 secs. It is a bit of work, but way cleaner for the long term in fact. Probably branded with a zimit logo and that's it.

WDYT?

audiodude commented 2 months ago

I don't know anything about k8s, but in a pure nginx world, such a redirect would be very simple. I'm sure that doesn't help 😞

rgaudin commented 2 months ago

Pretty sure the standard redirect is the way to go ; you might have made a mistake

benoit74 commented 2 months ago

I've just updated the first comment and the code with new strategy

benoit74 commented 2 months ago

Migration completed, web redirection in Gandi will be ready in few hours