From 28be6108c98854a5fe606adecadc9af2892aabf7 Mon Sep 17 00:00:00 2001 From: Joshua Hesketh Date: Thu, 3 Jul 2014 15:33:21 +1000 Subject: [PATCH] Ensure there is a slash in the object prefix zuul sends the destination address without a trailing slash. This is because the LOG_PATH does not contain one. Check to see if we need to add a slash to object paths before pushing to swift Change-Id: I3e43c4ea266b57028fcaf9aa5fd09f1f5e37c306 --- .../files/slave_scripts/zuul_swift_upload.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/openstack_project/files/slave_scripts/zuul_swift_upload.py b/modules/openstack_project/files/slave_scripts/zuul_swift_upload.py index 27209940a6..4d27c1fd92 100755 --- a/modules/openstack_project/files/slave_scripts/zuul_swift_upload.py +++ b/modules/openstack_project/files/slave_scripts/zuul_swift_upload.py @@ -92,8 +92,14 @@ def swift_form_post_submit(file_list, url, hmac_body, signature): files = {} + # Zuul's log path is generated without a tailing slash. As such the + # object prefix does not contain a slash and the files would be + # uploaded as 'prefix' + 'filename'. Assume we want the destination + # url to look like a folder and make sure there's a slash between. + filename_prefix = '/' if url[-1] != '/' else '' for i, f in enumerate(file_list): - files['file%d' % (i + 1)] = (f['filename'], open(f['path'], 'rb'), + files['file%d' % (i + 1)] = (filename_prefix + f['filename'], + open(f['path'], 'rb'), get_file_mime(f['path'])) requests.post(url, data=payload, files=files)