1c88d2cb81
get_account_info used to work like this: * make an account HEAD request * ignore the response * get the account info by digging around in the request environment, where it had been deposited by elves or something Not actually elves, but the proxy's GETorHEAD_base method would take the HEAD response and cache it in the response environment, which was the same object as the request environment, thus enabling get_account_info to find it. This was extraordinarily brittle. If a WSGI middleware were to shallow-copy the request environment, then any middlewares to its left could not use get_account_info, as the left middleware's request environment would no longer be identical to the response environment down in GETorHEAD_base. Now, get_account_info works like this: * make an account HEAD request. * if the account info is in the request environment, return it. This is an optimization to avoid a double-set in memcached. * else, compute the account info from the response headers, store it in caches, and return it. This is much easier to think about; get_account_info can get and cache account info all on its own; the cache check and cache set are right next to each other. All the above is true for get_container_info as well. get_info() is still around, but it's just a shim. It was trying to unify get_account_info and get_container_info to exploit the commonalities, but the number of times that "if container:" showed up in get_info and its helpers really indicated that something was wrong. I'd rather have two functions with some duplication than one function with no duplication but a bunch of "if container:" branches. Other things of note: * a HEAD request to a deleted account returns 410, but get_account_info would return 404 since the 410 came from the account controller *after* GETorHEAD_base ran. Now get_account_info returns 410 as well. * cache validity period (recheck_account_existence and recheck_container_existence) is now communicated to get_account_info via an X-Backend header. This way, get_account_info doesn't need a reference to the swift.proxy.server.Application object. * both logged swift_source values are now correct for get_container_info calls; before, on a cold cache, get_container_info would call get_account_info but not pass along swift_source, resulting in get_account_info logging "GET_INFO" as the source. Amusingly, there was a unit test asserting this bogus behavior. * callers that modify the return value of get_account_info or of get_container_info don't modify what's stored in swift.infocache. * get_account_info on an account that *can* be autocreated but has not been will return a 200, same as a HEAD request. The old behavior was a 404 from get_account_info but a 200 from HEAD. Callers can tell the difference by looking at info['account_really_exists'] if they need to know the difference (there is one call site that needs to know, in container PUT). Note: this is for all accounts when the proxy's "account_autocreate" setting is on. Change-Id: I5167714025ec7237f7e6dd4759c2c6eb959b3fca |
||
---|---|---|
bin | ||
doc | ||
etc | ||
examples | ||
swift | ||
test | ||
.alltests | ||
.coveragerc | ||
.functests | ||
.gitignore | ||
.gitreview | ||
.mailmap | ||
.manpages | ||
.probetests | ||
.testr.conf | ||
.unittests | ||
AUTHORS | ||
babel.cfg | ||
bandit.yaml | ||
CHANGELOG | ||
CONTRIBUTING.rst | ||
LICENSE | ||
MANIFEST.in | ||
README.rst | ||
requirements.txt | ||
REVIEW_GUIDELINES.rst | ||
setup.cfg | ||
setup.py | ||
test-requirements.txt | ||
tox.ini |
Swift
A distributed object storage system designed to scale from a single machine to thousands of servers. Swift is optimized for multi-tenancy and high concurrency. Swift is ideal for backups, web and mobile content, and any other unstructured data that can grow without bound.
Swift provides a simple, REST-based API fully documented at http://docs.openstack.org/.
Swift was originally developed as the basis for Rackspace's Cloud Files and was open-sourced in 2010 as part of the OpenStack project. It has since grown to include contributions from many companies and has spawned a thriving ecosystem of 3rd party tools. Swift's contributors are listed in the AUTHORS file.
Docs
To build documentation install sphinx
(pip install sphinx
), run
python setup.py build_sphinx
, and then browse to
/doc/build/html/index.html. These docs are auto-generated after every
commit and available online at http://docs.openstack.org/developer/swift/.
For Developers
Getting Started
Swift is part of OpenStack and follows the code contribution, review, and testing processes common to all OpenStack projects.
If you would like to start contributing, check out these notes to help you get started.
The best place to get started is the "SAIO - Swift All In One". This document will walk you through setting up a development cluster of Swift in a VM. The SAIO environment is ideal for running small-scale tests against swift and trying out new features and bug fixes.
Tests
There are three types of tests included in Swift's source tree.
- Unit tests
- Functional tests
- Probe tests
Unit tests check that small sections of the code behave properly. For example, a unit test may test a single function to ensure that various input gives the expected output. This validates that the code is correct and regressions are not introduced.
Functional tests check that the client API is working as expected. These can be run against any endpoint claiming to support the Swift API (although some tests require multiple accounts with different privilege levels). These are "black box" tests that ensure that client apps written against Swift will continue to work.
Probe tests are "white box" tests that validate the internal workings of a Swift cluster. They are written to work against the "SAIO - Swift All In One" dev environment. For example, a probe test may create an object, delete one replica, and ensure that the background consistency processes find and correct the error.
You can run unit tests with .unittests
, functional tests
with .functests
, and probe tests with
.probetests
. There is an additional .alltests
script that wraps the other three.
Code Organization
- bin/: Executable scripts that are the processes run by the deployer
- doc/: Documentation
- etc/: Sample config files
- examples/: Config snippets used in the docs
- swift/: Core code
- account/: account server
- cli/: code that backs some of the CLI tools in bin/
- common/: code shared by different modules
- middleware/: "standard", officially-supported middleware
- ring/: code implementing Swift's ring
- container/: container server
- locale/: internationalization (translation) data
- obj/: object server
- proxy/: proxy server
- test/: Unit, functional, and probe tests
Data Flow
Swift is a WSGI application and uses eventlet's WSGI server. After
the processes are running, the entry point for new requests is the
Application
class in swift/proxy/server.py
.
From there, a controller is chosen, and the request is processed. The
proxy may choose to forward the request to a back- end server. For
example, the entry point for requests to the object server is the
ObjectController
class in
swift/obj/server.py
.
For Deployers
Deployer docs are also available at http://docs.openstack.org/developer/swift/. A good starting point is at http://docs.openstack.org/developer/swift/deployment\_guide.html
There is an ops runbook that gives information about how to diagnose and troubleshoot common issues when running a Swift cluster.
You can run functional tests against a swift cluster with
.functests
. These functional tests require
/etc/swift/test.conf
to run. A sample config file can be
found in this source tree in test/sample.conf
.
For Client Apps
For client applications, official Python language bindings are provided at http://github.com/openstack/python-swiftclient.
Complete API documentation at http://docs.openstack.org/api/openstack-object-storage/1.0/content/
There is a large ecosystem of applications and libraries that support and work with OpenStack Swift. Several are listed on the associated projects page.
For more information come hang out in #openstack-swift on freenode.
Thanks,
The Swift Development Team