Skip to content

Update Sentry gem to version 5.1.1

Marius Bobin requested to merge mb-ruby-sentry-upgrade into master

What does this MR do and why?

Introduces a way to run both Sentry 9.1.2 and Sentry 21.9.0 with the goal of deprecating 9.1.2. Because the versions are not compatible and replacing one with the other would be a breaking change, we need to support both of them until the next major release.

https://asciinema.org/a/XZbPDmspyG2PTalYRMQgSETKO

Related to https://gitlab.com/gitlab-com/gl-infra/infrastructure/-/issues/12053

It brings back parts of !62387 (merged), but it doesn't implement the scrubber because I'm trying to keep it small. The scrubber will be added in a follow-up.

Enabling and/or disabling enable_new_sentry_integration and enable_old_sentry_integration events can be sent to a specific version of Sentry or both versions at the same time.

How to set up and validate locally

Running multiple instances of Sentry on you development environment(OSX edition)

Prerequisites:

Sentry reuses the docker volume names, so we're going to use two minikube VMs to isolate the installations.

brew install docker minikube hyperkit docker-credential-helper docker-compose

You're going to need two separate terminal windows:

# Setup a minikube VM:
minikube start --driver=hyperkit --cpus=4 --memory='8g' --namespace='sentry-9' --profile='sentry-9'
minikube --profile='sentry-9' pause # pause k8s containers
minikube --profile='sentry-9' docker-env  # inspect docker env
eval $(minikube -p sentry-9 docker-env)   # instruct docker cli to talk to minikube's docker-daemon
docker ps -aq | xargs -n 1 docker rm -f   # remove k8s containers

# install Sentry:
wget https://github.com/getsentry/onpremise/archive/refs/tags/9.1.2.zip
unzip 9.1.2.zip
cd self-hosted-9.1.2
./install.sh
# the docker-compose version check might fail, so you'll need comment the lines
# from 35 through 38 from `install.sh`

docker-compose up
minikube start --driver=hyperkit --cpus=4 --memory='8g' --namespace='sentry-22' --profile='sentry-22'

minikube --profile='sentry-22' pause # pause k8s containers
minikube --profile='sentry-22' docker-env
eval $(minikube -p sentry-22 docker-env) # instruct docker to talk to minikube's docker-daemon
docker ps -aq | xargs -n 1 docker rm -f # remove k8s containers

# open a new terminal window and run this command so that docker-compose can mount files:
minikube -p sentry-22 mount /path/to/current/dir:/path/to/current/dir 

# Back to the main window:

# install Sentry:
wget https://github.com/getsentry/self-hosted/archive/refs/tags/22.1.0.zip
unzip 22.1.0.zip
cd self-hosted-22.1.0/

# Skips the user prompt because it fails to grab the user input 
SKIP_USER_PROMPT=1 ./install.sh
# the docker-compose version check might fail, so you'll need comment the lines
# from 19 through 22 from `install/check-minimum-requirements.sh`

# create the user after installation completes
docker-compose run --rm web createuser

docker-compose up

Connecting to Sentry

Each minikube VM has its own IP address:

$> minikube -p sentry-9 ip
192.168.64.4
$> minikube -p sentry-22 ip
192.168.64.5

Sentry uses port 9000 for the web service, so the services can be accessed with:

  • 192.168.64.4:9000
  • 192.168.64.5:9000

Other problems

docker compose desc = error getting credentials - err: exec: "docker-credential-desktop": executable file not found in $PATH, out: ``

Can be fixed by changing:

$ cat ~/.docker/config.json
{
  "credsStore" : "desktop",
  "stackOrchestrator" : "swarm",
  "experimental" : "disabled",
  "auths" : {},
  "currentContext" : "default"
}

To:

$ cat ~/.docker/config.json
{
  "credsStore" : "osxkeychain",
  "stackOrchestrator" : "swarm",
  "experimental" : "disabled",
  "auths" : {},
  "currentContext" : "default"
}

Viewing minikube profiles

$ minikube profile list
|-----------|-----------|---------|---------------|------|---------|---------|-------|
|  Profile  | VM Driver | Runtime |      IP       | Port | Version | Status  | Nodes |
|-----------|-----------|---------|---------------|------|---------|---------|-------|
| minikube  | hyperkit  | docker  | 192.168.64.12 | 8443 | v1.23.1 | Stopped |     1 |
| sentry-20 | hyperkit  | docker  | 192.168.64.5  | 8443 | v1.22.2 | Stopped |     1 |
| sentry-22 | hyperkit  | docker  | 192.168.64.11 | 8443 | v1.23.1 | Stopped |     1 |
| sentry-9  | hyperkit  | docker  | 192.168.64.10 | 8443 | v1.23.1 | Stopped |     1 |
|-----------|-----------|---------|---------------|------|---------|---------|-------|

Screenshots

Sentry 9 Sentry 22
Exception captured in web Not available* Screen_Shot_2022-03-04_at_16.32.13-fullpage
Exception captured in API Screen_Shot_2022-03-04_at_16.49.56-fullpage Screen_Shot_2022-03-04_at_16.48.53-fullpage
Exception captured in GraphQL Screen_Shot_2022-03-04_at_16.55.22-fullpage Screen_Shot_2022-03-04_at_16.54.53-fullpage
Exception captured in Sidekiq Screen_Shot_2022-03-04_at_17.00.14-fullpage Screen_Shot_2022-03-04_at_17.00.06-fullpage
Manually captured an exception in web Screen_Shot_2022-03-04_at_17.04.20-fullpage Screen_Shot_2022-03-04_at_17.03.52-fullpage
Manually captured an exception in API Screen_Shot_2022-03-04_at_17.05.53-fullpage Screen_Shot_2022-03-04_at_17.05.34-fullpage
Manually captured an exception in GraphQL Screen_Shot_2022-03-04_at_17.04.55-fullpage Screen_Shot_2022-03-04_at_17.04.38-fullpage
Manually captured an exception in Sidekiq Screen_Shot_2022-03-04_at_17.41.38-fullpage Screen_Shot_2022-03-04_at_17.40.51-fullpage
Manually captured exception with sensitive information Screen_Shot_2022-03-04_at_17.07.39-fullpage Screen_Shot_2022-03-04_at_17.07.22-fullpage

* I think we're failing to capture controller errors because the middleware is introduced too late in the stack and the response is already turned into 500: https://github.com/getsentry/sentry-ruby/blob/master/sentry-raven/lib/raven/integrations/rails.rb#L12

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Marius Bobin

Merge request reports