Merge pull request #612 from runcom/fixies-profiling

Fixies profiling + conflict run pod sandbox
This commit is contained in:
Mrunal Patel 2017-06-18 22:07:47 -07:00 committed by GitHub
commit 0413088ffb
2 changed files with 12 additions and 12 deletions

View file

@ -3,14 +3,14 @@ package main
import ( import (
"fmt" "fmt"
"net" "net"
"net/http"
_ "net/http/pprof"
"os" "os"
"os/signal" "os/signal"
"sort" "sort"
"strings" "strings"
"syscall" "syscall"
"runtime/pprof"
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/containers/storage/pkg/reexec" "github.com/containers/storage/pkg/reexec"
"github.com/kubernetes-incubator/cri-o/server" "github.com/kubernetes-incubator/cri-o/server"
@ -233,9 +233,9 @@ func main() {
Name: "cni-plugin-dir", Name: "cni-plugin-dir",
Usage: "CNI plugin binaries directory", Usage: "CNI plugin binaries directory",
}, },
cli.StringFlag{ cli.BoolFlag{
Name: "cpu-profile", Name: "profile",
Usage: "set the CPU profile file path", Usage: "enable pprof remote profiler on localhost:6060",
}, },
} }
@ -285,13 +285,10 @@ func main() {
} }
app.Action = func(c *cli.Context) error { app.Action = func(c *cli.Context) error {
if cp := c.GlobalString("cpu-profile"); cp != "" { if c.GlobalBool("profile") {
f, err := os.Create(cp) go func() {
if err != nil { http.ListenAndServe("localhost:6060", nil)
return fmt.Errorf("invalid --cpu-profile value %q", err) }()
}
_ = pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
} }
config := c.App.Metadata["config"].(*server.Config) config := c.App.Metadata["config"].(*server.Config)

View file

@ -109,6 +109,9 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest
return nil, err return nil, err
} }
dupID := matches[1] dupID := matches[1]
if _, err := s.StopPodSandbox(ctx, &pb.StopPodSandboxRequest{PodSandboxId: dupID}); err != nil {
return nil, err
}
if _, err := s.RemovePodSandbox(ctx, &pb.RemovePodSandboxRequest{PodSandboxId: dupID}); err != nil { if _, err := s.RemovePodSandbox(ctx, &pb.RemovePodSandboxRequest{PodSandboxId: dupID}); err != nil {
return nil, err return nil, err
} }