mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-10-21 21:37:38 +00:00
Fix runtime initialization for missing StaticDir and VolumePath
This commit fixes two issues in runtime initialization that occur when
vendor code doesn't properly set StaticDir and VolumePath defaults:
1. Add defensive initialization for StaticDir and VolumePath
- Check if StaticDir is empty and set it to GraphRoot/libpod
- Check if VolumePath is empty and set it to GraphRoot/volumes
- This works around missing initialization in older vendor code
without requiring changes to the vendor directory
2. Fix database initialization to allow creating new bolt_state.db
- Previously, getDBState() would fail if bolt_state.db didn't exist
- Now, only return error if it's not os.ErrNotExist
- This allows NewBoltState() to create the database on first run
These changes resolve the "creating runtime static files directory:
mkdir : no such file or directory" error that occurred when running
podman commands.
Tested with:
- podman ps, info, version commands work correctly
- Volume operations create volumes at correct path
- Database is properly initialized on first run
Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
This commit is contained in:
parent
4231526e18
commit
650b46a368
1 changed files with 16 additions and 4 deletions
|
|
@ -319,10 +319,14 @@ func getDBState(runtime *Runtime) (State, error) {
|
|||
case config.DBBackendDefault:
|
||||
// for backwards compatibility check if boltdb exists, if it does not we use sqlite
|
||||
if _, err := os.Stat(boltDBPath); err != nil {
|
||||
// Return error here some other problem with the boltdb file, rather than silently
|
||||
// switch to sqlite which would be hard to debug for the user return the error back
|
||||
// as this likely a real bug.
|
||||
return nil, err
|
||||
// Only return error if it's not a "file not found" error.
|
||||
// If the file doesn't exist, we'll create it with NewBoltState.
|
||||
if !errors.Is(err, os.ErrNotExist) {
|
||||
// Return error here some other problem with the boltdb file, rather than silently
|
||||
// switch to sqlite which would be hard to debug for the user return the error back
|
||||
// as this likely a real bug.
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
runtime.config.Engine.DBBackend = config.DBBackendBoltDB.String()
|
||||
fallthrough
|
||||
|
|
@ -352,6 +356,14 @@ func makeRuntime(runtime *Runtime) (retErr error) {
|
|||
return fmt.Errorf("cannot perform system reset while renumbering locks: %w", define.ErrInvalidArg)
|
||||
}
|
||||
|
||||
// Ensure StaticDir and VolumePath are set (defensive check for older vendor code)
|
||||
if runtime.config.Engine.StaticDir == "" {
|
||||
runtime.config.Engine.StaticDir = filepath.Join(runtime.storageConfig.GraphRoot, "libpod")
|
||||
}
|
||||
if runtime.config.Engine.VolumePath == "" {
|
||||
runtime.config.Engine.VolumePath = filepath.Join(runtime.storageConfig.GraphRoot, "volumes")
|
||||
}
|
||||
|
||||
// Make the static files directory if it does not exist
|
||||
if err := os.MkdirAll(runtime.config.Engine.StaticDir, 0700); err != nil {
|
||||
// The directory is allowed to exist
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue