Skip to content

Instantly share code, notes, and snippets.

@michaelgugino
michaelgugino / evict-code-cov.html
Created October 20, 2020 15:38
evict-code-cov
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>storage: Go Coverage Report</title>
<style>
body {
background: black;
color: rgb(80, 80, 80);
@michaelgugino
michaelgugino / gist:e742b83d3950c6cdbfaa25fe262a86bf
Last active October 6, 2020 00:09
fedora-cloud-launch-gce-cli
Created google-fedora-metadata-keys following instructions here: https://wiki.ubuntu.com/GoogleComputeEngineSSHKeys
I used 'fedora', 'cloudinit', and 'root' as usernames there, most likely just 'fedora' would be required/needed.
Converted qcow2 image to raw using qemu-img convert command, followed instructions here to import into GCE appropriately: https://major.io/2019/08/07/fedora-30-on-google-compute-engine/
Create instance (you probably don't need to specify all these options, this was copied from the web interface for convenience)
gcloud beta compute \
--project=<redacted> instances create mgugino-fedora-33-test3 \
--zone=us-east1-c --machine-type=e2-medium \
[myuser machine-api-operator]$ go test ./pkg/apis/machine/v1beta1/
panic: test timed out after 10m0s
goroutine 6194 [running]:
testing.(*M).startAlarm.func1()
/home/myuser/go_dists/go-1.13.7/src/testing/testing.go:1377 +0xdf
created by time.goFunc
/home/myuser/go_dists/go-1.13.7/src/time/sleep.go:168 +0x44
goroutine 1 [chan receive, 9 minutes]:
=== RUN TestStorageMachine
--- PASS: TestStorageMachine (0.04s)
=== RUN TestRoundTripMachine
--- PASS: TestRoundTripMachine (0.86s)
=== RUN TestMachineCreation
=== RUN TestMachineCreation/with_AWS_and_a_nil_provider_spec_value
Starting runnable 986112c5-fa99-4a4d-8a9e-9c37034185f3
=== RUN TestMachineCreation/with_AWS_and_no_fields_set
finished runnable 986112c5-fa99-4a4d-8a9e-9c37034185f3
Starting runnable 18caa06b-9bd6-468a-9332-10a70c6bbcc6
==================
WARNING: DATA RACE
Read at 0x00c000599ef0 by goroutine 68:
runtime.mapiterinit()
/home/mgugino/go_dists/go-1.13.7/src/runtime/map.go:802 +0x0
sigs.k8s.io/controller-runtime/pkg/webhook.(*Server).Start()
/home/mgugino/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.6.0/pkg/webhook/server.go:145 +0x174
sigs.k8s.io/controller-runtime/pkg/manager.(*controllerManager).Add.func1()
/home/mgugino/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.6.0/pkg/manager/internal.go:235 +0x74
[myuser machine-api-operator]$ go test -race -gcflags '-N -l' ./pkg/apis/machine/v1beta1/
==================
WARNING: DATA RACE
Read at 0x00c00070e210 by goroutine 62:
runtime.mapiterinit()
/home/myuser/go_dists/go-1.13.7/src/runtime/map.go:802 +0x0
sigs.k8s.io/controller-runtime/pkg/webhook.(*Server).Start()
/home/myuser/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.6.0/pkg/webhook/server.go:145 +0x174
sigs.k8s.io/controller-runtime/pkg/manager.(*controllerManager).Add.func1()
/home/myuser/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.6.0/pkg/manager/internal.go:235 +0x74
--- FAIL: TestCPMachineSetDelete (0.06s)
--- FAIL: TestCPMachineSetDelete/is_not_CP_MachineSet (0.01s)
machineset_webhook_test.go:694:
Expected success, but got an error:
<*errors.StatusError | 0xc000922280>: {
ErrStatus: {
TypeMeta: {Kind: "", APIVersion: ""},
ListMeta: {
SelfLink: "",
ResourceVersion: "",
$ go test ./pkg/apis/machine/v1beta1/
2020/06/17 23:57:58 Defaulting fields for MachineSet foo
2020/06/17 23:57:58 Defaulting to Random
--- FAIL: TestMachineSetUpdate (0.28s)
--- FAIL: TestMachineSetUpdate/with_a_valid_Azure_ProviderSpec (0.01s)
machineset_webhook_test.go:590:
Unexpected error:
<*errors.StatusError | 0xc0000f66e0>: {
ErrStatus: {
TypeMeta: {Kind: "", APIVersion: ""},
@michaelgugino
michaelgugino / all-objects.sh
Created June 11, 2020 17:45
dumping all your k8s objects
./kubectl get --raw / | jq '.paths | map(select(. | test("/v1")))[]' | \
sed -e 's/^"//' -e 's/"$//' | parallel -a - --jobs 20 --tag './apigetter.sh {= $args[0] =} 2> /dev/null' | \
sed 's/\s/\//g' | parallel -a - --jobs 20 ./oc get --raw | \
jq '.items[] | .metadata.selfLink+":"+.metadata.resourceVersion' | sort > allobjects.out
# apigetter.sh
#!/usr/bin/env bash
./oc get --raw $1 | jq '.resources | map(select(.name | test("^\\w*$")))[].name' | sed -e 's/^"//' -e 's/"$//'
import os
import sys
import pytest
try:
# python3, mock is built in.
from unittest.mock import patch
except ImportError:
# In python2, mock is installed via pip.