Skip to content

Instantly share code, notes, and snippets.

View ncdc's full-sized avatar

Andy Goldstein ncdc

View GitHub Profile
@ncdc
ncdc / ast.go
Created November 9, 2016 20:50
golang ast parsing to extract a variable's value
package main
import (
"fmt"
"go/ast"
"go/parser"
"go/token"
)
func main() {
@ncdc
ncdc / stack.txt
Created June 9, 2022 19:54
2 kcp admission inits
# First trace
│I0609 15:50:57.523552 62573 server.go:342] Finished start kube informers │
│E0609 15:50:57.538166 62573 kubequota_admission.go:137] ANDY │
│goroutine 2465 [running]: │
│runtime/debug.Stack() │
│ /usr/local/Cellar/go/1
@ncdc
ncdc / main.go
Created August 11, 2017 14:50
Simple Kubernetes client-go example code
package main
import (
"flag"
"fmt"
"os"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
@ncdc
ncdc / kcp.log
Created January 26, 2022 15:36
kcp ingress source log file - e2e test run
I0126 10:33:12.395799 96588 etcd.go:57] Creating embedded etcd server
{"level":"warn","ts":1643211193.659682,"caller":"fileutil/fileutil.go:57","msg":"check file permission","error":"directory \"/Users/angoldst/go/src/github.com/kcp-dev/kcp/testout/TestIngressController/create_an_ingress_that_points_to_a_valid_service_and_expect_the_Ingress_to_be_scheduled_to_the_same_cluster/2345490025/data/kcp/source\" exist, but the permission is \"drwxr-xr-x\". The recommended permission is \"-rwx------\" to prevent possible unprivileged access to the data"}
{"level":"warn","ts":"2022-01-26T10:33:16.624-0500","caller":"etcdserver/metrics.go:224","msg":"failed to get file descriptor usage","error":"cannot get FDUsage on darwin"}
{"level":"warn","ts":"2022-01-26T10:33:18.036-0500","caller":"etcdserver/util.go:166","msg":"apply request took too long","took":"265.457663ms","expected-duration":"100ms","prefix":"","request":"ID:4097570423066461443 Method:\"PUT\" Path:\"/0/version\" Val:\"3.5.0\" ","response":""}
{"level":"war
@ncdc
ncdc / test.log
Created January 26, 2022 15:30
Output from kcp e2e tests on a 2019 16" MacBook Pro 2.6 GHz 6-Core Intel Core i7 32GB RAM
--- FAIL: TestAPIInheritance (0.00s)
--- FAIL: TestAPIInheritance/Basic_workspace_API_inheritance (70.00s)
util.go:85: Saving test artifacts and data under /var/folders/hf/d3p2y6v55zq4_q709t06cj4w0000gn/T/TestAPIInheritanceBasic_workspace_API_inheritance2907862924/001/TestAPIInheritance/Basic_workspace_API_inheritance/758656762.
test.go:105: Starting kcp servers...
kcp.go:137: running: kcp start --root-directory /var/folders/hf/d3p2y6v55zq4_q709t06cj4w0000gn/T/TestAPIInheritanceBasic_workspace_API_inheritance2907862924/001/TestAPIInheritance/Basic_workspace_API_inheritance/758656762/data/kcp/main --listen=:60446 --etcd-client-port=60447 --etcd-peer-port=60448 --etcd-wal-size-bytes=5000 --kubeconfig-path=admin.kubeconfig --install-workspace-controller
test.go:137: error contacting /livez: Get "https://[::1]:60446/livez": context deadline exceeded
test.go:137: error contacting /readyz: Get "https://[::1]:60446/readyz": context deadline exceeded
kcp.go:132: cle
$ cat workspace-source.yaml
apiVersion: tenancy.kcp.dev/v1alpha1
kind: Workspace
metadata:
name: source
spec:
shard: abc
$ cat workspace-target.yaml
apiVersion: tenancy.kcp.dev/v1alpha1
goroutine profile: total 9
1 @ 0x1032fde 0x10668c8 0x10ee219 0x106a9c1
# 0x10668c7 os/signal.signal_recv+0x27 /usr/local/Cellar/go/1.17.2/libexec/src/runtime/sigqueue.go:166
# 0x10ee218 os/signal.loop+0x18 /usr/local/Cellar/go/1.17.2/libexec/src/os/signal/signal_unix.go:24
1 @ 0x1039856 0x1007a8c 0x10074f8 0x1a1064a 0x106a9c1
# 0x1a10649 k8s.io/klog.(*loggingT).flushDaemon+0x69 /Users/angoldst/go/pkg/mod/k8s.io/klog@v1.0.0/klog.go:1010
1 @ 0x1039856 0x1007a8c 0x10074f8 0x1a66fea 0x106a9c1
# 0x1a66fe9 k8s.io/klog/v2.(*loggingT).flushDaemon+0x69 /Users/angoldst/go/pkg/mod/k8s.io/klog/v2@v2.9.0/klog.go:1169
[
{
"local": "0.0.0.0:58093",
"remote": "192.168.127.2:58093",
"protocol": "tcp"
},
{
"local": ":55834",
"remote": "192.168.127.2:22",
"protocol": "tcp"
@ncdc
ncdc / main_test.go
Last active November 4, 2021 18:09
Go map benchmarks - string vs struct keys
package mapbenchmark
import (
"math/rand"
"strconv"
"testing"
)
type structKey struct {
one string
$ rsync -a -vvvv -e 'kubectl exec -i pod -- /wrap' _output/local/go/bin/kubectl ignored:/data
cmd=kubectl exec -i pod -- /wrap machine=ignored user=<NULL> path=/data
cmd[0]=kubectl cmd[1]=exec cmd[2]=-i cmd[3]=pod cmd[4]=-- cmd[5]=/wrap cmd[6]=ignored cmd[7]=rsync cmd[8]=--server cmd[9]=-vvvvlogDtpre.iLsfx cmd[10]=. cmd[11]=/data
opening connection using: kubectl exec -i pod -- /wrap ignored rsync --server -vvvvlogDtpre.iLsfx . /data (12 args)