pyrax icon indicating copy to clipboard operation
pyrax copied to clipboard

Unable to set X-DELETE-AFTER header

Open behemphi opened this issue 13 years ago • 8 comments

I just read through the pull requests for #64 and #66, #67. I am not a Pythonista, so I am loathe to attempt this. (I do wish I was though!)

The X-DELETE-AFTER header is extremely useful to me on the file storage side for automagically deleting database backups after a certain amount of time. If we were using the CDN they would be great for cache expiry. Give this, I am likely missing the code that sets them or the doc that explains it.

The other side of this is that I am not sure this header is valid any longer. Here is the doc: http://docs.rackspace.com/files/api/v1/cf-devguide/content/Expiring_Objects-e1e3228.html). It does appear that swift supports x-delete-after as well.

behemphi avatar May 29 '13 01:05 behemphi

This is a good addition. I will add it after I'm done with the 1.4 release, which should be out in the next day or two.

EdLeafe avatar May 29 '13 13:05 EdLeafe

Thanks for the quick response.

On Wed, May 29, 2013 at 8:15 AM, Ed Leafe [email protected] wrote:

This is a good addition. I will add it after I'm done with the 1.4 release, which should be out in the next day or two.

— Reply to this email directly or view it on GitHubhttps://github.com/rackspace/pyrax/issues/76#issuecomment-18615280 .

Best Regards Boyd Hemphill Chief Systems Architect www.feedmagnet.com [email protected] (512) 470-6146

behemphi avatar May 29 '13 13:05 behemphi

Added in 1.4.3; commit 5fb3ad891b

EdLeafe avatar Jun 03 '13 15:06 EdLeafe

@EdLeafe

(Please do not read the below as complaining, it is an observation about a potential blind spot)

I have tested this in that I can run it with the code and don't get an error.

However I cannot find a way to read the headers of a file at all. Neither the classic control panel or the new one provide the header info. The new CP does not even seem to provide meta data.

I am not sure if it is relevant to you to that success is "untestable" for this change.

That said, thanks for work on this! I will know in 7 days if this worked or not.

behemphi avatar Jun 05 '13 20:06 behemphi

That information is not available via the API, so there is no way to expose it in pyrax.

To test, I created some small files with various TTLs, and tested how long it took for each to disappear from a listing. They all were deleted within a minute of the expected time. If you find out anything after your 7 days have elapsed, please let me know. ;-)

EdLeafe avatar Jun 05 '13 22:06 EdLeafe

It's possible to detect when an object will be deleted via the Cloud Files API. Just issue an HTTP HEAD on the object in question and look for the X-Delete-At header.

For example:

auth=my_auth_token
files=rackspace_cloud_files_endpoint_associated_with_my_account
http put $files/container/delete-me-soon x-auth-token:$auth x-delete-after:30
# some HTTPie output
http head $files/container/delete-me-soon x-auth-token:$auth
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: 2109
Content-Type: application/json; charset=utf-8
Date: Thu, 06 Jun 2013 01:05:07 GMT
Etag: 6cbad8ca5dd0a5d0a2de722860b02855
Last-Modified: Thu, 06 Jun 2013 01:04:59 GMT
X-Delete-At: 1370480729
X-Timestamp: 1370480699.48837
X-Trans-Id: tx9734cfbb922c466e95340331c95b51c3

The X-Delete-After is converted to X-Delete-At internally.

queertypes avatar Jun 06 '13 01:06 queertypes

What I meant is that it is not exposed directly in python-swiftclient as a direct call that pyrax could wrap. I could hack the head_object() method of the connection class to look for that header, but I'm not sure how fragile that would be.

EdLeafe avatar Jun 06 '13 14:06 EdLeafe

Ah, thanks for clarifying! :)

I've not dived into the python-swiftclient sources, so I can't say either way. I'd love to hear from the project's maintainer on adding support for exposing that information.

queertypes avatar Jun 06 '13 17:06 queertypes