Add support for stracing containers
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
parent
d0e0303921
commit
effe1c4281
3 changed files with 28 additions and 0 deletions
|
@ -83,6 +83,7 @@ For sync communication we have an IRC channel #CRI-O, on chat.freenode.net, that
|
|||
- socat
|
||||
- iproute
|
||||
- iptables
|
||||
- strace (required for debugging using cri-o strace annotation)
|
||||
|
||||
Latest version of `runc` is expected to be installed on the system. It is picked up as the default runtime by CRI-O.
|
||||
|
||||
|
|
24
oci/oci.go
24
oci/oci.go
|
@ -14,6 +14,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/containerd/cgroups"
|
||||
"github.com/kubernetes-incubator/cri-o/pkg/annotations"
|
||||
"github.com/kubernetes-incubator/cri-o/utils"
|
||||
rspec "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
@ -284,6 +285,7 @@ func (r *Runtime) CreateContainer(c *Container, cgroupParent string) (err error)
|
|||
if ss.err != nil {
|
||||
return fmt.Errorf("error reading container (probably exited) json message: %v", ss.err)
|
||||
}
|
||||
c.state.Pid = ss.si.Pid
|
||||
logrus.Debugf("Received container pid: %d", ss.si.Pid)
|
||||
if ss.si.Pid == -1 {
|
||||
if ss.si.Message != "" {
|
||||
|
@ -297,6 +299,28 @@ func (r *Runtime) CreateContainer(c *Container, cgroupParent string) (err error)
|
|||
logrus.Errorf("Container creation timeout (%v)", ContainerCreateTimeout)
|
||||
return fmt.Errorf("create container timeout")
|
||||
}
|
||||
|
||||
enableStrace := false
|
||||
if _, ok := c.annotations[annotations.Strace]; ok {
|
||||
logrus.Debugf("Enabling strace from annotation")
|
||||
enableStrace = true
|
||||
}
|
||||
if !enableStrace {
|
||||
if _, ok := c.labels[annotations.Strace]; ok {
|
||||
logrus.Debugf("Enabling strace from label")
|
||||
enableStrace = true
|
||||
}
|
||||
}
|
||||
|
||||
if enableStrace {
|
||||
go func() {
|
||||
straceCmd := exec.Command("strace", "-f", "-o", fmt.Sprintf("/tmp/%v", c.id), "-p", fmt.Sprintf("%d", c.state.Pid))
|
||||
_, err := straceCmd.CombinedOutput()
|
||||
if err != nil {
|
||||
logrus.Errorf("Failed to execute strace: %v", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -84,6 +84,9 @@ const (
|
|||
|
||||
// Volumes is the volumes annotatoin
|
||||
Volumes = "io.kubernetes.cri-o.Volumes"
|
||||
|
||||
// Strace is enable strace debug annotation.
|
||||
Strace = "io.kubernetes.cri-o.Strace"
|
||||
)
|
||||
|
||||
// ContainerType values
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue