Attempt to fix swift_pypy memory issues

Move to use tempauth to resolve memory issues resulting from an AIO
swift install running in pypy.

This PR adds some options for using pypy:
* Set a pypy Garbage collection value

This PR includes some tempauth fixes to make it useable:
* Set the tempauth users based on a variable

Testing is changed as follows for pypy:
* Use only memcache within swift-proxy
* Remove galera/keystone
* Add swap for swift-storage hosts
* Use tempauth for pypy
* Reduce to 2 swift hosts

Change-Id: Ic1ed5acc9b20853d9a159035226f97fda088f035
This commit is contained in:
Andy McCrae 2016-10-14 13:27:04 +01:00
parent e8e08ec3e2
commit 3fb6784459
12 changed files with 189 additions and 13 deletions

View File

@ -79,6 +79,10 @@ swift_middleware_list:
- proxy-logging
- proxy-server
# Setup tempauth users list (user_<account>_<username> = <password> <roles>)
swift_tempauth_users:
- "user_admin_admin = admin .admin .reseller_admin"
## Swift default ports
swift_proxy_port: "8080"
# You can change the object, container, account ports.
@ -387,10 +391,15 @@ swift_pretend_min_part_hours_passed: False
# Set this option to enable or disable the pypy interpreter for swift
swift_pypy_enabled: false
swift_pypy_archive:
url: "https://bitbucket.org/pypy/pypy/downloads/pypy2-v5.3.1-linux64.tar.bz2"
sha256: "6d0e8b14875b76b1e77f06a2ee3f1fb5015a645a951ba7a7586289344d4d9c22"
url: "https://bitbucket.org/pypy/pypy/downloads/pypy2-v5.6.0-linux64.tar.bz2"
sha256: "aad55328cb0673a60b2633dcc3c36cf452917ac906b577eb3aed5876a7666fca"
swift_pypy_version: "{{ swift_pypy_archive['url'] | basename | replace('.tar.bz2', '') }}"
swift_pypy_env: "/opt/pypy-runtime/{{ swift_pypy_version }}/bin/pypy"
# Set the Garbage Collection (GC) options for pypy if you would like to tune these
# More info on pypy garbage collection can be found here:
# http://doc.pypy.org/en/latest/gc_info.html
#swift_pypy_gc_min: "15M"
#swift_pypy_gc_max: "1GB"
# This variable is used by the repo_build process to determine
# which host group to check for members of before building the

View File

@ -0,0 +1,10 @@
---
features:
- When using the pypy python interpreter you can configure the garbage
collection (gc) settings for pypy. Set the minimum GC value using the
``swift_pypy_gc_min`` variable. GC will only happen when the memory
size is above this value. Set the maximum GC value using the
``swift_pypy_gc_max`` variable. This is the maximum memory heap size
for pypy.
Both variables are not defined by default, and will only be used if
the values are defined and ``swift_pypy_enabled`` is set to ``True``.

View File

@ -0,0 +1,8 @@
---
features:
- Swift tempauth users now be specified. The
``swift_tempauth_users`` variable can be defined as a list
of tempauth users, and their permissions. You will still
need to specify the appropriate Swift middleware using the
``swift_middleware_list`` variable, in order to utilise
tempauth.

View File

@ -112,6 +112,8 @@
- include: swift_sync_post_install.yml
static: no
when: swift_do_sync | bool
when:
- swift_do_sync | bool
- not swift_do_setup | bool
tags:
- always

View File

@ -71,10 +71,9 @@ sorting_method = {{ swift_sorting_method }}
{% if 'tempauth' in swift_middleware_list %}
[filter:tempauth]
use = egg:swift#tempauth
user_admin_admin = admin .admin .reseller_admin
user_test_tester = testing .admin
user_test2_tester2 = testing2 .admin
user_test_tester3 = testing3
{% for user in swift_tempauth_users %}
{{ user }}
{% endfor %}
{% endif %}
{% if 'authtoken' in swift_middleware_list %}

View File

@ -9,6 +9,14 @@ Type=simple
User={{ swift_system_user_name }}
Group={{ swift_system_group_name }}
{% if swift_pypy_enabled %}
{% if swift_pypy_gc_min is defined %}
Environment=PYPY_GC_MIN={{ swift_pypy_gc_min }}
{% endif %}
{% if swift_pypy_gc_max is defined %}
Environment=PYPY_GC_MAX={{ swift_pypy_gc_max }}
{% endif %}
{% endif %}
{% if item.value.program_override is defined %}
ExecStart={{ item.value.program_override }} {{ item.value.program_config_options|default('') }}
{% else %}

View File

@ -10,6 +10,14 @@ respawn limit 10 5
# Set the RUNBIN environment variable
env RUNBIN="{{ swift_bin }}/{{ item.value.program_binary | default(item.value.program_name) }}"
{% if swift_pypy_enabled %}
{% if swift_pypy_gc_min is defined %}
env PYPY_GC_MIN={{ swift_pypy_gc_min }}
{% endif %}
{% if swift_pypy_gc_max is defined %}
env PYPY_GC_MAX={{ swift_pypy_gc_max }}
{% endif %}
{% endif %}
# Change directory to service users home
chdir "{{ swift_system_home_folder }}"

43
tests/inventory_pypy Normal file
View File

@ -0,0 +1,43 @@
[all]
localhost
swift-proxy
swift-storage1
swift-storage2
[all_containers]
swift-proxy
swift-storage1
swift-storage2
[memcached_all]
swift-proxy
[service_all:children]
memcached_all
[swift_hosts]
swift-storage1
swift-storage2
[swift_proxy]
swift-proxy
[swift_acc]
swift-storage1
swift-storage2
[swift_cont]
swift-storage1
swift-storage2
[swift_obj]
swift-storage1
swift-storage2
[swift_all:children]
swift_acc
swift_proxy
swift_cont
swift_obj
[swift_remote_all]

View File

@ -0,0 +1,61 @@
---
# Copyright 2015, 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.
bridges:
- name: "br-mgmt"
ip_addr: "10.1.1.1"
- name: "br-storage"
ip_addr: "10.1.2.1"
- name: "br-repl"
ip_addr: "10.1.3.1"
# These values are quite low due to memory constraints in an AIO
swift_pypy_gc_min: "5M"
swift_pypy_gc_max: "200M"
swift_pypy_enabled: True
swift_middleware_list:
- catch_errors
- gatekeeper
- healthcheck
- proxy-logging
- "{% if swift_ceilometer_enabled | bool %}ceilometer{% endif %}"
- cache
- container_sync
- bulk
- tempurl
- ratelimit
- tempauth
- staticweb
- container-quotas
- account-quotas
- slo
- dlo
- proxy-logging
- proxy-server
swift_tempauth_users:
- "user_admin_admin = admin .admin .reseller_admin"
- "user_test1_test1 = test1 .admin"
- "user_test2_test2 = test2 .admin"
- "user_test1_test3 = test3"
- "user_test5_test5 = test5 service"
- "user_test6_test6 = test6 .reseller_admin"
swift_hard_open_file_limits: 30720
swift_soft_open_file_limits: 12288
swift_rsync_module_per_drive: True
test_swift_repl_number: 2

View File

@ -1,17 +1,20 @@
[func_test]
{% if groups['keystone_all'] is not defined %}
# sample config for Swift with tempauth
#auth_host = 10.100.100.2
#auth_port = 5000
#auth_ssl = no
#auth_prefix = /auth/
auth_host = {{ test_swift_proxy_host }}
auth_port = 8080
auth_ssl = no
auth_prefix = /auth/
{% else %}
## sample config for Swift with Keystone v2 API
# For keystone v2 change auth_version to 2 and auth_prefix to /v2.0/
# And "allow_account_management" should not be set "true"
auth_version = 3
auth_host = {{ hostvars[groups['keystone_all'][0]]['ansible_host'] }}
auth_host = {{ test_keystone_host }}
auth_port = 5000
auth_ssl = no
auth_prefix = /v3/
{% endif %}
# Primary functional test account (needs admin access to the account)
account = test1

View File

@ -20,6 +20,7 @@
- { project_name: "test2", domain_name: "Default" }
- { project_name: "test5", domain_name: "Default" }
- { project_name: "test6", domain_name: "Default" }
when: groups['keystone_all'] is defined
register: add_service
run_once: true
until: add_service|success
@ -37,6 +38,7 @@
with_items:
- "test-role"
- "test5"
when: groups['keystone_all'] is defined
run_once: true
register: add_service
until: add_service|success
@ -60,6 +62,7 @@
- { user_name: "test3", project_name: "test1", password: "test3", domain_name: "Default" }
- { user_name: "test5", project_name: "test5", password: "test5", domain_name: "Default" }
- { user_name: "test6", project_name: "test6", password: "test6", domain_name: "Default" }
when: groups['keystone_all'] is defined
run_once: true
register: add_service
until: add_service|success
@ -83,6 +86,7 @@
- { user_name: "test3", project_name: "test1", role_name: "test-role", domain_name: "Default" }
- { user_name: "test5", project_name: "test5", role_name: "test5", domain_name: "Default" }
- { user_name: "test6", project_name: "test6", role_name: "ResellerAdmin", domain_name: "Default" }
when: groups['keystone_all'] is defined
retries: 5
run_once: true
register: add_service
@ -108,6 +112,26 @@
dest: "/etc/swift/test.conf"
owner: "swift"
group: "swift"
- name: Create swap file for swift-storage hosts
command: dd if=/dev/zero of=/swift_swap bs=1M count=1024
when:
- inventory_hostname in groups['swift_hosts']
- name: Make swap for swift-storage hosts
command: mkswap /swift_swap
when:
- inventory_hostname in groups['swift_hosts']
- name: Add swap to fstab for swift-storage hosts
lineinfile:
dest: /etc/fstab
regexp: "swift_swap"
line: "/swift_swap none swap sw 0 0"
state: present
when:
- inventory_hostname in groups['swift_hosts']
- name: Turn swap on for swift-storage hosts
command: swapon -a
when:
- inventory_hostname in groups['swift_hosts']
- name: Run functional tests for swift
shell: "source /openstack/venvs/swift-untagged/bin/activate && ./.functests"
args:

View File

@ -116,7 +116,8 @@ deps =
{[testenv:ansible]deps}
setenv =
{[testenv]setenv}
ANSIBLE_PARAMETERS=-vvv -e swift_pypy_enabled=True
ANSIBLE_INVENTORY={toxinidir}/tests/inventory_pypy
ANSIBLE_OVERRIDES={toxinidir}/tests/os_swift-overrides-pypy.yml
commands =
{[testenv:tests_clone]commands}
bash -c "{toxinidir}/tests/common/test-ansible-functional.sh"