Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
# Copyright (c) 2021 Nvidia
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@matthewoliver
matthewoliver / heatmap_disk_console.py
Last active February 18, 2021 00:55
heatmap_disk_console.py
import argparse
from subprocess import Popen, PIPE
import json
import sys
from operator import itemgetter
import time
import string
from signal import signal, SIGINT
COLOURS = [16, 17, 18, 19, 20, 21, 57, 56, 55, 54, 53, 52, 88, 124, 125, 160,
#!/usr/bin/env python
from graphviz import Graph
import sys
import time
import re
from collections import OrderedDict
from hashlib import md5
graph = Graph("config_info")
@matthewoliver
matthewoliver / rangescanner.py
Last active September 2, 2020 23:28
Random untested very hacky version of a range scanner, best path picker and gap filler code.
from swift.common.utils import Timestamp, ShardRange
from swift.container.sharder import DEFAULT_SHARD_CONTAINER_THRESHOLD, \
DEFAULT_SHARD_SHRINK_POINT
from itertools import chain
# This doesn't have to be in a class, was just trying to brainstorm and write something.
class RangesScanner(object):
def __init__(self, shard_account=None, root_conatiner=None,
ranges=None, shard_threshold=None, shrink_size=None):
@matthewoliver
matthewoliver / sr_overlaps.py
Created June 4, 2020 07:31
sr_overlaps.py - playing with SR ranges overlap and gap detection
from swift.common.utils import Timestamp, ShardRange
from collections import defaultdict
from pprint import pprint
range_list_sharded = (('', 'b'), ('b', 'c'), ('c','d'), ('b', 'd'), ('d', 'l'), ('l', 'q'), ('q', ''))
range_list_good = (('', 'c'), ('c', 'f'), ('f', 't'), ('t', ''))
range_list_extra = (('', 'd'), ('d', 'g'), ('g', 's'), ('s', ''))
@matthewoliver
matthewoliver / Infra_links.txt
Created May 3, 2019 16:48
Docker image zuul build conversation
@matthewoliver
matthewoliver / multi_keystone_reseller.patch
Created March 27, 2018 06:09
A patch the allows you to have multiple keystoneauth middlewares into a single proxy pipeline
diff --git a/swift/common/middleware/keystoneauth.py b/swift/common/middleware/keystoneauth.py
index cb1b4c7c3..57405079d 100644
--- a/swift/common/middleware/keystoneauth.py
+++ b/swift/common/middleware/keystoneauth.py
@@ -17,7 +17,8 @@ from swift.common.http import is_success
from swift.common.middleware import acl as swift_acl
from swift.common.request_helpers import get_sys_meta_prefix
from swift.common.swob import HTTPNotFound, HTTPForbidden, HTTPUnauthorized
-from swift.common.utils import config_read_reseller_options, list_from_csv
+from swift.common.utils import config_read_reseller_options, list_from_csv, \
import sys
from swift.common.ring.builder import RingBuilder
from swift.common.ring import Ring
import optparse
class PartDiff(object):
def _load_file(self, filename):
if filename.endswith('.gz'):
builder = Ring(filename)
builder.parts = builder.partition_count
@matthewoliver
matthewoliver / reloader.py
Created June 25, 2017 06:47
benchmark reloading times in Swift - start a bunch of proxies on the same port (SO_REUSEPORT) then roll through very quickly terminate and recreate proxies processes.
import multiprocessing
import time
from swift.common.wsgi import run_wsgi
def start_daemon(conf_file='/etc/swift/proxy-server.conf', options={}):
run_wsgi(conf_file, 'proxy-server', **options)
self.qemu_cmd = '%s -netdev type=%s,id=net0 -device %s,netdev=net0' % \
(self.qemu_cmd, 'user', netdev)