Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
CuriousGeorgiy committed Mar 23, 2023
1 parent 85b8022 commit 11d62f1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
3 changes: 2 additions & 1 deletion configs/gvisor-containerd/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ state = "/run/gvisor-containerd"
runtime_type = "io.containerd.runsc.v1"

[debug]
level = "debug"
address = "/run/gvisor-containerd/debug.sock"
level = "trace"
20 changes: 12 additions & 8 deletions cri/gvisor/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ package gvisor
import (
"context"
"fmt"
"github.com/containerd/containerd"
"github.com/containerd/containerd/cio"
"github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/oci"
"github.com/containerd/containerd/remotes/docker"
"github.com/containerd/go-cni"
log "github.com/sirupsen/logrus"
"net"
"net/http"
"net/url"
Expand All @@ -33,14 +40,6 @@ import (
"sync"
"sync/atomic"
"syscall"

"github.com/containerd/containerd"
"github.com/containerd/containerd/cio"
"github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/oci"
"github.com/containerd/containerd/remotes/docker"
"github.com/containerd/go-cni"
log "github.com/sirupsen/logrus"
)

const (
Expand Down Expand Up @@ -88,6 +87,7 @@ func (c *coordinator) startContainer(ctx context.Context, imageName string, envi
ctrID := strconv.Itoa(int(atomic.AddUint64(&c.nextID, 1)))
image, err := c.getImage(ctx, imageName)
if err != nil {
log.Errorf("failed to get container image: %v", err)
return nil, err
}
container, err := c.client.NewContainer(
Expand All @@ -101,6 +101,7 @@ func (c *coordinator) startContainer(ctx context.Context, imageName string, envi
),
)
if err != nil {
log.Errorf("failed to create container: %v", err)
return nil, err
}
defer func() {
Expand All @@ -114,6 +115,7 @@ func (c *coordinator) startContainer(ctx context.Context, imageName string, envi
// create a task from the container
task, err := container.NewTask(ctx, cio.NewCreator(cio.WithStdio))
if err != nil {
log.Errorf("failed to create a task from the container: %v", err)
return nil, err
}
defer func() {
Expand All @@ -126,6 +128,7 @@ func (c *coordinator) startContainer(ctx context.Context, imageName string, envi

exitStatusC, err := task.Wait(ctx)
if err != nil {
log.Errorf("failed to wait for task execution: %v", err)
return nil, err
}

Expand All @@ -146,6 +149,7 @@ func (c *coordinator) startContainer(ctx context.Context, imageName string, envi
ip := result.Interfaces["eth0"].IPConfigs[0].IP.String()

if err := task.Start(ctx); err != nil {
log.Errorf("failed to start task: %v", err)
return nil, err
}
defer func() {
Expand Down
2 changes: 1 addition & 1 deletion vhive.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ func main() {
TimestampFormat: ctrdlog.RFC3339NanoFixed,
FullTimestamp: true,
})
//log.SetReportCaller(true) // FIXME: make sure it's false unless debugging

log.SetOutput(os.Stdout)

if *debug {
log.SetLevel(log.DebugLevel)
log.SetReportCaller(true)
log.Debug("Debug logging is enabled")
} else {
log.SetLevel(log.InfoLevel)
Expand Down

0 comments on commit 11d62f1

Please sign in to comment.