Documentation
¶
Overview ¶
Package util groups a bunch of common helper functions used by commands.
Index ¶
- Variables
- func Errorf(format string, args ...any) subcommands.ExitStatus
- func Fatalf(format string, args ...any)
- func Infof(format string, args ...any)
- func IsPCIDeviceDirTPU(sysfsPath string, allowedDeviceIDs map[uint64]struct{}) bool
- func IsTPUDeviceValid(path string) (bool, error)
- type InternalCommand
- type InternalSubCommand
- type SubCommand
- type Writer
Constants ¶
This section is empty.
Variables ¶
var ErrorLogger io.Writer
ErrorLogger is where error messages should be written to. These messages are consumed by containerd and show up to users of command line tools, like docker/kubectl.
Functions ¶
func Errorf ¶
func Errorf(format string, args ...any) subcommands.ExitStatus
Errorf logs error to containerd log (--log), to stderr, and debug logs. It returns subcommands.ExitFailure for convenience with subcommand.Execute() methods:
return Errorf("Danger! Danger!")
func IsPCIDeviceDirTPU ¶
IsPCIDeviceDirTPU returns if the given PCI device sysfs path is a TPU device with one of the allowed device IDs.
func IsTPUDeviceValid ¶
IsTPUDeviceValid returns if the accelerator device is valid.
Types ¶
type InternalCommand ¶
InternalCommand is an interface for internal commands.
Internal commands are invoked by runsc itself. All of them use the --debug-log-fd and --log-fd mechanism. They all return "", nil, nil from SubCommand.FetchSpec because they don't need to have the spec as debug log file and log files are already created for them. This avoids having to re-load the Container struct from local filesystem, read all annotations and fix the config via specutils.FixConfig(). They already get the fixed config values as conf.ToFlags() is used to create their flags. They don't operate on a container so don't even take a container ID as an argument. Some of them (like boot and gofer) don't even have access to the host filesystem so they can't really open any host files.
type InternalSubCommand ¶
type InternalSubCommand struct{}
InternalSubCommand is a struct that implements FetchSpec for internal commands. It should be embedded in internal commands.
func (*InternalSubCommand) InternalFetchSpec ¶
func (*InternalSubCommand) InternalFetchSpec() (string, *specs.Spec, error)
InternalFetchSpec implements InternalCommand.InternalFetchSpec.
type SubCommand ¶
type SubCommand interface {
subcommands.Command
// FetchSpec returns the container ID, OCI spec associated with the command.
// If the command does not target a container, it should return "", nil, nil.
FetchSpec(conf *config.Config, f *flag.FlagSet) (string, *specs.Spec, error)
}
SubCommand is an extension of subcommands.Command that allows runsc CLI to fetch the OCI spec for the container that is targeted by the command.