
With this change, we integrate all the plugin changes into the introspection service. All plugins can be listed with the following command: ```console $ ctr plugins TYPE ID PLATFORM STATUS io.containerd.content.v1 content - ok io.containerd.metadata.v1 bolt - ok io.containerd.differ.v1 walking linux/amd64 ok io.containerd.grpc.v1 containers - ok io.containerd.grpc.v1 content - ok io.containerd.grpc.v1 diff - ok io.containerd.grpc.v1 events - ok io.containerd.grpc.v1 healthcheck - ok io.containerd.grpc.v1 images - ok io.containerd.grpc.v1 namespaces - ok io.containerd.snapshotter.v1 btrfs linux/amd64 error io.containerd.snapshotter.v1 overlayfs linux/amd64 ok io.containerd.grpc.v1 snapshots - ok io.containerd.monitor.v1 cgroups linux/amd64 ok io.containerd.runtime.v1 linux linux/amd64 ok io.containerd.grpc.v1 tasks - ok io.containerd.grpc.v1 version - ok ``` There are few things to note about this output. The first is that it is printed in the order in which plugins are initialized. This useful for debugging plugin initialization problems. Also note that even though the introspection GPRC api is a itself a plugin, it is not listed. This is because the plugin takes a snapshot of the initialization state at the end of the plugin init process. This allows us to see errors from each plugin, as they happen. If it is required to introspect the existence of the introspection service, we can make modifications to include it in the future. The last thing to note is that the btrfs plugin is in an error state. This is a common state for containerd because even though we load the plugin, most installations aren't on top of btrfs and the plugin cannot be used. We can actually view this error using the detailed view with a filter: ```console $ ctr plugins --detailed id==btrfs Type: io.containerd.snapshotter.v1 ID: btrfs Platforms: linux/amd64 Exports: root /var/lib/containerd/io.containerd.snapshotter.v1.btrfs Error: Code: Unknown Message: path /var/lib/containerd/io.containerd.snapshotter.v1.btrfs must be a btrfs filesystem to be used with the btrfs snapshotter ``` Along with several other values, this is a valuable tool for evaluating the state of components in containerd. Signed-off-by: Stephen J Day <stephen.day@docker.com>
97 lines
1.9 KiB
Go
97 lines
1.9 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"log"
|
|
"os"
|
|
|
|
"github.com/containerd/containerd/namespaces"
|
|
"github.com/containerd/containerd/server"
|
|
"github.com/containerd/containerd/version"
|
|
"github.com/sirupsen/logrus"
|
|
"github.com/urfave/cli"
|
|
"google.golang.org/grpc/grpclog"
|
|
)
|
|
|
|
var extraCmds = []cli.Command{}
|
|
|
|
func init() {
|
|
// Discard grpc logs so that they don't mess with our stdio
|
|
grpclog.SetLogger(log.New(ioutil.Discard, "", log.LstdFlags))
|
|
|
|
cli.VersionPrinter = func(c *cli.Context) {
|
|
fmt.Println(c.App.Name, version.Package, c.App.Version)
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
app := cli.NewApp()
|
|
app.Name = "ctr"
|
|
app.Version = version.Version
|
|
app.Usage = `
|
|
__
|
|
_____/ /______
|
|
/ ___/ __/ ___/
|
|
/ /__/ /_/ /
|
|
\___/\__/_/
|
|
|
|
containerd CLI
|
|
`
|
|
app.Flags = []cli.Flag{
|
|
cli.BoolFlag{
|
|
Name: "debug",
|
|
Usage: "enable debug output in logs",
|
|
},
|
|
cli.StringFlag{
|
|
Name: "address, a",
|
|
Usage: "address for containerd's GRPC server",
|
|
Value: server.DefaultAddress,
|
|
},
|
|
cli.DurationFlag{
|
|
Name: "timeout",
|
|
Usage: "total timeout for ctr commands",
|
|
},
|
|
cli.DurationFlag{
|
|
Name: "connect-timeout",
|
|
Usage: "timeout for connecting to containerd",
|
|
},
|
|
cli.StringFlag{
|
|
Name: "namespace, n",
|
|
Usage: "namespace to use with commands",
|
|
Value: namespaces.Default,
|
|
EnvVar: namespaces.NamespaceEnvVar,
|
|
},
|
|
}
|
|
app.Commands = append([]cli.Command{
|
|
applyCommand,
|
|
containersCommand,
|
|
contentCommand,
|
|
eventsCommand,
|
|
fetchCommand,
|
|
fetchObjectCommand,
|
|
imageCommand,
|
|
namespacesCommand,
|
|
pprofCommand,
|
|
pullCommand,
|
|
pushCommand,
|
|
pushObjectCommand,
|
|
rootfsCommand,
|
|
runCommand,
|
|
snapshotCommand,
|
|
tasksCommand,
|
|
pluginsCommand,
|
|
versionCommand,
|
|
}, extraCmds...)
|
|
app.Before = func(context *cli.Context) error {
|
|
if context.GlobalBool("debug") {
|
|
logrus.SetLevel(logrus.DebugLevel)
|
|
}
|
|
return nil
|
|
}
|
|
if err := app.Run(os.Args); err != nil {
|
|
fmt.Fprintf(os.Stderr, "ctr: %s\n", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|