From ba4a978f92d541cb02e2ff98205a58f14f50d6b1 Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Fri, 7 Aug 2020 12:00:37 -0400 Subject: [PATCH] Add Sentry to Keystone Change-Id: Ic24c0e6eefaf6a14062ddf65480d04c4ec670215 --- images/keystone/Dockerfile | 2 ++ images/keystone/keystone-wsgi-public | 25 +++++++++++++++++++ images/keystone/requirements.txt | 1 + .../templates/keystone/daemonset.yml.j2 | 6 ++++- 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 images/keystone/keystone-wsgi-public diff --git a/images/keystone/Dockerfile b/images/keystone/Dockerfile index b89768b3..c368277b 100644 --- a/images/keystone/Dockerfile +++ b/images/keystone/Dockerfile @@ -16,6 +16,8 @@ FROM vexxhost/python-builder AS builder FROM vexxhost/python-base +COPY keystone-wsgi-public /usr/local/bin/keystone-wsgi-public + EXPOSE 5000 ENV UWSGI_HTTP_SOCKET=:5000 UWSGI_WSGI_FILE=/usr/local/bin/keystone-wsgi-public CMD ["/usr/local/bin/uwsgi", "--ini", "/etc/uwsgi/uwsgi.ini"] diff --git a/images/keystone/keystone-wsgi-public b/images/keystone/keystone-wsgi-public new file mode 100644 index 00000000..3c049717 --- /dev/null +++ b/images/keystone/keystone-wsgi-public @@ -0,0 +1,25 @@ +#!/usr/local/bin/python +# Copyright (c) 2020 VEXXHOST, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import sentry_sdk + +from keystone.server.wsgi import initialize_public_application +from sentry_sdk.integrations import wsgi + +sentry_sdk.init(traces_sample_rate=0.1) + +application = initialize_public_application() +application = wsgi.SentryWsgiMiddleware(application) diff --git a/images/keystone/requirements.txt b/images/keystone/requirements.txt index fefb9efd..b93d2118 100644 --- a/images/keystone/requirements.txt +++ b/images/keystone/requirements.txt @@ -2,3 +2,4 @@ uWSGI keystone PyMySQL python-memcached +sentry-sdk diff --git a/openstack_operator/templates/keystone/daemonset.yml.j2 b/openstack_operator/templates/keystone/daemonset.yml.j2 index 6ba70b99..0f64b986 100644 --- a/openstack_operator/templates/keystone/daemonset.yml.j2 +++ b/openstack_operator/templates/keystone/daemonset.yml.j2 @@ -98,6 +98,10 @@ spec: image: vexxhost/keystone:latest imagePullPolicy: Always env: + {% if 'sentryDSN' in spec %} + - name: SENTRY_DSN + value: spec['sentryDSN'] + {% endif %} {% for v in env %} - name: "{{ v.name }}" value: "{{ v.value }}" @@ -155,4 +159,4 @@ spec: {% if 'hostAliases' in spec %} hostAliases: {{ spec.hostAliases | to_yaml | indent(8) }} -{% endif %} \ No newline at end of file +{% endif %}