-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure good defaults on blank c/storage configuration #3954
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -281,10 +281,17 @@ func defaultRuntimeConfig() (RuntimeConfig, error) { | |
if err != nil { | ||
return RuntimeConfig{}, err | ||
} | ||
graphRoot := storeOpts.GraphRoot | ||
if graphRoot == "" { | ||
logrus.Warnf("Storage configuration is unset - using hardcoded default paths") | ||
graphRoot = "/var/lib/containers/storage" | ||
} | ||
volumePath := filepath.Join(graphRoot, "volumes") | ||
staticDir := filepath.Join(graphRoot, "libpod") | ||
return RuntimeConfig{ | ||
// Leave this empty so containers/storage will use its defaults | ||
StorageConfig: storage.StoreOptions{}, | ||
VolumePath: filepath.Join(storeOpts.GraphRoot, "volumes"), | ||
VolumePath: volumePath, | ||
ImageDefaultTransport: DefaultTransport, | ||
StateType: BoltDBStateStore, | ||
OCIRuntime: "runc", | ||
|
@@ -314,7 +321,7 @@ func defaultRuntimeConfig() (RuntimeConfig, error) { | |
}, | ||
InitPath: define.DefaultInitPath, | ||
CgroupManager: SystemdCgroupsManager, | ||
StaticDir: filepath.Join(storeOpts.GraphRoot, "libpod"), | ||
StaticDir: staticDir, | ||
TmpDir: "", | ||
MaxLogSize: -1, | ||
NoPivotRoot: false, | ||
|
@@ -789,6 +796,20 @@ func probeConmon(conmonBinary string) error { | |
// Make a new runtime based on the given configuration | ||
// Sets up containers/storage, state store, OCI runtime | ||
func makeRuntime(ctx context.Context, runtime *Runtime) (err error) { | ||
// Let's sanity-check some paths first. | ||
// Relative paths can cause nasty bugs, because core paths we use could | ||
// shift between runs (or even parts of the program - the OCI runtime | ||
// uses a different working directory than we do, for example. | ||
if !filepath.IsAbs(runtime.config.StaticDir) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should these checks should go into containers/storage? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These paths are all ours - libpod static and temporary files directories and libpod named volumes |
||
return errors.Wrapf(define.ErrInvalidArg, "static directory must be an absolute path - instead got %q", runtime.config.StaticDir) | ||
} | ||
if !filepath.IsAbs(runtime.config.TmpDir) { | ||
return errors.Wrapf(define.ErrInvalidArg, "temporary directory must be an absolute path - instead got %q", runtime.config.TmpDir) | ||
} | ||
if !filepath.IsAbs(runtime.config.VolumePath) { | ||
return errors.Wrapf(define.ErrInvalidArg, "volume path must be an absolute path - instead got %q", runtime.config.VolumePath) | ||
} | ||
|
||
// Find a working conmon binary | ||
foundConmon := false | ||
foundOutdatedConmon := false | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should at least warn on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, added warning logs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concur, but could be talked into a debug instead. Chocolate chip cookies would help sway me! ;^)