Wednesday, April 6, 2016

OpenStack Swift – tips to get through SAIO installation

OpenStack Swift – tips to get through SAIO installation

What this blog is not for –
This blog is not intended to give step by step instructions for installing OpenStack Swift All In One (SAIO) on a single node, but if you are looking for that, please refer to http://docs.openstack.org/developer/swift/development_saio.html [1] which provides sufficient information for a successful setup (might also provide you reasons to visit this blog back!:) )
This blog lists the potential errors along with their fixes, during SAIO setup on an Ubuntu 14.04 LTS server, while following the instructions from [1]. Issues and fixes are categorized in that order.
·       
        Getting the code/ build a development installation of Swift:
$ sudo pip install –r requirements.txt
Error:
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 262, in run
for req in parse_requirements(filename, finder=finder, options=options, session=session):
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1632, in parse_requirements
req = InstallRequirement.from_line(line, comes_from, prereleases=getattr(options, "pre", None))
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 173, in from_line
return cls(req, comes_from, url=url, prereleases=prereleases)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 71, in __init__
req = pkg_resources.Requirement.parse(req)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2667, in parse
reqs = list(parse_requirements(s))
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2605, in parse_requirements
line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec")
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2583, in scan_list
"Expected ',' or end-of-list in",line,"at",line[p:]
ValueError: ("Expected ',' or end-of-list in", "dnspython>=1.12.0;python_version<'3.0'", 'at', ";python_version<'3.0'") Storing debug log for failure in /home/stack/.pip/pip.log

Fix: Possible cause: older pip version; uninstall pip and install from http://pip.readthedocs.org/en/stable/installing/
$ sudo apt-get purge python-pip
$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python get-pip.py

Error:
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 262, in run
for req in parse_requirements(filename, finder=finder, options=options, session=session):
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1632, in parse_requirements
req = InstallRequirement.from_line(line, comes_from, prereleases=getattr(options, "pre", None))
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 173, in from_line
return cls(req, comes_from, url=url, prereleases=prereleases)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 71, in __init__
req = pkg_resources.Requirement.parse(req)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2667, in parse
reqs = list(parse_requirements(s))
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2605, in parse_requirements
line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec")
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2583, in scan_list
"Expected ',' or end-of-list in",line,"at",line[p:]
ValueError: ("Expected ',' or end-of-list in", "dnspython>=1.12.0;python_version<'3.0'", 'at', ";python_version<'3.0'")
Storing debug log for failure in /home/swift/.pip/pip.log
error in setup command: Invalid environment marker: (python_version>='3.0')

Fix:
$ sudo pip install -U pip tox pbr virtualenv setuptools
$ sudo apt-get install libpython3.4-dev

·        While verifying the unit tests run:
$ sudo python setup.py develop
Error:
error in setup command: Invalid environment marker: (python_version>='3.0')

Fix:
$ sudo pip install -U pip tox pbr virtualenv setuptools

·        While verifying the unit tests run:
$ HOME/swift/.unittests
Error:
liberasurecode[20837]: liberasurecode_backend_open: dynamic linking error libJerasure.so: cannot open shared object file: No such file or directory
ERROR: Invalid Storage Policy Configuration in /etc/swift/swift.conf (Error creating EC policy (pyeclib_c_init ERROR: Invalid arguments. Please inspect syslog for liberasurecode error report.), for index 2)
/home/swift/swift

Fix: check if libJerasure is present, install if not
$ sudo find / -name "libJerasure.so*"
$ sudo apt-get install liberasurecode-dev

Error:
File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 411, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 47, in importFromPath return self.importFromDir(dir_path, fqname)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/home/swift/swift/test/unit/obj/test_replicator.py", line 37, in <module>
from swift.obj import diskfile, replicator as object_replicator
File "/home/swift/swift/swift/obj/replicator.py", line 23, in <module>
from six import viewkeys
ImportError: cannot import name viewkeys

Fix:
#remove the default python-six package
$ sudo apt-get remove python-six
#pip install the six package
$ sudo pip install -U six


·        Start the “main” Swift daemon processes:
$ startmain
Error:
File "/usr/local/bin/swift-container-server", line 6, in <module>
    exec(compile(open(__file__).read(), __file__, 'exec'))
File "/home/swift/swift/bin/swift-container-server", line 23, in <module>
    sys.exit(run_wsgi(conf_file, 'container-server', **options))
File "/home/swift/swift/swift/common/wsgi.py", line 883, in run_wsgi
    error_msg = strategy.bind_ports()
File "/home/swift/swift/swift/common/wsgi.py", line 481, in bind_ports
    self.sock = get_socket(self.conf)
File "/home/swift/swift/swift/common/wsgi.py", line 201, in get_socket
    bind_addr[0], bind_addr[1], bind_timeout))
Exception: Could not bind to 127.0.0.1:6011 after trying for 30 seconds

Traceback (most recent call last):
File "/usr/local/bin/swift-account-server", line 6, in <module>
  exec(compile(open(__file__).read(), __file__, 'exec'))
File "/home/swift/swift/bin/swift-account-server", line 23, in <module>
    sys.exit(run_wsgi(conf_file, 'account-server', **options))
File "/home/swift/swift/swift/common/wsgi.py", line 883, in run_wsgi
    error_msg = strategy.bind_ports()
File "/home/swift/swift/swift/common/wsgi.py", line 481, in bind_ports
    self.sock = get_socket(self.conf)
File "/home/swift/swift/swift/common/wsgi.py", line 201, in get_socket
    bind_addr[0], bind_addr[1], bind_timeout))
Exception: Could not bind to 127.0.0.1:6012 after trying for 30 seconds

Fix:
When running SAIO, sometimes the servers will fail to load (with the above error) as ports 6012/11/10 is/are in use by ‘sshd’. This happens when you have enabled port forwarding on your VM and connect to it.
1.        Edit /etc/ssh/sshd_config
2.        Change X11DisplayOffset to a different number (say set it to 100)
3.        Kill all SSH connections and restart ssh daemon.

$ sudo vim /etc/ssh/sshd_config
$ ps –ef | grep ssh
$ sudo kill -5 <PID>
$ sudo service ssh restart

·     While verifying the functionality tests :
$ HOME/swift/.functests
Error:
$ ./.functests
Traceback (most recent call last):
  File "/usr/local/bin/ostestr", line 7, in <module>
    from os_testr.os_testr import main
  File "/usr/local/lib/python2.7/dist-packages/os_testr/__init__.py", line 15, in <module>
    import pbr.version
ImportError: No module named pbr.version

Fix:  Check if pbr is installed
1. If not present, install
$ sudo apt-get purge python-setuptools
$ sudo apt-get install python-pbr
$ sudo pip install -r requirements.txt
$ sudo pip install -r test-requirements.txt 

2. If pbr were present say in python-swiftclient directory, then delete that .egg for pbr
$ sudo rm –rf pbr-<version> .egg
$ sudo pip install –r requirements.txt –upgrade
$ cd ../swift
$ sudo pip install six --upgrade
$ sudo pip install mock –upgrade

Please note above are some of the most commonly encountered issues, given that you are correctly following the instructions provided at [1]. There could be several issues such as - you  miss a step  to replace <your-user-name> with your username as mentioned in [1] or your proxy settings or user permissions etc. which are user/environment-specific , all of which are not covered in this blog; but feel free to reach out for further tips/answers. Most of the fixes/tips listed here can be found online, and are put here together to help new contributors to OpenStack Swift community.

If you have already gone through the SAIO setup, and have faced more issues/found fixes, then you are welcome to leave comments/suggestions and share your approaches.


References:
[1] OpenStack Swift documentation for SAIO development setup. Available online at http://docs.openstack.org/developer/swift/development_saio.html