mirror of
https://github.com/containers/podman.git
synced 2026-03-10 10:47:15 -04:00
Merge pull request #3465 from baude/nostore
configure runtime without store
This commit is contained in:
@@ -60,7 +60,7 @@ func execCmd(c *cliconfig.ExecValues) error {
|
||||
argStart = 0
|
||||
}
|
||||
cmd := args[argStart:]
|
||||
runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand)
|
||||
runtime, err := adapter.GetRuntimeNoStore(getContext(), &c.PodmanCommand)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error creating libpod runtime")
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ func containerExistsCmd(c *cliconfig.ContainerExistsValues) error {
|
||||
if len(args) > 1 || len(args) < 1 {
|
||||
return errors.New("you may only check for the existence of one container at a time")
|
||||
}
|
||||
runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand)
|
||||
runtime, err := adapter.GetRuntimeNoStore(getContext(), &c.PodmanCommand)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "could not get runtime")
|
||||
}
|
||||
@@ -126,7 +126,7 @@ func podExistsCmd(c *cliconfig.PodExistsValues) error {
|
||||
if len(args) > 1 || len(args) < 1 {
|
||||
return errors.New("you may only check for the existence of one pod at a time")
|
||||
}
|
||||
runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand)
|
||||
runtime, err := adapter.GetRuntimeNoStore(getContext(), &c.PodmanCommand)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "could not get runtime")
|
||||
}
|
||||
|
||||
@@ -15,20 +15,25 @@ import (
|
||||
|
||||
// GetRuntimeMigrate gets a libpod runtime that will perform a migration of existing containers
|
||||
func GetRuntimeMigrate(ctx context.Context, c *cliconfig.PodmanCommand) (*libpod.Runtime, error) {
|
||||
return getRuntime(ctx, c, false, true)
|
||||
return getRuntime(ctx, c, false, true, false)
|
||||
}
|
||||
|
||||
// GetRuntimeRenumber gets a libpod runtime that will perform a lock renumber
|
||||
func GetRuntimeRenumber(ctx context.Context, c *cliconfig.PodmanCommand) (*libpod.Runtime, error) {
|
||||
return getRuntime(ctx, c, true, false)
|
||||
return getRuntime(ctx, c, true, false, false)
|
||||
}
|
||||
|
||||
// GetRuntime generates a new libpod runtime configured by command line options
|
||||
func GetRuntime(ctx context.Context, c *cliconfig.PodmanCommand) (*libpod.Runtime, error) {
|
||||
return getRuntime(ctx, c, false, false)
|
||||
return getRuntime(ctx, c, false, false, false)
|
||||
}
|
||||
|
||||
func getRuntime(ctx context.Context, c *cliconfig.PodmanCommand, renumber bool, migrate bool) (*libpod.Runtime, error) {
|
||||
// GetRuntimeNoStore generates a new libpod runtime configured by command line options
|
||||
func GetRuntimeNoStore(ctx context.Context, c *cliconfig.PodmanCommand) (*libpod.Runtime, error) {
|
||||
return getRuntime(ctx, c, false, false, true)
|
||||
}
|
||||
|
||||
func getRuntime(ctx context.Context, c *cliconfig.PodmanCommand, renumber, migrate, noStore bool) (*libpod.Runtime, error) {
|
||||
options := []libpod.RuntimeOption{}
|
||||
storageOpts := storage.StoreOptions{}
|
||||
storageSet := false
|
||||
@@ -89,6 +94,9 @@ func getRuntime(ctx context.Context, c *cliconfig.PodmanCommand, renumber bool,
|
||||
options = append(options, libpod.WithStorageConfig(storageOpts))
|
||||
}
|
||||
|
||||
if !storageSet && noStore {
|
||||
options = append(options, libpod.WithNoStore())
|
||||
}
|
||||
// TODO CLI flags for image config?
|
||||
// TODO CLI flag for signature policy?
|
||||
|
||||
|
||||
@@ -300,6 +300,15 @@ func WithTmpDir(dir string) RuntimeOption {
|
||||
}
|
||||
}
|
||||
|
||||
// WithNoStore sets a bool on the runtime that we do not need
|
||||
// any containers storage.
|
||||
func WithNoStore() RuntimeOption {
|
||||
return func(rt *Runtime) error {
|
||||
rt.noStore = true
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// WithMaxLogSize sets the maximum size of container logs.
|
||||
// Positive sizes are limits in bytes, -1 is unlimited.
|
||||
func WithMaxLogSize(limit int64) RuntimeOption {
|
||||
|
||||
@@ -125,6 +125,9 @@ type Runtime struct {
|
||||
|
||||
// mechanism to read and write even logs
|
||||
eventer events.Eventer
|
||||
|
||||
// noStore indicates whether we need to interact with a store or not
|
||||
noStore bool
|
||||
}
|
||||
|
||||
// RuntimeConfig contains configuration options used to set up the runtime
|
||||
@@ -784,11 +787,14 @@ func makeRuntime(ctx context.Context, runtime *Runtime) (err error) {
|
||||
var store storage.Store
|
||||
if os.Geteuid() != 0 {
|
||||
logrus.Debug("Not configuring container store")
|
||||
} else if runtime.noStore {
|
||||
logrus.Debug("No store required. Not opening container store.")
|
||||
} else {
|
||||
store, err = storage.GetStore(runtime.config.StorageConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = nil
|
||||
|
||||
defer func() {
|
||||
if err != nil && store != nil {
|
||||
@@ -1148,6 +1154,8 @@ func (r *Runtime) Shutdown(force bool) error {
|
||||
}
|
||||
|
||||
var lastError error
|
||||
// If no store was requested, it can bew nil and there is no need to
|
||||
// attempt to shut it down
|
||||
if r.store != nil {
|
||||
if _, err := r.store.Shutdown(force); err != nil {
|
||||
lastError = errors.Wrapf(err, "Error shutting down container storage")
|
||||
|
||||
@@ -58,12 +58,26 @@ type Volume struct {
|
||||
// VolumeFilter is for filtering volumes on the client
|
||||
type VolumeFilter func(*Volume) bool
|
||||
|
||||
// GetRuntimeNoStore returns a localruntime struct wit an embedded runtime but
|
||||
// without a configured storage.
|
||||
func GetRuntimeNoStore(ctx context.Context, c *cliconfig.PodmanCommand) (*LocalRuntime, error) {
|
||||
runtime, err := libpodruntime.GetRuntimeNoStore(ctx, c)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return getRuntime(runtime)
|
||||
}
|
||||
|
||||
// GetRuntime returns a LocalRuntime struct with the actual runtime embedded in it
|
||||
func GetRuntime(ctx context.Context, c *cliconfig.PodmanCommand) (*LocalRuntime, error) {
|
||||
runtime, err := libpodruntime.GetRuntime(ctx, c)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return getRuntime(runtime)
|
||||
}
|
||||
|
||||
func getRuntime(runtime *libpod.Runtime) (*LocalRuntime, error) {
|
||||
return &LocalRuntime{
|
||||
Runtime: runtime,
|
||||
}, nil
|
||||
|
||||
@@ -50,6 +50,12 @@ type LocalRuntime struct {
|
||||
*RemoteRuntime
|
||||
}
|
||||
|
||||
// GetRuntimeNoStore returns a LocalRuntime struct with the actual runtime embedded in it
|
||||
// The nostore is ignored
|
||||
func GetRuntimeNoStore(ctx context.Context, c *cliconfig.PodmanCommand) (*LocalRuntime, error) {
|
||||
return GetRuntime(ctx, c)
|
||||
}
|
||||
|
||||
// GetRuntime returns a LocalRuntime struct with the actual runtime embedded in it
|
||||
func GetRuntime(ctx context.Context, c *cliconfig.PodmanCommand) (*LocalRuntime, error) {
|
||||
var (
|
||||
|
||||
Reference in New Issue
Block a user