[Openstack] [Swift] : Update Operation

John Dickinson me at not.mn
Wed Jul 19 18:01:48 UTC 2017


You cannot partially upload objects to Swift. You must upload the full object each time, and Swift treats the objects as discrete entities. In your example, the entirety of objectB will be written to disk and the bytes used by objectA will be freed.

--John




On 19 Jul 2017, at 10:25, Sai Vishwas wrote:

> Dear Sir ,
>    Thanks a lot for your immediate response. I would like to make the
> question more clear. We are actually interested in learning the internal
> working of swift. Let us say I upload an objectA to my cluster under the
> name BestObject . So i now have BestObject in my cluster. Now I have
> modified a few bytes of objectA (not all bytes) and name that object
> locally as ObjectB. So now when i upload ObjectB to my cluster under the
> same name of BestObject, on swift while objectB is replacing objectA, will
> all the bytes of BestObject (on swift) be rewritten or only the ones
> changed. Or is it something like objectB is written in a new free disk
> space and the memory occupied by old objectA is freed.
>    It would be of great help if you could explain the internal working of
> swift with respect to this scenario.
>
> Thank you.
> Regards,
> Sai Vishwas
>
> On Wed, Jul 19, 2017 at 10:19 PM, John Dickinson <me at not.mn> wrote:
>
>> It depends on what you mean by "update", so let me describe the two things
>> it could mean.
>>
>> Suppose you upload cat.jpg to your cluster:
>>
>> curl -i -H "x-auth-token: foobar" https://awesome.swift.cluster.
>> foobar/v1/AUTH_me/cats/bestcat.jpg -T cat1.jpg -XPUT
>>
>> Now you've got bestcat.jpg in your cluster.
>>
>> But, oh no! You forgot to add your metadata to the picture. Let's do that:
>>
>> curl -i -H "x-auth-token: foobar" https://awesome.swift.cluster.
>> foobar/v1/AUTH_me/cats/bestcat.jpg -XPOST -H "x-object-meta-name: mr
>> snugglz" -H "x-object-meta-breed: tabby"
>>
>> In this case, the Swift cluster has updated the metadata, but the data
>> itself hasn't changed or moved.[1] This operation is fast and lightweight.
>> Note, however, that when you POST to an object, you must give the whole set
>> of x-object-meta-* keys and values. The metadata sent to an object on POST
>> replaces the current set.
>>
>> Oh no! We mis-spelled the cat's name! Let's fix it:
>>
>> curl -i -H "x-auth-token: foobar" https://awesome.swift.cluster.
>> foobar/v1/AUTH_me/cats/bestcat.jpg -XPOST -H "x-object-meta-name: mr
>> snuggles" -H "x-object-meta-breed: tabby"
>>
>> Tragedy strikes again! Mr Snuggles ran into the road and was hit by a car.
>> Tragic, yes, but you have overcome this trial and adopted a new cat from
>> the local rescue shelter. The new cat, Ms Sunshine, is better in every
>> possible way. We certainly can't still have a "bestcat.jpg" object that is
>> an old pic of Mr Sunggles!
>>
>> curl -i -H "x-auth-token: foobar" https://awesome.swift.cluster.
>> foobar/v1/AUTH_me/cats/bestcat.jpg -T cat2.jpg -H "x-object-meta-name: ms
>> sunshine" -H "x-object-meta-birthday: July 12, 2017" -XPUT
>>
>> Now Swift as written the data of cat2.jpg and replaced the previous
>> content that was there, along with the new metadata we set in the PUT
>> request.
>>
>> Swift is a durable storage system which means that it stores multiple
>> copies of the data in different places. If one of those locations was
>> offline when you did the overwrite and then came back online (e.g. a server
>> restarting), Swift will reconcile the data asynchronously in the
>> background. From the perspective of you the API user (or any client),
>> bestcat.jpg has the most up to data contents and the most recent metadata.
>>
>> [1] Assuming Swift 2.13.0 with default settings or Swift 2.7.0 or later
>> with object_post_as_copy set to False.
>>
>> Hope that helps
>>
>> --John
>>
>> On 19 Jul 2017, at 9:15, Sameer Kulkarni wrote:
>>
>> Hi All,
>>
>> How does update operation work in Swift?
>>
>> Like, does it deletes the older object and creates new entry or It finds
>> out which part of object is modified and just copies or pushes the modified
>> object?
>>
>>
>> Thank you
>> _______________________________________________
>> Mailing list: http://lists.openstack.org/cgi-bin/mailman/listinfo/
>> openstack
>> Post to : openstack at lists.openstack.org
>> Unsubscribe : http://lists.openstack.org/cgi-bin/mailman/listinfo/
>> openstack
>>
>>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack/attachments/20170719/f5d0df70/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: OpenPGP digital signature
URL: <http://lists.openstack.org/pipermail/openstack/attachments/20170719/f5d0df70/attachment.sig>


More information about the Openstack mailing list