Skip to content
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

Rootless libpod.conf should fill in an appropriate tmp_dir #2408

Closed
llchan opened this issue Feb 21, 2019 · 9 comments

Comments

Projects
None yet
4 participants
@llchan
Copy link

commented Feb 21, 2019

/kind bug

Description

When a libpod.conf is specified via --config, an omitted tmp_dir does not fall back to the default ($XDG_RUNTIME_DIR/libpod/tmp) like it does when --config is not specified. It remains at the empty string, which leads to a fairly obvious but not very user-friendly error downstream.

Steps to reproduce the issue:

  1. Copy the default libpod.conf (which has tmp_dir commented out)

  2. podman --config libpod.conf info

Describe the results you received:

DEBU[0000] Using tmp dir                                
DEBU[0000] Set libpod namespace to ""                   
DEBU[0000] [graphdriver] trying provided driver "vfs"   
ERRO[0000] could not get runtime: error creating tmpdir : mkdir : no such file or directory 

Describe the results you expected:

DEBU[0000] Using tmp dir /run/user/XXXXX/libpod/tmp     
DEBU[0000] Set libpod namespace to ""                   
DEBU[0000] [graphdriver] trying provided driver "vfs"

Output of podman version:

RemoteAPI Version:  1
Go Version:         go1.11
Git Commit:         eb6243226a08254f15657c3728bb4dd8949ee6cd
Built:              Thu Feb 21 17:13:21 2019
OS/Arch:            linux/amd64
@llchan

This comment has been minimized.

Copy link
Author

commented Feb 21, 2019

This diff fixes things (awaiting approval to submit PRs, but pasting this here since it's small and harmless):

diff --git a/libpod/runtime.go b/libpod/runtime.go
index 94dbf37d..a8bb4b9f 100644
--- a/libpod/runtime.go
+++ b/libpod/runtime.go
@@ -472,6 +472,12 @@ func NewRuntimeFromConfig(configPath string, options ...RuntimeOption) (runtime
    runtime.config.OCIRuntime = defaultRuntimeConfig.OCIRuntime
    runtime.config.StorageConfig = storage.StoreOptions{}

+   tmpDir, err := getDefaultTmpDir()
+   if err != nil {
+       return nil, err
+   }
+   runtime.config.TmpDir = tmpDir
+
    // Check to see if the given configuration file exists
    if _, err := os.Stat(configPath); err != nil {
        return nil, errors.Wrapf(err, "error checking existence of configuration file %s", configPath)

On a more general note, is there a reason why we don't initialize with defaultRuntimeConfig, and let the user-supplied config overwrite (i.e. more similar to what NewRuntime does)?

@giuseppe

This comment has been minimized.

Copy link
Member

commented Feb 22, 2019

the patch LGTM

@giuseppe giuseppe added the rootless label Feb 22, 2019

@rhatdan

This comment has been minimized.

Copy link
Member

commented Feb 22, 2019

Could someone open this as a PR?

@rhatdan

This comment has been minimized.

Copy link
Member

commented Feb 23, 2019

This seems to be working for me in current podman?

$ podman --log-level debug --config ~/.config/containers/libpod.conf info  2>&1 | grep -i "Using tmp"
time="2019-02-23T06:11:43-05:00" level=debug msg="Using tmp dir /run/user/3267/libpod/tmp" 
$ grep tmp ~/.config/containers/libpod.conf
@llchan

This comment has been minimized.

Copy link
Author

commented Feb 25, 2019

@rhatdan maybe you need to remove your existing db config?

@giuseppe

This comment has been minimized.

Copy link
Member

commented Feb 26, 2019

I see the same problem with a fresh storage. I confirm the patch above fixes the problem.

@llchan could you open a PR?

@llchan

This comment has been minimized.

Copy link
Author

commented Feb 27, 2019

I unfortunately cannot yet, still pending approval from manager and he's out of town for the week. Will do as soon as I can. If you'd like to file it on my behalf feel free to.

@rhatdan

This comment has been minimized.

Copy link
Member

commented Feb 27, 2019

Ok, @llchan We would love to have you to contribute, once you get permission.. @giuseppe Can you open a PR.

giuseppe added a commit to giuseppe/libpod that referenced this issue Mar 4, 2019

runtime: fill a proper default tmpdir when --config is used
Closes: containers#2408

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
@giuseppe

This comment has been minimized.

Copy link
Member

commented Mar 4, 2019

I've opened a PR here: #2515

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.