summaryrefslogtreecommitdiffhomepage
path: root/runsc/boot
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2018-06-20 13:30:39 -0700
committerShentubot <shentubot@google.com>2018-06-20 13:31:31 -0700
commit4ad7315b6759afa81f492ec119080deb9a224101 (patch)
tree0f1e4c51b199301023f0269855013e020cc54ea2 /runsc/boot
parent5aa7615ec93335a922361728881ab1224a6e9266 (diff)
Add 'runsc debug' command
It prints sandbox stacks to the log to help debug stuckness. I expect that many more options will be added in the future. PiperOrigin-RevId: 201405931 Change-Id: I87e560800cd5a5a7b210dc25a5661363c8c3a16e
Diffstat (limited to 'runsc/boot')
-rw-r--r--runsc/boot/BUILD1
-rw-r--r--runsc/boot/controller.go5
-rw-r--r--runsc/boot/debug.go29
3 files changed, 35 insertions, 0 deletions
diff --git a/runsc/boot/BUILD b/runsc/boot/BUILD
index 8b3b09a22..924cc2b90 100644
--- a/runsc/boot/BUILD
+++ b/runsc/boot/BUILD
@@ -7,6 +7,7 @@ go_library(
srcs = [
"config.go",
"controller.go",
+ "debug.go",
"events.go",
"fds.go",
"fs.go",
diff --git a/runsc/boot/controller.go b/runsc/boot/controller.go
index 1a598199d..ec24c4dad 100644
--- a/runsc/boot/controller.go
+++ b/runsc/boot/controller.go
@@ -68,6 +68,9 @@ const (
// RootContainerStart is the URPC endpoint for starting a new sandbox
// with root container.
RootContainerStart = "containerManager.StartRoot"
+
+ // SandboxStacks collects sandbox stacks for debugging.
+ SandboxStacks = "debug.Stacks"
)
// ControlSocketAddr generates an abstract unix socket name for the given id.
@@ -107,6 +110,8 @@ func newController(fd int, k *kernel.Kernel, w *watchdog.Watchdog) (*controller,
srv.Register(net)
}
+ srv.Register(&debug{})
+
if err := srv.StartServing(); err != nil {
return nil, err
}
diff --git a/runsc/boot/debug.go b/runsc/boot/debug.go
new file mode 100644
index 000000000..971962c91
--- /dev/null
+++ b/runsc/boot/debug.go
@@ -0,0 +1,29 @@
+// Copyright 2018 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package boot
+
+import (
+ "gvisor.googlesource.com/gvisor/pkg/log"
+)
+
+type debug struct {
+}
+
+// Stacks collects all sandbox stacks and copies them to 'stacks'.
+func (*debug) Stacks(_ *struct{}, stacks *string) error {
+ buf := log.Stacks(true)
+ *stacks = string(buf)
+ return nil
+}