Skip to content

Commit

Permalink
create machine dirs at discovery
Browse files Browse the repository at this point in the history
in various use cases, the required machine dirs are not created.  the
machine dirs are runtimedir, datadir, and configdir.  Example in Linux
would be:

configDir /<HOME>/.config/containers/podman/machine/<provider>
dataDir /<HOME>/.local/share/containers/podman/machine/<provider>
runtimeDir /run/user/1000/podman/machine

now we blindly create them without checking for their existence (because
it is faster).

this fixes a bug where runtimedir does not exist on macos after a reboot

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <[email protected]>
  • Loading branch information
Brent Baude committed Feb 5, 2024
1 parent 268743a commit 33bda05
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/machine/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,25 @@ func GetMachineDirs(vmType define.VMType) (*define.MachineDirs, error) {
}

rtDirFile, err := define.NewMachineFile(rtDir, nil)
if err != nil {
return nil, err
}

dirs := define.MachineDirs{
ConfigDir: configDirFile,
DataDir: dataDirFile,
RuntimeDir: rtDirFile,
}

// make sure all machine dirs are present
if err := os.MkdirAll(rtDir, 0755); err != nil {
return nil, err
}
if err := os.MkdirAll(configDir, 0755); err != nil {
return nil, err
}
err = os.MkdirAll(dataDir, 0755)

return &dirs, err
}

Expand Down

0 comments on commit 33bda05

Please sign in to comment.