Hi @BYK
After some more work I managed to get the update going, although I still have some problems that I’m working on.
In my case (I’m writing this in case other people are in a similar situation) I had to do the following to get database migration going:
- set myself as admin user (as I’m taking over this sentry installation from another colleague)
$ docker exec -it sentry-postgres /bin/sh
$ psql -U postgres
postgres=# update auth_user set is_superuser=True where email = '<myemail>' ;
UPDATE 1
postgres=# update auth_user set is_staff=True where email = '<myemail>' ;
UPDATE 1
postgres=# update auth_user set is_active=True where email = '<myemail>' ;
- disable email sending from the testing instance (remove SMTP-related environment variables)
- change my user’s password (as I initially signed up using old gitlab auth):
postgres=# select username from auth_user where email='<myemail>';
username
----------------------------------
2402e6ea0FFFFFFFFFFFFFFFFF
(1 row)
postgres=#
then
docker exec -it sentry_web_1 /bin/bash
root@9d36d3f6d0e1:/usr/local/bin# sentry django changepassword 2402e6ea0FFFFFFFFFFFFFFFFF
14:57:21 [WARNING] sentry.utils.geo: settings.GEOIP_PATH_MMDB not configured.
14:57:28 [INFO] sentry.plugins.github: apps-not-configured
Changing password for user '2402e6ea0FFFFFFFFFFFFFFFFF'
Password:
Password (again):
Password changed successfully for user '2402e6ea0FFFFFFFFFFFFFFFFF'
-
start the old sentry and disable gitlab authentication
-
remove old events
docker exec -it sentry_web_1 /bin/bash
root@9d36d3f6d0e1:/usr/local/bin# sentry cleanup --days 0
this is going to take a while, and then I also run a full vacuumdb just to be sure.
- shut down sentry except for postgres, and delete releases (table
sentry_releases
) from the database migrating those have create index problems. This sadly implies deleting data from a bunch of other tables due to foreign keys. It’s mostly okay I guess because I mostly care about keeping users, projects and DSNs.
So:
delete from sentry_release_project ;
delete from sentry_releaseprojectenvironment ;
delete from sentry_deploy ;
delete from sentry_grouphash ;
delete from sentry_activity ;
delete from sentry_groupemailthread ;
delete from sentry_grouprulestatus ;
delete from sentry_groupseen ;
delete from sentry_groupsubscription ;
delete from sentry_groupasignee ;
delete from sentry_groupbookmark ;
delete from sentry_groupedmessage ;
delete from sentry_releaseheadcommit ;
delete from sentry_releasecommit ;
delete from sentry_releasefile;
delete from sentry_release;
- Now I can start the actual migration. I copy the postgres folders along with the sentry-data folder over to the new installation and create docker volumes pointing to those directories:
docker volume create \
-d local \
-o type=none \
-o o=bind \
-o "device=/storage/sentry21/sentry/data/sentry" \
sentry-data
docker volume create \
-d local \
-o type=none \
-o o=bind \
-o "device=/storage/sentry21/sentry/data/postgres" \
sentry-postgres
- patch the docker-compose.yml file so that nginx can load tls certificates and binds to port 443.
- run the
install.sh
- add
sentry-auth-oidc==5.0.0
to sentry’s requirements.txt
and then configure the sentry-auth-oidc plugin (OIDC_CLIENT_ID
, OIDC_CLIENT_SECRET
, OIDC_SCOPE
and OIDC_DOMAIN
)
- boot the sentry containers
- login with my email and password set in step 3
- configure login with gitlab again.
This kinda works, projects are still available, users and DSNs too.
However, this minor inconvenience came up while testing with an user: when he logged in via oidc (backed by gitlab) a new user with the same Full Name and email is created, and of course a different username
(username
as in username property of the django auth system, reflected in the auth_user table in postgres).
I tried digging up the source code for the sentry-oidc-auth plugin as well as some of the Sentry code but it’s a bit too much of a rabbit hole for me.
@BYK is there anything that you think I could do to have existing users in sentry be matched to users in gitlab? That’s effectively the last thing I need to get our development sentry updated (we use sentry cloud for production).
Thank you in advance!
esantoro