Skip to content

Instantly share code, notes, and snippets.

@alistairncoles
alistairncoles / time_yield_objects.py
Created January 27, 2023 15:08
time_yield_objects
(swift-3.8.15) (acoles) ~/0dev/openstack/swift{p-misplaced-faster} % git show -q|cat
commit eef67f5319da794b7786ed0613cdbc77889551af
(swift-3.8.15) (acoles) ~/0dev/openstack/swift{p-misplaced-faster} % PYTHONPATH=. python ./time_yield_objects.py 1000000 10
Unable to read test config /etc/swift/test.conf - file not found
yielded 1000000 rows in 1.718s
yielded 1000000 rows in 1.350s
yielded 1000000 rows in 1.317s
yielded 1000000 rows in 1.356s
yielded 1000000 rows in 1.317s
yielded 1000000 rows in 1.535s
@alistairncoles
alistairncoles / hack_object_metadata.py
Last active March 21, 2018 12:59
hack object to remove x-delete-at
#!/usr/bin/python
import os
import sys
from swift.common.utils import Timestamp
from swift.obj import diskfile
#
# make this file executable.
@alistairncoles
alistairncoles / internal_delete_object_metadata.py
Last active March 20, 2018 16:00
use internal client to delete object metadata
#!/usr/bin/python
import argparse
import swift.common.internal_client as internal_client
DESCRIPTION = 'Delete object metadata via internal client. Use with extreme ' \
'caution. Must be run on a node with an internal-client.conf ' \
'file and access to the swift proxy server endpoint.'
@alistairncoles
alistairncoles / gist:8c7ed4ef1220f06b0591709c767a6346
Created March 31, 2016 16:01
Extra test for object versioning reverse listing
diff --git a/swift/common/middleware/versioned_writes.py b/swift/common/middleware/versioned_writes.py
index 51497c7..a742587 100644
--- a/swift/common/middleware/versioned_writes.py
+++ b/swift/common/middleware/versioned_writes.py
@@ -244,7 +244,7 @@ class VersionedWritesContext(WSGIContext):
first_item = sublisting[0]['name'].encode('utf-8')
last_item = sublisting[-1]['name'].encode('utf-8')
page_is_after_marker = marker and first_item > marker
- if reverse and (first_item < last_item or page_is_after_marker):
+ if reverse and (first_item <= last_item or page_is_after_marker):
@alistairncoles
alistairncoles / gist:8e7aeaf64780299a512e
Last active March 23, 2016 16:01
Slightly simpler auditor cleanup of unexpected files
diff --git a/swift/common/utils.py b/swift/common/utils.py
index 210dd9f..8397277 100644
--- a/swift/common/utils.py
+++ b/swift/common/utils.py
@@ -2124,18 +2124,19 @@ def unlink_older_than(path, mtime):
:param path: path to remove file from
:param mtime: timestamp of oldest file to keep
"""
- filepaths = map(functools.partial(os.path.join, path), listdir(path))
- return unlink_paths_older_than(filepaths, mtime)
@alistairncoles
alistairncoles / gist:0dd102384c47bfe95787
Created March 21, 2016 20:06
container sync fixups
diff --git a/swift/container/sync.py b/swift/container/sync.py
index 95cd38a..cbf6a34 100644
--- a/swift/container/sync.py
+++ b/swift/container/sync.py
@@ -409,10 +409,10 @@ class ContainerSync(Daemon):
self.logger.exception(_('ERROR Syncing %s'),
broker if broker else path)
- def _update_sync_to_headers(self, sync_to, name, realm_key, user_key,
- realm, method, headers):
@alistairncoles
alistairncoles / gist:0debf01f19c74eeaaf72
Created March 21, 2016 19:48
internal client test fixes
diff --git a/test/unit/common/test_internal_client.py b/test/unit/common/test_internal_client.py
index f0eea61..150f88c 100644
--- a/test/unit/common/test_internal_client.py
+++ b/test/unit/common/test_internal_client.py
@@ -14,6 +14,8 @@
# limitations under the License.
import json
+
+import itertools
@alistairncoles
alistairncoles / swift-port-stats.sh
Created March 21, 2016 19:44
Monitoring swift container sync traffic
#!/bin/bash
# could be smarter and read these ports from the server conf files...
OBJ_SERVER_PORTS="6010 6020 6030 6040"
PROXY_SERVER_PORT=8080
setup_rules() {
# $1 should be -A to set, -D to unset
OP=$1
@alistairncoles
alistairncoles / swift-port-stats.sh
Created March 21, 2016 19:43
Monitoring swift container sync traffic
#!/bin/bash
# could be smarter and read these ports from the server conf files...
OBJ_SERVER_PORTS="6010 6020 6030 6040"
PROXY_SERVER_PORT=8080
setup_rules() {
# $1 should be -A to set, -D to unset
OP=$1
@alistairncoles
alistairncoles / gist:abefa37ffd0abc70611c
Created March 17, 2016 17:52
TestConcurrentGets tweaks
diff --git a/test/unit/proxy/controllers/test_base.py b/test/unit/proxy/controllers/test_base.py
index 285909e..25742fd 100644
--- a/test/unit/proxy/controllers/test_base.py
+++ b/test/unit/proxy/controllers/test_base.py
@@ -911,6 +911,7 @@ class TestConcurrentGets(unittest.TestCase):
self._now = time.time()
self.tickets = []
self.finished_tickets = []
+ self.unused_tickets = 0