mirror of
https://github.com/containers/podman.git
synced 2025-11-11 16:45:02 +08:00
Before this, for some special Podman commands (system reset, system migrate, system renumber), Podman would create a first Libpod runtime to do initialization and flag parsing, then stop that runtime and create an entirely new runtime to perform the actual task. This is an artifact of the pre-Podman 2.0 days, when there was almost no indirection between Libpod and the CLI, and we only used one runtime because we didn't need a second runtime for flag parsing and basic init. This system was clunky, and apparently, very buggy. When we migrated to SQLite, some logic was introduced where we'd select a different database location based on whether or not Libpod's StaticDir was manually set - which differed between the first invocation of Libpod and the second. So we'd get a different database for some commands (like `system reset`) and they would not be able to see existing containers, meaning they would not function properly. The immediate cause is obviously the SQLite behavior, but I'm certain there's a lot more baggage hiding behind this multiple Libpod runtime logic, so let's just refactor it out. It doesn't make sense, and complicates the code. Instead, make Reset, Renumber, and Migrate methods of the libpod Runtime. For Reset and Renumber, we can shut the runtime down afterwards to achieve the desired effect (no valid runtime after). Then pipe all of them through the ContainerEngine so cmd/podman can access them. As part of this, remove the SystemEngine part of pkg/domain. This was supposed to encompass these "special" commands, but every command in SystemEngine is actually a ContainerEngine command. Reset, Renumber, Migrate - they all need a full Libpod and access to all containers. There's no point to a separate engine if it just wraps Libpod in the exact same way as ContainerEngine. This consolidation saves us a bit more code and complexity. Signed-off-by: Matt Heon <mheon@redhat.com>
61 lines
2.5 KiB
Go
61 lines
2.5 KiB
Go
package entities
|
|
|
|
import (
|
|
"github.com/containers/common/pkg/config"
|
|
"github.com/spf13/pflag"
|
|
)
|
|
|
|
// EngineMode is the connection type podman is using to access libpod
|
|
type EngineMode string
|
|
|
|
// EngineSetup calls out whether a "normal" or specialized engine should be created
|
|
type EngineSetup string
|
|
|
|
const (
|
|
ABIMode = EngineMode("abi")
|
|
TunnelMode = EngineMode("tunnel")
|
|
)
|
|
|
|
// Convert EngineMode to String
|
|
func (m EngineMode) String() string {
|
|
return string(m)
|
|
}
|
|
|
|
// PodmanConfig combines the defaults and settings from the file system with the
|
|
// flags given in os.Args. Some runtime state is also stored here.
|
|
type PodmanConfig struct {
|
|
*pflag.FlagSet
|
|
|
|
ContainersConf *config.Config
|
|
ContainersConfDefaultsRO *config.Config // The read-only! defaults from containers.conf.
|
|
DBBackend string // Hidden: change the database backend
|
|
DockerConfig string // Location of authentication config file
|
|
CgroupUsage string // rootless code determines Usage message
|
|
ConmonPath string // --conmon flag will set Engine.ConmonPath
|
|
CPUProfile string // Hidden: Should CPU profile be taken
|
|
EngineMode EngineMode // ABI or Tunneling mode
|
|
HooksDir []string
|
|
Identity string // ssh identity for connecting to server
|
|
IsRenumber bool // Is this a system renumber command? If so, a number of checks will be relaxed
|
|
IsReset bool // Is this a system reset command? If so, a number of checks will be skipped/omitted
|
|
MaxWorks int // maximum number of parallel threads
|
|
MemoryProfile string // Hidden: Should memory profile be taken
|
|
RegistriesConf string // allows for specifying a custom registries.conf
|
|
Remote bool // Connection to Podman API Service will use RESTful API
|
|
RuntimePath string // --runtime flag will set Engine.RuntimePath
|
|
RuntimeFlags []string // global flags for the container runtime
|
|
Syslog bool // write logging information to syslog as well as the console
|
|
Trace bool // Hidden: Trace execution
|
|
URI string // URI to RESTful API Service
|
|
FarmNodeName string // Name of farm node
|
|
|
|
Runroot string
|
|
ImageStore string
|
|
StorageDriver string
|
|
StorageOpts []string
|
|
SSHMode string
|
|
MachineMode bool
|
|
TransientStore bool
|
|
GraphRoot string
|
|
}
|