Merge pull request #7943 from samuelkarp/shim-delete-warning
shim: enable debug logging for delete
This commit is contained in:
commit
f82ae8a922
@ -26,6 +26,9 @@ import (
|
|||||||
gruntime "runtime"
|
gruntime "runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containerd/ttrpc"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/containerd/containerd/api/runtime/task/v2"
|
"github.com/containerd/containerd/api/runtime/task/v2"
|
||||||
"github.com/containerd/containerd/log"
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/namespaces"
|
"github.com/containerd/containerd/namespaces"
|
||||||
@ -34,8 +37,6 @@ import (
|
|||||||
"github.com/containerd/containerd/protobuf/types"
|
"github.com/containerd/containerd/protobuf/types"
|
||||||
"github.com/containerd/containerd/runtime"
|
"github.com/containerd/containerd/runtime"
|
||||||
client "github.com/containerd/containerd/runtime/v2/shim"
|
client "github.com/containerd/containerd/runtime/v2/shim"
|
||||||
"github.com/containerd/ttrpc"
|
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type shimBinaryConfig struct {
|
type shimBinaryConfig struct {
|
||||||
@ -153,6 +154,15 @@ func (b *binary) Delete(ctx context.Context) (*runtime.Exit, error) {
|
|||||||
if gruntime.GOOS != "windows" && gruntime.GOOS != "freebsd" {
|
if gruntime.GOOS != "windows" && gruntime.GOOS != "freebsd" {
|
||||||
bundlePath = b.bundle.Path
|
bundlePath = b.bundle.Path
|
||||||
}
|
}
|
||||||
|
args := []string{
|
||||||
|
"-id", b.bundle.ID,
|
||||||
|
"-bundle", b.bundle.Path,
|
||||||
|
}
|
||||||
|
switch logrus.GetLevel() {
|
||||||
|
case logrus.DebugLevel, logrus.TraceLevel:
|
||||||
|
args = append(args, "-debug")
|
||||||
|
}
|
||||||
|
args = append(args, "delete")
|
||||||
|
|
||||||
cmd, err := client.Command(ctx,
|
cmd, err := client.Command(ctx,
|
||||||
&client.CommandConfig{
|
&client.CommandConfig{
|
||||||
@ -161,11 +171,7 @@ func (b *binary) Delete(ctx context.Context) (*runtime.Exit, error) {
|
|||||||
TTRPCAddress: b.containerdTTRPCAddress,
|
TTRPCAddress: b.containerdTTRPCAddress,
|
||||||
Path: bundlePath,
|
Path: bundlePath,
|
||||||
Opts: nil,
|
Opts: nil,
|
||||||
Args: []string{
|
Args: args,
|
||||||
"-id", b.bundle.ID,
|
|
||||||
"-bundle", b.bundle.Path,
|
|
||||||
"delete",
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -312,6 +312,9 @@ func run(ctx context.Context, manager Manager, initFunc Init, name string, confi
|
|||||||
// Handle explicit actions
|
// Handle explicit actions
|
||||||
switch action {
|
switch action {
|
||||||
case "delete":
|
case "delete":
|
||||||
|
if debugFlag {
|
||||||
|
logrus.SetLevel(logrus.DebugLevel)
|
||||||
|
}
|
||||||
logger := log.G(ctx).WithFields(logrus.Fields{
|
logger := log.G(ctx).WithFields(logrus.Fields{
|
||||||
"pid": os.Getpid(),
|
"pid": os.Getpid(),
|
||||||
"namespace": namespaceFlag,
|
"namespace": namespaceFlag,
|
||||||
@ -400,14 +403,14 @@ func run(ctx context.Context, manager Manager, initFunc Init, name string, confi
|
|||||||
initContext.TTRPCAddress = ttrpcAddress
|
initContext.TTRPCAddress = ttrpcAddress
|
||||||
|
|
||||||
// load the plugin specific configuration if it is provided
|
// load the plugin specific configuration if it is provided
|
||||||
//TODO: Read configuration passed into shim, or from state directory?
|
// TODO: Read configuration passed into shim, or from state directory?
|
||||||
//if p.Config != nil {
|
// if p.Config != nil {
|
||||||
// pc, err := config.Decode(p)
|
// pc, err := config.Decode(p)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// return nil, err
|
// return nil, err
|
||||||
// }
|
// }
|
||||||
// initContext.Config = pc
|
// initContext.Config = pc
|
||||||
//}
|
// }
|
||||||
|
|
||||||
result := p.Init(initContext)
|
result := p.Init(initContext)
|
||||||
if err := initialized.Add(result); err != nil {
|
if err := initialized.Add(result); err != nil {
|
||||||
|
@ -71,7 +71,7 @@ func serveListener(path string) (net.Listener, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func reap(ctx context.Context, logger *logrus.Entry, signals chan os.Signal) error {
|
func reap(ctx context.Context, logger *logrus.Entry, signals chan os.Signal) error {
|
||||||
logger.Info("starting signal loop")
|
logger.Debug("starting signal loop")
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
Loading…
Reference in New Issue
Block a user