openstack team mailing list archive
-
openstack team
-
Mailing list archive
-
Message #20858
Re: [SWIFT] code reading
This part of the code gets the account info, but if the account isn't found and account autocreation is set (eg for tempauth and keystone), then we need to create the account first before returning the info.
However, since there are multiple replicas of the account in the cluster, we can't simply auto create after getting a 404. Swift is eventually consistent and the 404 may be stale data. We don't want to overwrite the account with a create if it already exists. So this loop is making sure that the account doesn't exist in any of <replica count> nodes, and if there is a combination of 404 and errors returned, we don't send another account create.
That's a little complicated, so here's some bullets:
Got any successful response (2xx) from a server: return the account info
Got 404 form all the servers: auto create the account and return the info (if the create was successful, else error)
Got any errors other than 404 or 507 but no success: return error (ie return None, None, None)
Got 507 from a server: skip that server for this an subsequent requests (ie error_limit) and carry on
--John
On Feb 12, 2013, at 4:11 AM, Kun Huang <Academicgareth@xxxxxxxxx> wrote:
> Hi, Chmouel and Darrell
>
> I know you're working on /swift/proxy/controllers/base.py for this bug: https://review.openstack.org/#/c/21563/
> I didn't know the https://github.com/openstack/swift/blob/master/swift/proxy/controllers/base.py#L371 to #372. Could you show me a simple understanding?
>
>
>
> elif resp.status == HTTP_NOT_FOUND:
>
>
>
> if result_code == 0:
>
>
>
> result_code = HTTP_NOT_FOUND
>
>
>
> elif result_code != HTTP_NOT_FOUND:
>
>
>
> result_code = -1
>
>
>
> In this part, given a 404 response, we should reset the variable result_code. If result_code is 0, reset it 404, 404 do nothing, and others set -1.
>
> What's the case for the "-1"?
> Furthermore, I simply think resp.status is sufficient condition to set result_code, so why these judgement need the result_code value in last loop (while attempts_left loop).
>
>
> Gareth
> _______________________________________________
> Mailing list: https://launchpad.net/~openstack
> Post to : openstack@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~openstack
> More help : https://help.launchpad.net/ListHelp
Follow ups
References