Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Michael Grosser grosser

🎯
Focusing
View GitHub Profile
View etcd_compact.sh
#!/bin/bash -e
# Kubernetes api server is supposed to run compaction on etcd
# when that does not happen we need to do an emergency compaction to make etcd not lock up
# this should only be done once, so we pick the leader to do it, which we assume is healthy
# (compacting manually outside of api server can lead to watches failing / requests for specific revisions failing etc)
#
# After compacting the keyspace, the backend database may exhibit internal fragmentation.
# Any internal fragmentation is space that is free to use by the backend but still consumes storage space.
# The process of defragmentation releases this storage space back to the file system.
@grosser
grosser / slow.rego
Created Jan 1, 2020
opa test is slow
View slow.rego
package k8srequiredlabels
violation[{"msg": msg, "details": {"missing_labels": missing}}] {
provided := {label | input.review.object.metadata.labels[label]}
required := {label | label := input.parameters.labels[_]}
missing := required - provided
count(missing) > 0
msg := sprintf("opa-gatekeeper: you must provide labels %v for %v %v/%v", [missing, input.review.object.kind, input.review.object.metadata.namespace, input.review.object.metadata.name])
}
View kubeclient_vs_faraday.rb
ruby test.rb internaltools.k8s.local
Warming up --------------------------------------
kubeclient os 1.000 i/100ms
kubeclient json 1.000 i/100ms
faraday json 1.000 i/100ms
faraday persistent 1.000 i/100ms
Calculating -------------------------------------
kubeclient os 1.896 (± 0.0%) i/s - 10.000 in 5.275373s
kubeclient json 1.907 (± 0.0%) i/s - 10.000 in 5.248037s
faraday json 1.933 (± 0.0%) i/s - 10.000 in 5.175768s
@grosser
grosser / build.rb
Last active Apr 16, 2018
Building single/partial steps from cloudbuild.yaml
View build.rb
remote = ARGV.delete("--remote")
id = ARGV.pop
abort "Usage: ruby build.rb <id|all> [--remote]" unless ARGV.empty?
unless system('which container-builder-local')
abort "Run: gcloud components install container-builder-local"
end
def dependencies(steps, id)
View test.rb
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
gem "activerecord"
View keybase.md

Keybase proof

I hereby claim:

  • I am grosser on github.
  • I am grosser (https://keybase.io/grosser) on keybase.
  • I have a public key whose fingerprint is 4435 57FE 9ACF 3D5D 4244 CF05 772C BEFC F3BF D2E5

To claim this, I am signing this object:

@grosser
grosser / travis_failures.rb
Last active Aug 29, 2015
Analyze travis failures from forking_test_runner across all jobs in the build
View travis_failures.rb
#!/usr/bin/env ruby
#
# show travis build failures for given build id/url, branch or current branch
# streams logs and shows errors as they happen
#
def usage
puts <<-TEXT.gsub(/^ /, "")
Setup
-----
@grosser
grosser / Post.md
Last active Aug 29, 2015
Updating rails versions while keeping the business running
View Post.md

Updating rails versions on big apps can be dangerous and time consuming. This is the workflow we use to deploy and test our Rails upgrades in isolation, before releasing them to everybody and without blocking other changes.

Gemfile

ln -s Gemfile Gemfile.rails4 and use BUNDLE_GEMFILE=Gemfile.rails4 bundle exec rails c to run rails 4.

if ENV['BUNDLE_GEMFILE'].to_s.include?('rails4')
  gem "rails", "4.0.13"
@grosser
grosser / Gemfile
Created Mar 15, 2015
Rubymine ex with bundle
View Gemfile
source "https://rubygems.org"
gem "parallel"
@grosser
grosser / rails_2_hacks.rb
Created Jan 14, 2014
hacks that help getting a rails 2 app run like a rails 3 app
View rails_2_hacks.rb
# test
if Rails::VERSION::MAJOR == 2
# make integration tests use rack response, so we can test our middlewares
# and not only the pure controller response
ActionController::Base.class_eval do
# this is usually done just-in-time by #process but we need to do it earlier
include ActionController::Integration::ControllerCapture
# then we hide last_instantiation from #process