Switch SESSION_ENGINE to memcached
Previously we were using cached_db session backend by default. However with django version update, it requires more recent mysqlclient module which is not part of requirements. Moreover usage of cached_db makes us to carry and maintain extra stuff, which can be dropped with memcached backend. Change-Id: I8df7ee967d8dcbeb09a42fd568f98acc3e88adad
This commit is contained in:
parent
c9bd84e398
commit
9c3c776c7a
@ -128,18 +128,14 @@ horizon_system_user_home: "/var/lib/{{ horizon_system_user_name }}"
|
||||
## Service Type and Data
|
||||
horizon_service_region: RegionOne
|
||||
horizon_service_name: horizon
|
||||
|
||||
## Database info
|
||||
horizon_db_setup_host: "{{ ('galera_all' in groups) | ternary(groups['galera_all'][0], 'localhost') }}"
|
||||
horizon_galera_address: "{{ galera_address | default('127.0.0.1') }}"
|
||||
horizon_galera_database: dash
|
||||
horizon_galera_user: dash
|
||||
horizon_galera_use_ssl: "{{ galera_use_ssl | default(False) }}"
|
||||
horizon_galera_ssl_ca_cert: "{{ galera_ssl_ca_cert | default('/etc/ssl/certs/galera-ca.pem') }}"
|
||||
|
||||
## Session configuration
|
||||
# Specifies the timespan in seconds inactivity, until a user is considered as
|
||||
# logged out
|
||||
horizon_session_engine: 'django.contrib.sessions.backends.cache'
|
||||
horizon_session_caches:
|
||||
default:
|
||||
BACKEND: 'django.core.cache.backends.memcached.MemcachedCache'
|
||||
LOCATION: "{{ memcached_servers.split(',') }}"
|
||||
horizon_session_timeout: 1800
|
||||
|
||||
## Horizon Help URL Path
|
||||
@ -393,7 +389,6 @@ horizon_listen_ports:
|
||||
|
||||
horizon_pip_packages:
|
||||
- horizon
|
||||
- PyMySQL
|
||||
- python-memcached
|
||||
|
||||
# Specific pip packages provided by the user
|
||||
|
11
releasenotes/notes/session_engine-54753c41d355e34e.yaml
Normal file
11
releasenotes/notes/session_engine-54753c41d355e34e.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
upgrade:
|
||||
- |
|
||||
`SESSION_ENGINE` has been changed to memcached by default. So that
|
||||
horizon do not require it's own database for storing session
|
||||
information anymore. `horizon_galera_*` variables has no effect now.
|
||||
features:
|
||||
- |
|
||||
Added variables `horizon_session_engine` and `horizon_session_caches`
|
||||
which can be used to configure horizon session engine and a backend
|
||||
for it.
|
@ -1,42 +0,0 @@
|
||||
---
|
||||
# Copyright 2019, 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.
|
||||
|
||||
# WARNING:
|
||||
# This file is maintained in the openstack-ansible-tests repository.
|
||||
# https://git.openstack.org/cgit/openstack/openstack-ansible-tests/tree/sync/tasks/db_setup.yml
|
||||
# If you need to modify this file, update the one in the openstack-ansible-tests
|
||||
# repository. Once it merges there, the changes will automatically be proposed to
|
||||
# all the repositories which use it.
|
||||
|
||||
- name: Setup Database Service (MariaDB)
|
||||
delegate_to: "{{ _oslodb_setup_host }}"
|
||||
tags:
|
||||
- common-mariadb
|
||||
block:
|
||||
- name: Create database for service
|
||||
mysql_db:
|
||||
name: "{{ item.name }}"
|
||||
loop: "{{ _oslodb_databases }}"
|
||||
no_log: true
|
||||
|
||||
- name: Grant access to the database for the service
|
||||
mysql_user:
|
||||
name: "{{ item.1.username }}"
|
||||
password: "{{ item.1.password }}"
|
||||
host: "{{ item.1.host | default('%') }}"
|
||||
priv: "{{ item.0.name }}.*:{{ item.1.priv | default('ALL') }}"
|
||||
append_privs: yes
|
||||
loop: "{{ _oslodb_databases | subelements('users') }}"
|
||||
no_log: true
|
@ -1,29 +0,0 @@
|
||||
---
|
||||
# Copyright 2014, Rackspace US, 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.
|
||||
|
||||
- name: Perform a horizon DB sync
|
||||
command: "{{ horizon_manage }} migrate --noinput"
|
||||
become: yes
|
||||
become_user: "{{ horizon_system_user_name }}"
|
||||
changed_when: false
|
||||
|
||||
- name: Register DB session cleanup cron
|
||||
cron:
|
||||
name: "Clear out expired sessions"
|
||||
minute: "{{ 58 | random(seed=inventory_hostname, start=2) }}"
|
||||
hour: "21"
|
||||
job: "{{ horizon_manage }} clearsessions"
|
||||
user: "{{ horizon_system_user_name }}"
|
||||
state: present
|
@ -119,3 +119,13 @@
|
||||
register: async_compress_static_files
|
||||
async: 600
|
||||
poll: 0
|
||||
|
||||
- name: Register DB session cleanup cron
|
||||
cron:
|
||||
name: "Clear out expired sessions"
|
||||
minute: "{{ 58 | random(seed=inventory_hostname, start=2) }}"
|
||||
hour: "21"
|
||||
job: "{{ horizon_manage }} clearsessions"
|
||||
user: "{{ horizon_system_user_name }}"
|
||||
state: present
|
||||
when: inventory_hostname == ansible_play_hosts[0]
|
||||
|
@ -39,19 +39,6 @@
|
||||
tags:
|
||||
- always
|
||||
|
||||
- import_tasks: db_setup.yml
|
||||
when: inventory_hostname == ansible_play_hosts[0]
|
||||
vars:
|
||||
_oslodb_setup_host: "{{ horizon_db_setup_host }}"
|
||||
_oslodb_databases:
|
||||
- name: "{{ horizon_galera_database }}"
|
||||
users:
|
||||
- username: "{{ horizon_galera_user }}"
|
||||
password: "{{ horizon_container_mysql_password }}"
|
||||
tags:
|
||||
- common-db
|
||||
- horizon-config
|
||||
|
||||
- import_tasks: horizon_pre_install.yml
|
||||
tags:
|
||||
- horizon-install
|
||||
@ -64,11 +51,6 @@
|
||||
tags:
|
||||
- horizon-config
|
||||
|
||||
- import_tasks: horizon_db_sync.yml
|
||||
when: inventory_hostname == ansible_play_hosts[0]
|
||||
tags:
|
||||
- horizon-config
|
||||
|
||||
- import_tasks: horizon_ssl_self_signed.yml
|
||||
when:
|
||||
- horizon_enable_ssl | bool
|
||||
|
@ -13,11 +13,8 @@
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
import pymysql
|
||||
import sys
|
||||
|
||||
pymysql.install_as_MySQLdb()
|
||||
|
||||
from django.core.management import execute_from_command_line # noqa
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -1,12 +1,9 @@
|
||||
import logging
|
||||
import os
|
||||
import pymysql
|
||||
import sys
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
from django.conf import settings
|
||||
|
||||
pymysql.install_as_MySQLdb()
|
||||
|
||||
# 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'
|
||||
|
@ -1,6 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import pymysql
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
@ -9,8 +8,6 @@ from horizon.utils import secret_key
|
||||
from openstack_dashboard import exceptions
|
||||
from openstack_dashboard.settings import HORIZON_CONFIG
|
||||
|
||||
pymysql.install_as_MySQLdb()
|
||||
|
||||
DEBUG = {{ debug }}
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
|
||||
@ -142,28 +139,10 @@ SECRET_KEY = secret_key.generate_or_read_from_file(
|
||||
# We recommend you use memcached for development; otherwise after every reload
|
||||
# of the django development server, you will have to login again. To use
|
||||
# memcached set CACHES to something like
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
|
||||
'LOCATION': {{ memcached_servers.split(',') }}
|
||||
}
|
||||
}
|
||||
CACHES = {{ horizon_session_caches }}
|
||||
|
||||
# Set the session engine configuration:
|
||||
SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.mysql',
|
||||
'HOST': '{{ horizon_galera_address }}',
|
||||
'NAME': '{{ horizon_galera_database }}',
|
||||
'USER': '{{ horizon_galera_user }}',
|
||||
'PASSWORD': '{{ horizon_container_mysql_password }}',
|
||||
'default-character-set': 'utf8'
|
||||
{% if horizon_galera_use_ssl | bool -%}
|
||||
,'ssl-ca': '{{ horizon_galera_ssl_ca_cert }}'
|
||||
{% endif -%}
|
||||
},
|
||||
}
|
||||
SESSION_ENGINE = '{{ horizon_session_engine }}'
|
||||
|
||||
# Send email to the console by default
|
||||
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
||||
|
@ -35,7 +35,6 @@ horizon_service_distro_packages:
|
||||
- python3-django-openstack-auth
|
||||
- python3-django-horizon
|
||||
- python3-memcache
|
||||
- python3-pymysql
|
||||
|
||||
horizon_apache_conf: "/etc/apache2/apache2.conf"
|
||||
horizon_apache_security_conf: "/etc/apache2/conf-available/security.conf"
|
||||
|
@ -42,7 +42,6 @@ horizon_service_distro_packages:
|
||||
- openstack-octavia-ui
|
||||
- python-django-horizon
|
||||
- python-memcached
|
||||
- python-PyMySQL
|
||||
|
||||
horizon_apache_conf: "/etc/httpd/conf/httpd.conf"
|
||||
horizon_apache_security_conf: "{{ horizon_apache_conf }}"
|
||||
|
@ -43,7 +43,6 @@ horizon_service_distro_packages:
|
||||
- openstack-horizon-plugin-trove-ui
|
||||
- python-horizon
|
||||
- python-memcached
|
||||
- python-PyMySQL
|
||||
|
||||
# SUSE does not currently have packages for the following dashboards
|
||||
horizon_enable_heat_ui: False
|
||||
|
Loading…
x
Reference in New Issue
Block a user