Skip to content

Instantly share code, notes, and snippets.

View teddyking's full-sized avatar

Ed King teddyking

View GitHub Profile
@teddyking
teddyking / mnt_pids.rb
Created October 4, 2016 08:28
Hacktastic script to print a PID from each mount namespace on a host
mntnses = Dir.glob("/proc/*/ns/mnt")
foundmnts = []
foundpids = []
mntnses.each do |mntns|
actualmntns = `readlink "#{mntns}"`
pid = mntns.split("/")[2]
mntnum = actualmntns.gsub(/mnt:\[/, "").gsub(/\]/, "")
#puts "#{pid} - #{mntnum}"
@teddyking
teddyking / tsgnano.go
Created October 27, 2016 10:30
the-secret-garden-nano - a lightweight version of the secret garden that also runs runc's pivot_root func
package main
import (
"fmt"
"os"
"path/filepath"
"strings"
"syscall"
"time"
@teddyking
teddyking / create.sh
Created October 27, 2016 10:56
AUFS hang on umount of loop device script
#!/bin/bash
set -x -e
WORKSPACE_DIR=~/workspace/4.4-loop-umount-hang-test
# 1. Setup workspace
mkdir -p $WORKSPACE_DIR
mkdir -p $WORKSPACE_DIR/{diff,mnt,layers}
@teddyking
teddyking / cleanup.sh
Created October 27, 2016 10:57
AUFS hang on umount of loop device cleanup script
#!/bin/bash
set -x -e
ps aux | grep namespaced | grep -v grep | awk '{print $2}' | xargs -n1 kill -9 || true
umount /root/workspace/4.4-loop-umount-hang-test/mnt/container-2 || true
umount /root/workspace/4.4-loop-umount-hang-test/diff/container-2 || true
umount /root/workspace/4.4-loop-umount-hang-test/mnt/container-1 || true
@teddyking
teddyking / pprof-guardian.sh
Last active April 12, 2017 07:35
Install go 1.8 and run a pprof againast a local guardian process
cd /usr/local/
wget "https://storage.googleapis.com/golang/go1.8.linux-amd64.tar.gz"
tar -zxf go1.8.linux-amd64.tar.gz
rm go1.8.linux-amd64.tar.gz
cd
mkdir go
cd go
mkdir src pkg bin
cd ../
@teddyking
teddyking / setup-go-dev.sh
Created December 23, 2016 14:57
Setup an ubuntu machine for Go dev
#!/bin/bash
set -e -x
apt-get -y update
apt-get -y install software-properties-common python-pip python3-dev python3-pip
add-apt-repository -y ppa:neovim-ppa/unstable
apt-get -y update
apt-get -y install neovim
Action: func(context *cli.Context) error {
if err := checkArgs(context, 1, exactArgs); err != nil {
return err
}
if err := revisePidFile(context); err != nil {
return err
}
spec, err := setupSpec(context)
if err != nil {
return err
func startContainer(context *cli.Context, spec *specs.Spec, create bool) (int, error) {
id := context.Args().First()
if id == "" {
return -1, errEmptyID
}
container, err := createContainer(context, id, spec)
if err != nil {
return -1, err
}
// Support on-demand socket activation by passing file descriptors into the container init process.
@teddyking
teddyking / iptables-regression-verification.md
Last active April 9, 2017 16:21
iptables regression patch verification

Objective

In this gist, we verified that the iptables regression patches improved performance for both direct iptables executions and for garden NetOut API calls.

In this gist, we attempt to verify that the performance improvements are still seen for the Release Candidate 4.4.0-63.84~14.04.1.

iptables rule addition

@teddyking
teddyking / config.json
Created February 24, 2017 07:56
config.json generated via `runc spec --rootless`
{
"ociVersion": "1.0.0-rc3",
"platform": {
"os": "linux",
"arch": "amd64"
},
"process": {
"terminal": false,
"consoleSize": {
"height": 0,