diff --git a/images/horizon/Dockerfile b/images/horizon/Dockerfile index 83511e89..17016d4f 100644 --- a/images/horizon/Dockerfile +++ b/images/horizon/Dockerfile @@ -30,6 +30,7 @@ RUN python manage.py compilemessages && \ chown 1001 -R local/ ../static COPY *.svg ../static/dashboard/img/ COPY *.ico ../static/dashboard/img/ +COPY wsgi.py /usr/local/lib/python3.7/site-packages/openstack_dashboard/wsgi.py EXPOSE 8000 ENV UWSGI_HTTP_SOCKET=:8000 \ UWSGI_WSGI_FILE=/usr/local/lib/python3.7/site-packages/openstack_dashboard/wsgi.py \ diff --git a/images/horizon/requirements.txt b/images/horizon/requirements.txt index 40804ca5..70b84dd4 100644 --- a/images/horizon/requirements.txt +++ b/images/horizon/requirements.txt @@ -1,5 +1,6 @@ uWSGI python-memcached +sentry-sdk git+https://opendev.org/openstack/horizon@stable/ussuri git+https://opendev.org/openstack/heat-dashboard@stable/ussuri git+https://opendev.org/openstack/designate-dashboard@stable/ussuri diff --git a/images/horizon/wsgi.py b/images/horizon/wsgi.py new file mode 100644 index 00000000..8dbd215c --- /dev/null +++ b/images/horizon/wsgi.py @@ -0,0 +1,44 @@ +#!/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. + +""" +WSGI config for openstack_dashboard project. +""" + +import os +import sys + +import pkg_resources +import sentry_sdk + +from django.core.wsgi import get_wsgi_application +from sentry_sdk.integrations import wsgi + +VERSION = pkg_resources.get_distribution("horizon").version + +sentry_sdk.init( + release="horizon@%s" % VERSION, + traces_sample_rate=0.1 +) + +# Add this file path to sys.path in order to import settings +sys.path.insert(0, os.path.normpath(os.path.join( + os.path.dirname(os.path.realpath(__file__)), '..'))) +os.environ['DJANGO_SETTINGS_MODULE'] = 'openstack_dashboard.settings' +sys.stdout = sys.stderr + +application = get_wsgi_application() +application = wsgi.SentryWsgiMiddleware(application) diff --git a/openstack_operator/templates/horizon/daemonset.yml.j2 b/openstack_operator/templates/horizon/daemonset.yml.j2 index fc07be8e..2b3872e8 100644 --- a/openstack_operator/templates/horizon/daemonset.yml.j2 +++ b/openstack_operator/templates/horizon/daemonset.yml.j2 @@ -41,6 +41,10 @@ spec: image: vexxhost/horizon: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 }}"