Skip to content

Instantly share code, notes, and snippets.

View roycaihw's full-sized avatar

Haowei Cai (Roy) roycaihw

View GitHub Profile
import sys
from kubernetes import client, config, watch
def main():
config.load_kube_config()
v1 = client.ApiextensionsV1Api()
w = watch.Watch()
for event in w.stream(v1.list_custom_resource_definition, resource_version=sys.argv[1]):
2021/02/16 16:29:56 [INFO] Terraform version: 0.12.28
2021/02/16 16:29:56 [INFO] Go runtime version: go1.12.13
2021/02/16 16:29:56 [INFO] CLI args: []string{"/usr/local/bin/terraform", "destroy"}
2021/02/16 16:29:56 [DEBUG] Attempting to open CLI config file: /usr/local/google/home/haoweic/.terraformrc
2021/02/16 16:29:56 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2021/02/16 16:29:56 [INFO] CLI command args: []string{"destroy"}
2021/02/16 16:29:56 [WARN] Log levels other than TRACE are currently unreliable, and are supported only for backward compatibility.
Use TF_LOG=TRACE to see Terraform's internal logs.
----
2021/02/16 16:29:56 [DEBUG] New state was assigned lineage "f5de0428-c61c-26e8-5712-36081165bc7f"
@roycaihw
roycaihw / main.go
Created October 30, 2020 22:36
append duplicate owner references
package main
import (
"context"
"flag"
"fmt"
"path/filepath"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@roycaihw
roycaihw / log
Last active October 8, 2020 21:28
IdleConnTimeout behavior difference
# run the server and client, see the connection is established and idle
$ go run main.go
add to idle
# wait 5s, in another terminal
# without IdleConnTimeout
$ netstat -an | grep 8080
tcp6 0 0 :::8080 :::* LISTEN
tcp6 0 0 ::1:8080 ::1:34246 ESTABLISHED
@roycaihw
roycaihw / log5-server-2.txt
Created January 7, 2020 22:19
server side: kube-aggregator openapi controller and apiextensions-apiserver openapi controller
I0107 19:34:21.894] [It] works for multiple CRDs of same group and version but different kinds [Conformance]
I0107 19:34:21.895] E0107 19:33:35.230889 12195 crd_publish_openapi.go:612] ----- checking
I0107 19:34:21.895] E0107 19:33:36.986000 12195 crd_publish_openapi.go:637] ----- spec changed
I0107 19:34:21.895] E0107 19:33:37.230794 12195 crd_publish_openapi.go:612] ----- checking
I0107 19:34:21.895] E0107 19:33:37.730833 12195 crd_publish_openapi.go:612] ----- checking
I0107 19:34:21.895] E0107 19:33:38.230694 12195 crd_publish_openapi.go:612] ----- checking
I0107 19:34:21.895] E0107 19:33:38.730736 12195 crd_publish_openapi.go:612] ----- checking
I0107 19:34:21.895] E0107 19:33:39.230678 12195 crd_publish_openapi.go:612] ----- checking
I0107 19:34:21.896] E0107 19:33:40.591085 12195 crd_publish_openapi.go:637] ----- spec changed
I0107 19:34:21.896] E0107 19:33:40.591469 12195 crd_publish_openapi.go:645] ----- succeeded
@roycaihw
roycaihw / log4.txt
Last active January 7, 2020 17:41
most verbose measure for waitForOpenAPISchema, waitForDefinition and waitForDefinitionCleanup
I0107 03:40:26.536] [It] updates the published spec when one version gets renamed [Conformance]
I0107 03:40:26.536] E0107 03:39:33.491514 11698 crd_publish_openapi.go:612] ----- checking
I0107 03:40:26.536] E0107 03:39:34.788702 11698 crd_publish_openapi.go:637] ----- spec changed
I0107 03:40:26.536] E0107 03:39:34.991467 11698 crd_publish_openapi.go:612] ----- checking
I0107 03:40:26.537] E0107 03:39:35.491489 11698 crd_publish_openapi.go:612] ----- checking
I0107 03:40:26.537] E0107 03:39:35.991472 11698 crd_publish_openapi.go:612] ----- checking
I0107 03:40:26.537] E0107 03:39:36.491503 11698 crd_publish_openapi.go:612] ----- checking
I0107 03:40:26.537] E0107 03:39:36.991484 11698 crd_publish_openapi.go:612] ----- checking
I0107 03:40:26.537] E0107 03:39:37.491465 11698 crd_publish_openapi.go:612] ----- checking
I0107 03:40:26.538] E0107 03:39:37.991455 11698 crd_publish_openapi.go:612] ----- checking
@roycaihw
roycaihw / log1.txt
Last active January 7, 2020 17:40
more verbose measure for waitForDefinition and waitForOpenAPISchema
I1224 00:43:47.601] [It] works for multiple CRDs of same group but different versions [Conformance]
I1224 00:43:47.609] E1224 00:42:18.499271 11821 crd_publish_openapi.go:609] ----- checking
I1224 00:43:47.609] E1224 00:42:21.506865 11821 crd_publish_openapi.go:609] ----- checking
I1224 00:43:47.609] E1224 00:42:21.981018 11821 crd_publish_openapi.go:609] ----- checking
I1224 00:43:47.610] E1224 00:42:22.510073 11821 crd_publish_openapi.go:609] ----- checking
I1224 00:43:47.612] E1224 00:42:26.967073 11821 crd_publish_openapi.go:641] ----- succeeded
I1224 00:43:47.613] E1224 00:42:26.967113 11821 crd_publish_openapi.go:609] ----- checking
I1224 00:43:47.616] E1224 00:42:27.268286 11821 crd_publish_openapi.go:641] ----- succeeded
I1224 00:43:47.616] E1224 00:42:27.268319 11821 crd_publish_openapi.go:609] ----- checking
I1224 00:43:47.617] E1224 00:42:27.374979 11821 crd_publish_openapi.go:641] ----- succeeded
@roycaihw
roycaihw / build-log-1
Last active January 7, 2020 17:39
time elapsed in waitForDefinition
haoweic@haoweic-macbookpro2:~$ grep "works for CRD with validation schema\|works for CRD without validation schema\|works for CRD preserving unknown fields at the schema root\|works for CRD preserving unknown fields in an embedded object\|works for multiple CRDs of different groups\|works for multiple CRDs of same group but different versions\|works for multiple CRDs of same group and version but different kinds\|updates the published spec when one version gets \|removes definition from spec when one version gets changed to not be served\|\-\-\- time" ~/Desktop/build-log.txt | grep -v "PASSED\|\] "
I1224 01:40:05.476] [It] works for multiple CRDs of different groups [Conformance]
I1224 01:40:05.480] E1224 01:39:06.687062 11743 crd_publish_openapi.go:584] --- time elapsed: 6.515549888s
I1224 01:40:05.485] E1224 01:39:22.163486 11743 crd_publish_openapi.go:584] --- time elapsed: 14.139480523s
I1224 01:40:05.487] E1224 01:39:25.116224 11743 crd_publish_openapi.go:584] --- time elapsed: 2.95247433s
I1224
@roycaihw
roycaihw / decode-yaml.go
Created October 2, 2019 20:53
Parsing yaml into Kubernetes object with client-go kubernetes/client-go#193
package main
import (
"fmt"
v1 "k8s.io/api/apps/v1"
"k8s.io/client-go/kubernetes/scheme"
)
var yml = `
@roycaihw
roycaihw / CRD openapi spec update latency.log
Last active July 16, 2019 03:01
CRD openapi spec update latency
First column: typed client creation timestamp (e.g. Jul 15 13:36:38.229: INFO: >>> kubeConfig:)
Second column: elapsed time (in seconds) since last creation = `setupCRDAndVerifySchema` = (some constant + waiting time for schema publishing)
Source code: https://github.com/roycaihw/kubernetes/commit/a4e62ea07e34193d2032eedde8a5d732be493219
Notes: only running the experiment e2e test above
Command: kubetest --build --up --test --test_args="--ginkgo.focus=when\sthere\sare\slots\sof\sCRDs"
Env: default kubetest-- GCP n1-standard-1 (1 vCPU, 3.75 GB memory)
13:36:38
13:36:42 0:00:03