Skip to content

Instantly share code, notes, and snippets.

@jtopjian
Created January 5, 2016 18:05
Show Gist options
  • Select an option

  • Save jtopjian/9e79fce302d9d08de022 to your computer and use it in GitHub Desktop.

Select an option

Save jtopjian/9e79fce302d9d08de022 to your computer and use it in GitHub Desktop.
Swift Container Sync Patches
--- sync.py.orig 2016-01-05 10:27:16.701367539 -0700
+++ sync.py 2016-01-05 10:27:09.457341736 -0700
@@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import errno
import os
import uuid
from swift import gettext_ as _
@@ -21,6 +22,7 @@
from struct import unpack_from
from eventlet import sleep, Timeout
+from eventlet.green import urllib2
import swift.common.db
from swift.container.backend import ContainerBroker, DATADIR
@@ -360,8 +362,8 @@
delete_object(sync_to, name=row['name'], headers=headers,
proxy=self.select_http_proxy(),
logger=self.logger)
- except ClientException as err:
- if err.http_status != HTTP_NOT_FOUND:
+ except urllib2.HTTPError as err:
+ if err.code != HTTP_NOT_FOUND:
raise
self.container_deletes += 1
self.logger.increment('deletes')
@@ -436,14 +438,14 @@
self.container_puts += 1
self.logger.increment('puts')
self.logger.timing_since('puts.timing', start_time)
- except ClientException as err:
- if err.http_status == HTTP_UNAUTHORIZED:
+ except urllib2.HTTPError as err:
+ if err.code == HTTP_UNAUTHORIZED:
self.logger.info(
_('Unauth %(sync_from)r => %(sync_to)r'),
{'sync_from': '%s/%s' %
(quote(info['account']), quote(info['container'])),
'sync_to': sync_to})
- elif err.http_status == HTTP_NOT_FOUND:
+ elif err.code == HTTP_NOT_FOUND:
self.logger.info(
_('Not found %(sync_from)r => %(sync_to)r \
- object %(obj_name)r'),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment