Skip to content

Instantly share code, notes, and snippets.

@matthiasr
matthiasr / 1_intro.md
Last active May 9, 2022 14:45
Notes on operating cluster queues

Someone asked in chat (paraphrased) "I am coming from synchronous online systems, and now am going to work on a queue-based system. What should I be aware of?" This is a (somewhat freely-associated) collection of thoughts, based on my experience at SoundCloud.

@matthiasr
matthiasr / delete-s3.sh
Created December 14, 2020 09:18
Delete everything in an S3 bucket (in a hurry)
# I needed to delete ~300k objects from an S3 bucket in a hurry. The better and cheaper solution is to use a lifecycle rule, but those can take a day or two to take effect.
bucket="i-want-to-lose-all-my-data"
mkdir -p deletes
# 1. List all the objects in the bucket, transform them 1000 at a time into request objects for DeleteObjects, write each to a separate file
aws s3api list-objects-v2 --bucket "${bucket}" \
| jq -c '.Contents | _nwise(1000) | map({ Key: .Key }) | { Objects: ., Quiet: true }' \
| awk '{ f = "deletes/" NR ".json"; print $0 > f; close(f) }'
$ kubectl --namespace mr-test exec -ti hostname-test bash
root@hostname-test:/# cat /etc/hosts
# Kubernetes-managed hosts file.
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
fe00::0 ip6-mcastprefix
fe00::1 ip6-allnodes
fe00::2 ip6-allrouters
10.128.1.142 hostname-test
@matthiasr
matthiasr / LICENSE.md
Last active February 15, 2023 00:16
Exporting chef-client metrics to Prometheus

The MIT License (MIT)

Copyright © 2017 SoundCloud Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE

@matthiasr
matthiasr / out.txt
Created October 13, 2016 17:32
Kubernetes file permissions in tarball have changed
% for v in 1.3.5 1.3.6 1.3.7 1.3.8 1.4.0 1.4.1; do echo ========= $v ==========; curl -sSfL "https://github.com/kubernetes/kubernetes/releases/download/v${v}/kubernetes.tar.gz" | tar -O -zxf - kubernetes/server/kubernetes-server-linux-amd64.tar.gz | tar -tvzf -; done
========= 1.3.5 ==========
drwxr-xr-x 0 root root 0 Aug 11 20:35 kubernetes/
-rw-r--r-- 0 root root 3533536 Aug 11 20:35 kubernetes/LICENSES
-rw-r--r-- 0 root root 41933134 Aug 11 20:35 kubernetes/kubernetes-src.tar.gz
drwxr-xr-x 0 root root 0 Aug 11 20:35 kubernetes/server/
drwxr-xr-x 0 root root 0 Aug 11 20:35 kubernetes/server/bin/
-rw-r--r-- 0 root root 33 Aug 11 20:35 kubernetes/server/bin/federation-apiserver.docker_tag
-rw-r--r-- 0 root root 33 Aug 11 20:35 kubernetes/server/bin/federation-controller-manager.docker_tag
-rw-r--r-- 0 root root 104576512 Aug 11 20:35 kubernetes/server/bin/federation-apiserver.tar
#!/bin/sh
set -eufx
tmpdir=$(mktemp -d ./prometheus-1610.XXXX)
cd "${tmpdir}"
cleanup() {
set +e
@matthiasr
matthiasr / Makefile
Created January 13, 2016 15:22
Extract vendored kubernetes/kubernetes client library dependencies at build time
KUBERNETES_VERSION ?= v1.1.3
KUBERNETES_SOURCE_URL = https://github.com/kubernetes/kubernetes/archive/v$(KUBERNETES_VERSION).tar.gz
LOCAL_SOURCES := $(shell find local -type f)
.PHONY: prepare
prepare: vendor/k8s.io/kubernetes/.available vendor/k8s.io/kubernetes/.lifted_godeps $(LOCAL_SOURCES:local/%=vendor/%)
# Lift a source tree into the vendor tree, skipping Godeps
vendor/%/.available: build/$(KUBERNETES_VERSION)/%/.available

Keybase proof

I hereby claim:

  • I am matthiasr on github.
  • I am matthiasr (https://keybase.io/matthiasr) on keybase.
  • I have a public key whose fingerprint is F46A 5FAA 9508 311D DBCC 403A 9A7D 111C AE60 D44B

To claim this, I am signing this object:

@matthiasr
matthiasr / gist:5805902
Created June 18, 2013 14:38
Translate from ss(8) to netstat(8) TCP state names (AWK dictionary)
translate["ESTAB"] = "ESTABLISHED";
translate["SYN-SENT"] = "SYN_SENT";
translate["SYN-RECV"] = "SYN_RECV";
translate["FIN-WAIT-1"] = "FIN_WAIT1";
translate["FIN-WAIT-2"] = "FIN_WAIT2";
translate["TIME-WAIT"] = "TIME_WAIT";
translate["UNCONN"] = "CLOSE";
translate["CLOSE-WAIT"] = "CLOSE_WAIT";
translate["LAST-ACK"] = "LAST_ACK";
translate["LISTEN"] = "LISTEN";
@matthiasr
matthiasr / bisect.sh
Created June 28, 2012 21:00
bisecting curl keepalive problem on DragonFly
#!/bin/sh
echo buildconf
./buildconf 2> /dev/null > /dev/null || exit 125
echo configure
./configure 2> /dev/null > /dev/null || exit 125
echo make
make 2> /dev/null > /dev/null || exit 125
echo Attempting to use the curl we just built ...