Skip to content

storage: unshare should not cache the HOME dir. #787

@Luap99

Description

@Luap99

Currently calls to unshare.HomeDir() cache the result and return the same thing over and over. It was added in containers/storage#669 for performance reasons though it is not clear to me how much this actually safes in practise? Are we really calling this on a hot path were we would need to get the home dir over and over? I really doubt that.

Also I assume the vast majority cases uses the $HOME env so the lookup there should be fast enough IMO, the user db fallback might be slower but since that is the not common case I do not think it matters much.

The reason the cache is problematic is at least for tests who set a custom $HOME, I have been surprised more than once of this behavior and it requires additional test work around often. The latest thing where this took me extra time to understand what is wrong was in containers/podman#28573 as machine test also use a custom per test $HOME.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions