Home > openstack, Uncategorized > Swift Proxy Server Code Flow

Swift Proxy Server Code Flow

In this note I like to walk through the code of OpenStack Swift proxy-server to have a abstracted view of what is going on here.. In order to do that, I have watched the output of following  script of a default devstack (only Swift & Keystone) installation.

 

/opt/stack/swift/bin/swift-proxy-server /etc/swift/proxy-server.conf -v

Before we deal with the code flow, lets talk about the directory structure of Swift proxy server..

 

 

1. The proxy server code is in the directory of /opt/stack/swift/swift/proxy/. Following figure shows the tree view of it.

For example, when we run the command of  ” /opt/stack/swift/bin/swift-proxy-server /etc/swift/proxy-server.conf -v “,

actually, servery.py shown in the figure  is executed.

 

 

Directory Strcutre of Swift Proxy server

 

 

2. Inside proxy directory there is another directory named ‘controllers’ which in turn have ‘container.py’, ‘obj.py’ and ‘account.py’. (see the figure). Worth to mention that these controller files are used to pass request to corresponding server. For example, when the swift proxy server receives a request for downloading a file, it discovers that the request  is related to object server and uses controllers/obj.py script to create a new http request to the swift-object-server.

 

Now, lets walk through the swift-proxy-server code.

1. When swift proxy server is running, and it receives a swift request, __call__() method is the first place to be called.

 

2.  handle_request method is called next.

a. handle_request method looks into the request parameter and loads either of the ‘controllers/account.py’ or ‘controllers/container.py’ or ‘controllers/obj.py’ (check it here). For example, if we run the following curl command to upload a file,

curl -X PUT -i -H “X-Auth-Token: $TOKEN” -T file $STORAGE_URL/container1/file ,

this is a file upload command, so handle_request method would load ‘controllers/obj.py’ or  ObjectController (more specific to say)

 

3. Now, if we look into the ObjectController code, we see it has method declared for PUT, GET, POST, HEAD methods. PUT method in our case will be fired.

 

4. These methods (for example assume PUT), build a http request to send a it to the corresponding running server. In our case, for the given curl example, the request will be send to the swift-object-server.

 

Advertisements
Categories: openstack, Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: