Skip to content

Instantly share code, notes, and snippets.

View ihcsim's full-sized avatar

Ivan Sim ihcsim

  • SUSE
  • BC, Canada
  • 21:41 (UTC -08:00)
View GitHub Profile
// create streaming server if configured.
if streamingConfig != nil {
var err error
ds.streamingServer, err = streaming.NewServer(*streamingConfig, ds.streamingRuntime)
if err != nil {
return nil, err
}
}
@ihcsim
ihcsim / server.go
Last active February 4, 2020 06:17
func (s *server) GetExec(req *runtimeapi.ExecRequest) (*runtimeapi.ExecResponse, error) {
if err := validateExecRequest(req); err != nil {
return nil, err
}
token, err := s.cache.Insert(req)
if err != nil {
return nil, err
}
return &runtimeapi.ExecResponse{
Url: s.buildURL("exec", token),
ds := &dockerService{
// ...
streamingRuntime: &streamingRuntime{
client: client,
execHandler: &NativeExecHandler{},
},
// ...
}
@ihcsim
ihcsim / exec.go
Last active February 4, 2020 06:19
func (*NativeExecHandler) ExecInContainer(client libdocker.Interface, container *dockertypes.ContainerJSON, cmd []string, stdin io.Reader, stdout, stderr io.WriteCloser, tty bool, resize <-chan remotecommand.TerminalSize, timeout time.Duration) error {
// ...
startOpts := dockertypes.ExecStartCheck{Detach: false, Tty: tty}
streamOpts := libdocker.StreamOptions{
InputStream: stdin,
OutputStream: stdout,
ErrorStream: stderr,
RawTerminal: tty,
ExecStarted: execStarted,
}
@ihcsim
ihcsim / server.go
Last active February 4, 2020 06:19
ws := &restful.WebService{}
endpoints := []struct {
path string
handler restful.RouteFunction
}{
{"/exec/{token}", s.serveExec},
{"/attach/{token}", s.serveAttach},
{"/portforward/{token}", s.servePortForward},
}
@ihcsim
ihcsim / exec.go
Last active February 4, 2020 06:20
// ServeExec handles requests to execute a command in a container. After
// creating/receiving the required streams, it delegates the actual execution
// to the executor.
func ServeExec(w http.ResponseWriter, req *http.Request, executor Executor, podName string, uid types.UID, container string, cmd []string, streamOpts *Options, idleTimeout, streamCreationTimeout time.Duration, supportedProtocols []string) {
// ...
err := executor.ExecInContainer(podName, uid, container, cmd, ctx.stdinStream, ctx.stdoutStream, ctx.stderrStream, ctx.tty, ctx.resizeChan, 0)
if err != nil {
// ...
} else {
// ...
@ihcsim
ihcsim / cmd.sh
Last active February 13, 2020 22:26
# the exact promql queries can be found in the stat-promql.sh below
# need to add direction="inbound" label to the smi-metrics queries.
$ linkerd -n <ns> stat <kind>
$ linkerd -n <ns> stat <kind> <workload_name>...
# need to add direction="outbound" label to the smi-metrics queries.
# currently, the value of <dst_ns> isn't used in the promql of `linkerd stats`.
# data is grouped by namespace and kind, instead of dst_namespace and dst_<kind>. Is this correct?
$ linkerd -n <ns> stat <kind> --to-namespace <dst_ns>
@ihcsim
ihcsim / chart.diff
Last active February 21, 2020 21:24
```diff
diff --git a/cli/cmd/install.go b/cli/cmd/install.go
index a508760e..b7d4cfef 100644
--- a/cli/cmd/install.go
+++ b/cli/cmd/install.go
@@ -151,11 +151,6 @@ var (
"templates/tap.yaml",
"templates/linkerd-values.yaml",
}
-
@ihcsim
ihcsim / addon.diff
Last active February 25, 2020 05:35
diff --git a/charts/linkerd2/values.yaml b/charts/linkerd2/values.yaml
index e21c8997..7ba88ee9 100644
--- a/charts/linkerd2/values.yaml
+++ b/charts/linkerd2/values.yaml
@@ -172,7 +172,7 @@ nodeSelector:
# Configuration for Add-ons
tracing:
- enabled: false
+ enabled: true
@ihcsim
ihcsim / profiling-after.log
Created March 5, 2020 23:16
Profiling the resolver.preloadServices() method
time="2020-03-05T05:01:03Z" level=info msg="running version "
time="2020-03-05T05:01:03Z" level=info msg="trying to connect to dive@aks-dive-staging:TykQrnVh4ZRrxNqBCpE5AP0g1j76hISdPYtvV5Ia@tcp(aks-dive-staging.mysql.database.azure.com:3306)/dive_staging?parseTime=true&charset=utf8mb4&collation=utf8mb4_unicode_ci&tls=true"
time="2020-03-05T05:01:03Z" level=warning msg="could not connect to dive@aks-dive-staging:TykQrnVh4ZRrxNqBCpE5AP0g1j76hISdPYtvV5Ia@tcp(aks-dive-staging.mysql.database.azure.com:3306)/dive_staging?parseTime=true&charset=utf8mb4&collation=utf8mb4_unicode_ci&tls=true; retrying in 10s"
time="2020-03-05T05:01:13Z" level=info msg="connected to database at dive@aks-dive-staging:TykQrnVh4ZRrxNqBCpE5AP0g1j76hISdPYtvV5Ia@tcp(aks-dive-staging.mysql.database.azure.com:3306)/dive_staging?parseTime=true&charset=utf8mb4&collation=utf8mb4_unicode_ci&tls=true"
time="2020-03-05T05:01:13Z" level=info msg="starting admin server on :9994"
time="2020-03-05T05:01:13Z" level=info msg="starting HTTP server on :8084