empty account listing inconsistent 204/200 reply with format=json

Bug #1183169 reported by clayg
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Object Storage (swift)
Fix Released
Critical
Samuel Merritt

Bug Description

If you asked for json, swift used to always return 200 with a valid json message body on GET /AUTH_acct - now it returns 204 if the account is empty. I think the previous behavior of returning 200 with an empty json list "[]" was better/more correct. Regardless it's an API change and should probably be treated as a regression. For example it breaks swift3.

Unfortunately it's not a trivial fix, since there's no way to get the 200 out of the account servers' who were previously doing the light lifting of generating the valid json response unless you *actually* create the account. So I'ma guess we'll just have to add some accept-header/format-querystring parsing to whoever generates this spoofed response. What a mess.

This is unrelated, but I'll mention it because it sort of surprised me. Every time I GET an empty uncreated account - swift has to ask every backend device (and handoffs) before it will return the spoofed 204. Swift always did this on the first request to an empty account, except then it would auto-create it, so on the second request it would return 204 after one back-end request. So until something actually uses the account swift is sort of chatty, but a 404 is cheap, just surprising...

Tags: api
Revision history for this message
clayg (clay-gerrard) wrote :

BEFORE (fd3acd2e5944251b3a473d2936f33f11101d56e4^1):

    clayg@swift:~$ curl -H 'x-auth-token: AUTH_tk' http://localhost/v1/AUTH_test?format=json -v
    * About to connect() to localhost port 80 (#0)
    * Trying 127.0.0.1... connected
    > GET /v1/AUTH_test?format=json HTTP/1.1
    > User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
    > Host: localhost
    > Accept: */*
    > x-auth-token: AUTH_tk1652a904f71a4869a13df050e6e886e2
    >
    < HTTP/1.1 200 OK
    < Content-Length: 2
    < Accept-Ranges: bytes
    < X-Timestamp: 1369274744.48164
    < X-Account-Bytes-Used: 0
    < X-Account-Container-Count: 0
    < Content-Type: application/json; charset=utf-8
    < X-Account-Object-Count: 0
    < Date: Thu, 23 May 2013 02:05:50 GMT
    <
    * Connection #0 to host localhost left intact
    * Closing connection #0
    []

AFTER (master):

    clayg@swift:~$ curl -H 'x-auth-token: AUTH_tk' http://localhost/v1/AUTH_test?format=json -v
    * About to connect() to localhost port 80 (#0)
    * Trying 127.0.0.1... connected
    > GET /v1/AUTH_test?format=json HTTP/1.1
    > User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
    > Host: localhost
    > Accept: */*
    > x-auth-token: AUTH_tk1652a904f71a4869a13df050e6e886e2
    >
    < HTTP/1.1 204 No Content
    < Content-Length: 0
    < Accept-Ranges: bytes
    < X-Timestamp: 1369274645.16959
    < X-Account-Bytes-Used: 0
    < X-Account-Container-Count: 0
    < Content-Type: text/plain; charset=utf-8
    < X-Account-Object-Count: 0
    < Date: Thu, 23 May 2013 02:04:05 GMT
    <
    * Connection #0 to host localhost left intact
    * Closing connection #0

Revision history for this message
gholt (gholt) wrote :

Yeah, I agree the response change isn't right. The xml response changed too, of course. I'm actually surprised my Swiftly handled this okay; I must've had a similar situation somewhere else in Swift before.

Anyway, this should be fixed before the next "official" release, so I'm going to up the levels or whatever. Maybe Hadas would like to tackle this since he was just in there?

Changed in swift:
importance: Undecided → Critical
status: New → Confirmed
clayg (clay-gerrard)
description: updated
Changed in swift:
assignee: nobody → Samuel Merritt (torgomatic)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to swift (master)

Fix proposed to branch: master
Review: https://review.openstack.org/30797

Changed in swift:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to swift (master)

Reviewed: https://review.openstack.org/30797
Committed: http://github.com/openstack/swift/commit/15c2ca55f02e1785f999a6790d9a5ff033449bcb
Submitter: Jenkins
Branch: master

commit 15c2ca55f02e1785f999a6790d9a5ff033449bcb
Author: Samuel Merritt <email address hidden>
Date: Thu May 23 18:53:51 2013 -0700

    Fix faked-out account GET for JSON and XML.

    If account autocreation is on and the proxy receives a GET request for
    a nonexistent account, it'll fake up a response that makes it look as
    if the account exists, but without reifying that account into sqlite
    DB files.

    That faked-out response was just fine as long as you wanted a
    text/plain response, but it didn't handle the case of format=json or
    format=xml; in those cases, the response would still be
    text/plain. This can break clients, and certainly causes crashes in
    swift3. Now, those responses match as closely as possible.

    The code for generating an account-listing response has been pulled
    into (the new) swift.account.utils module, and both the fake response
    and the real response use it, thus ensuring that they can't
    accidentally diverge. There's also a new probe test for that
    non-divergence.

    Also, cleaned up a redundant matching of the Accept header in the code
    for generating the account listing.

    Note that some of the added tests here pass with or without this code
    change; they were added because the code I was changing (parts of the
    real account GET) wasn't covered by tests.

    Bug 1183169

    Change-Id: I2a3b8e5d9053e4d0280a320f31efa7c90c94bb06

Changed in swift:
status: In Progress → Fix Committed
Changed in swift:
milestone: none → 1.9.0
Thierry Carrez (ttx)
Changed in swift:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.