Remove sentry integration
It was introduced by #2159 because the various machines were hard to monitor. Since we moved to botmaster there is no longer a problem with that and if it ever served us is hard to say as the sentry project's password is lost for years. So simplify the exception handling by just throwing it
This commit is contained in:
parent
3e14e55fde
commit
d6fb5d680c
19
ReviewBot.py
19
ReviewBot.py
@ -18,7 +18,6 @@ from osclib.core import request_action_key
|
||||
from osclib.core import request_age
|
||||
from osclib.memoize import memoize
|
||||
from osclib.memoize import memoize_session_reset
|
||||
from osclib.sentry import sentry_init
|
||||
from osclib.stagingapi import StagingAPI
|
||||
import signal
|
||||
import datetime
|
||||
@ -32,9 +31,6 @@ from urllib.error import HTTPError, URLError
|
||||
|
||||
from itertools import count
|
||||
|
||||
# In-case not properly initialized via the CommandLineInterface.
|
||||
sentry_sdk = sentry_init()
|
||||
|
||||
|
||||
class PackageLookup(object):
|
||||
""" helper class to manage 00Meta/lookup.yml
|
||||
@ -186,8 +182,6 @@ class ReviewBot(object):
|
||||
for req in self.requests:
|
||||
self.logger.info("checking %s" % req.reqid)
|
||||
self.request = req
|
||||
with sentry_sdk.configure_scope() as scope:
|
||||
scope.set_extra('request.id', self.request.reqid)
|
||||
|
||||
# XXX: this is a hack. Annotating the request with staging_project.
|
||||
# OBS itself should provide an API for that but that's currently not the case
|
||||
@ -202,15 +196,13 @@ class ReviewBot(object):
|
||||
|
||||
try:
|
||||
good = self.check_one_request(req)
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
good = None
|
||||
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
return_value = 1
|
||||
|
||||
sentry_sdk.capture_exception(e)
|
||||
|
||||
if self.review_mode == 'no':
|
||||
good = None
|
||||
elif self.review_mode == 'accept':
|
||||
@ -439,8 +431,6 @@ class ReviewBot(object):
|
||||
# Store in-case sub-classes need direct access to original values.
|
||||
self.action = a
|
||||
key = request_action_key(a)
|
||||
with sentry_sdk.configure_scope() as scope:
|
||||
scope.set_extra('action.key', key)
|
||||
|
||||
override = self.request_override_check()
|
||||
if override is not None:
|
||||
@ -897,11 +887,6 @@ class CommandLineInterface(cmdln.Cmdln):
|
||||
if self.options.fallback_group:
|
||||
self.checker.fallback_group = self.options.fallback_group
|
||||
|
||||
sentry_init(conf.config['apiurl'], {
|
||||
'review_bot': self.clazz.__name__,
|
||||
'review_user': self.checker.review_user,
|
||||
})
|
||||
|
||||
def setup_checker(self):
|
||||
""" reimplement this """
|
||||
apiurl = conf.config['apiurl']
|
||||
@ -991,8 +976,6 @@ class CommandLineInterface(cmdln.Cmdln):
|
||||
self.logger.info("sleeping %d minutes." % interval)
|
||||
time.sleep(interval * 60)
|
||||
|
||||
sentry_sdk.flush()
|
||||
|
||||
# Reset all memoize session caches which are designed for single
|
||||
# tool run and not extended usage.
|
||||
memoize_session_reset()
|
||||
|
2
dist/package/openSUSE-release-tools.spec
vendored
2
dist/package/openSUSE-release-tools.spec
vendored
@ -238,8 +238,6 @@ Group: Development/Tools/Other
|
||||
Requires: %{name} = %{version}
|
||||
Requires: osc >= 0.165.1
|
||||
Requires: python3-osc
|
||||
# internal API change related to accessing DSN in osclib/sentry.py
|
||||
Suggests: python3-sentry-sdk >= 0.11.0
|
||||
BuildArch: noarch
|
||||
|
||||
%description -n osclib
|
||||
|
@ -11,10 +11,7 @@ from socketserver import ThreadingMixIn
|
||||
import json
|
||||
import tempfile
|
||||
import os
|
||||
from osc import conf
|
||||
from osclib import common
|
||||
from osclib.sentry import sentry_client
|
||||
from osclib.sentry import sentry_init
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
@ -27,15 +24,10 @@ from urllib.parse import parse_qs
|
||||
# https://stackoverflow.com/a/47012250, workaround by making EVERYTHING LEGAL!
|
||||
http.cookies._is_legal_key = lambda _: True
|
||||
|
||||
sentry_sdk = sentry_init()
|
||||
|
||||
# Available in python 3.7.
|
||||
|
||||
|
||||
class ThreadedHTTPServer(ThreadingMixIn, HTTPServer):
|
||||
def handle_error(self, request, client_address):
|
||||
super().handle_error(request, client_address)
|
||||
sentry_sdk.capture_exception()
|
||||
|
||||
|
||||
class RequestHandler(BaseHTTPRequestHandler):
|
||||
@ -179,14 +171,9 @@ class RequestHandler(BaseHTTPRequestHandler):
|
||||
return None
|
||||
|
||||
def oscrc_create(self, oscrc_file, apiurl, cookiejar_file, user):
|
||||
sentry_dsn = sentry_client().dsn
|
||||
sentry_environment = sentry_client().options.get('environment')
|
||||
|
||||
oscrc_file.write('\n'.join([
|
||||
'[general]',
|
||||
# Passthru sentry_sdk options to allow for reporting on subcommands.
|
||||
'sentry_sdk.dsn = {}'.format(sentry_dsn) if sentry_dsn else '',
|
||||
'sentry_sdk.environment = {}'.format(sentry_environment) if sentry_environment else '',
|
||||
'apiurl = {}'.format(apiurl),
|
||||
'cookiejar = {}'.format(cookiejar_file.name),
|
||||
'staging.color = 0',
|
||||
@ -371,9 +358,6 @@ class OSCRequestEnvironmentException(Exception):
|
||||
|
||||
|
||||
def main(args):
|
||||
conf.get_config() # Allow sentry DSN to be available.
|
||||
sentry_init()
|
||||
|
||||
RequestHandler.apiurl = args.apiurl
|
||||
RequestHandler.session = args.session
|
||||
RequestHandler.debug = args.debug
|
||||
|
@ -25,7 +25,6 @@ from osclib.origin import origin_revision_state
|
||||
from osclib.origin import origin_updatable
|
||||
from osclib.origin import origin_updatable_initial
|
||||
from osclib.origin import origin_update
|
||||
from osclib.sentry import sentry_init
|
||||
from osclib.util import mail_send
|
||||
from shutil import copyfile
|
||||
import sys
|
||||
@ -101,14 +100,8 @@ def do_origin(self, subcmd, opts, *args):
|
||||
if not config:
|
||||
raise oscerr.WrongArgs('OSRT:OriginConfig attribute missing from {}'.format(opts.project))
|
||||
|
||||
sentry_sdk = sentry_init(apiurl, {'osc_plugin': subcmd})
|
||||
try:
|
||||
function = 'osrt_origin_{}'.format(command)
|
||||
globals()[function](apiurl, opts, *args[1:])
|
||||
except Exception as e:
|
||||
# Capture exception as osc.babysitter will consume any plugin exception.
|
||||
sentry_sdk.capture_exception(e)
|
||||
raise e
|
||||
function = 'osrt_origin_{}'.format(command)
|
||||
globals()[function](apiurl, opts, *args[1:])
|
||||
|
||||
|
||||
def osrt_origin_config(apiurl, opts, *args):
|
||||
|
@ -32,7 +32,6 @@ from osclib.unselect_command import UnselectCommand
|
||||
from osclib.repair_command import RepairCommand
|
||||
from osclib.rebuild_command import RebuildCommand
|
||||
from osclib.request_splitter import RequestSplitter
|
||||
from osclib.sentry import sentry_init
|
||||
from osclib.supersede_command import SupersedeCommand
|
||||
from osclib.prio_command import PrioCommand
|
||||
|
||||
@ -392,8 +391,6 @@ def do_staging(self, subcmd, opts, *args):
|
||||
if value:
|
||||
setattr(Fore, name, ansi.code_to_chars(value))
|
||||
|
||||
sentry_init(opts.apiurl, {'osc_plugin': subcmd})
|
||||
|
||||
if opts.wipe_cache:
|
||||
Cache.delete_all()
|
||||
|
||||
|
@ -1,60 +0,0 @@
|
||||
from osc import conf
|
||||
from osc import core
|
||||
from osclib.common import VERSION
|
||||
|
||||
|
||||
def sentry_init(obs_apiurl=None, tags=None):
|
||||
try:
|
||||
import sentry_sdk
|
||||
except ImportError:
|
||||
sentry_init.client = sentry_client_dummy()
|
||||
return sentry_sdk_dummy()
|
||||
|
||||
sentry_init.client = sentry_sdk.init(
|
||||
conf.config.get('sentry_sdk.dsn'),
|
||||
environment=conf.config.get('sentry_sdk.environment'),
|
||||
release=VERSION)
|
||||
|
||||
with sentry_sdk.configure_scope() as scope:
|
||||
scope.set_tag('osc', core.__version__)
|
||||
|
||||
if obs_apiurl:
|
||||
scope.set_tag('obs_apiurl', obs_apiurl)
|
||||
scope.user = {'username': conf.get_apiurl_usr(obs_apiurl)}
|
||||
|
||||
if tags:
|
||||
for key, value in tags.items():
|
||||
scope.set_tag(key, value)
|
||||
|
||||
return sentry_sdk
|
||||
|
||||
|
||||
def sentry_client():
|
||||
return sentry_init.client._client
|
||||
|
||||
|
||||
class sentry_sdk_dummy:
|
||||
def configure_scope(*args, **kw):
|
||||
return nop_class()
|
||||
|
||||
def __getattr__(self, _):
|
||||
return nop_func
|
||||
|
||||
|
||||
class nop_class:
|
||||
def __enter__(self):
|
||||
return nop_class()
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
pass
|
||||
|
||||
def __getattr__(self, _):
|
||||
return nop_func
|
||||
|
||||
|
||||
class sentry_client_dummy(nop_class):
|
||||
options = {}
|
||||
|
||||
|
||||
def nop_func(*args, **kw):
|
||||
pass
|
Loading…
x
Reference in New Issue
Block a user