-
Notifications
You must be signed in to change notification settings - Fork 267
Move Storage features in pkg/util from libpod to containers/storage #295
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
Conversation
|
@vrothberg PTAL |
vrothberg
left a comment
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.
One nit regarding the env variables. We need to be careful with future changes to the package to not introduce regressions.
pkg/rootless/rootless_linux.c
Outdated
| if (pid) | ||
| return pid; | ||
|
|
||
| setenv ("_LIBPOD_USERNS_CONFIGURED", "init", 1); |
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.
Can we rename the identifiers to CONTAINERS ?
|
Why are we moving |
|
The |
|
@mheon Util package currently is used in buildah, libpod and eventually skopeo. |
|
Util package also seems mainly concerned with setting up default containers storage. |
|
@nalind Can we start moving parts of containers image over here if it is needed by both packages. I would like to get to the point where we have a stack of tools that looks like this. But the vendoring only goes in one direction. cri-o |
|
@rhatdan Not really? There's some storage in there, but that's where I tell people to stick general utility functions, and a fair bit of it will be libpod-specific |
The only dependency in that direction so far is a call to |
|
@mheon I will remove the parts of utils.go that have nothing to do with storage. |
I don't have a great handle on how libraries are distributed among these projects, so take this with a grain of salt, but I don't see a connection between the rootless stuff and storage, except for holding a package-level |
|
I agree with @wking. It might help with vendoring and avoid circular dependencies, but containers/storage doesn't seem the best place for We are only using a subset of the package from Buildah, we could probably avoid the circular dependency embedding the few changes inside Buildah itself and not requiring pkg/rootless. |
5d5054b to
7767c0b
Compare
|
I am moving pkg/rootless to buildah and just putting the StorageDefaults handling in this PR. |
|
Opened containers/buildah#1400 to test this patch out and mv pkg/rootless to buildah. |
|
@nalind PTAL |
| } | ||
|
|
||
| // GetRootlessRuntimeDir returns the runtime directory when running as non root | ||
| func GetRootlessRuntimeDir(rootlessUid int) (string, error) { |
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.
Does this need to be exported?
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.
It is used all over libpod.
/home/dwalsh/libpod/libpod/runtime.go: rootlessRuntimeDir, err := util.GetRootlessRuntimeDir()
/home/dwalsh/libpod/libpod/runtime.go: val, err = util.GetRootlessRuntimeDir()
/home/dwalsh/libpod/libpod/runtime.go: runtimeDir, err := util.GetRootlessRuntimeDir()
/home/dwalsh/libpod/libpod/runtime.go: runtimeDir, err := util.GetRootlessRuntimeDir()
/home/dwalsh/libpod/libpod/oci.go: runtimeDir, err := util.GetRootlessRuntimeDir()
/home/dwalsh/libpod/libpod/oci.go: runtimeDir, err := util.GetRootlessRuntimeDir()
/home/dwalsh/libpod/libpod/oci.go: runtimeDir, err := util.GetRootlessRuntimeDir()
/home/dwalsh/libpod/libpod/oci.go: runtimeDir, err := util.GetRootlessRuntimeDir()
/home/dwalsh/libpod/libpod/oci.go: runtimeDir, err := util.GetRootlessRuntimeDir()
/home/dwalsh/libpod/libpod/oci.go: runtimeDir, err := util.GetRootlessRuntimeDir()
/home/dwalsh/libpod/libpod/oci.go: runtimeDir, err := util.GetRootlessRuntimeDir()
/home/dwalsh/libpod/libpod/oci.go: runtimeDir, err := util.GetRootlessRuntimeDir()
/home/dwalsh/libpod/libpod/oci.go: runtimeDir, err := util.GetRootlessRuntimeDir()
/home/dwalsh/libpod/libpod/oci.go: runtimeDir, err := util.GetRootlessRuntimeDir()
pkg/util/utils.go
Outdated
| } | ||
| } | ||
| if runtimeDir == "" { | ||
| tmpDir := fmt.Sprintf("%s/user/%d", os.TempDir(), rootlessUid) |
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.
Why the "user" intermediate directory under what will likely be "/tmp"?
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.
Because it was there in the libpod version. Removed.
pkg/util/utils.go
Outdated
|
|
||
| // GetRootlessDirInfo returns the parent path of where the storage for containers and | ||
| // volumes will be in rootless mode | ||
| func GetRootlessDirInfo(rootlessUid int) (string, string, error) { |
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.
Does this need to be exported?
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.
Nope, Fixed
pkg/util/utils.go
Outdated
| } | ||
|
|
||
| // GetRootlessStorageOpts returns the storage opts for containers running as non root | ||
| func GetRootlessStorageOpts(rootlessUid int) (storage.StoreOptions, error) { |
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.
Does this need to be exported?
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.
Nope Fixed.
pkg/util/utils.go
Outdated
| } | ||
|
|
||
| // GetDefaultStoreOptions returns the default storage ops for containers | ||
| func GetDefaultStoreOptions(rootless bool, rootlessUid int) (storage.StoreOptions, error) { |
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.
What do we gain by hiding this in a subpackage? How should a caller know if it should call this function, GetRootlessStorageOpts(), or simply read from storage.DefaultStoreOptions?
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.
Documentation?
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.
Rewritten again to make these functions primary in storage and to remove links to the constants.
Now storage.DefaultStoreOptions is function.
pkg/util/utils.go
Outdated
| } | ||
|
|
||
| // StorageConfigFile returns the path to the storage config file used | ||
| func StorageConfigFile(rootless bool) string { |
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.
How should a caller know if this is needed instead of trusting storage.DefaultConfigFile?
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.
I could make DefaultConfigFile not be exposed.
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.
Change DefaultConfigFile-> defaultConfigFile.
Now you need to call StorageFile()
pkg/util/utils.go
Outdated
| // StorageConfigFile returns the path to the storage config file used | ||
| func StorageConfigFile(rootless bool) string { | ||
| if rootless { | ||
| return filepath.Join(os.Getenv("HOME"), ".config/containers/storage.conf") |
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.
GetRootlessDirInfo() returns an error if $HOME is not set. Should this function be checking for that?
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.
Fixed
d7908a2 to
dcbc3f5
Compare
|
LGTM |
utils.go
Outdated
| if subUIDMap != "" && subGIDMap != "" { | ||
| mappings, err := idtools.NewIDMappings(subUIDMap, subGIDMap) | ||
| if err != nil { | ||
| return nil, err |
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.
Wrap this with errors.Wrapf.
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.
Fixed
utils.go
Outdated
| } | ||
| parsedUIDMap, err := idtools.ParseIDMap(UIDMapSlice, "UID") | ||
| if err != nil { | ||
| return nil, err |
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.
Wrap this with errors.Wrapf.
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.
Fixed
utils.go
Outdated
| } | ||
| parsedGIDMap, err := idtools.ParseIDMap(GIDMapSlice, "GID") | ||
| if err != nil { | ||
| return nil, err |
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.
Wrap this with errors.Wrapf.
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.
Fixed
utils.go
Outdated
|
|
||
| if rootless { | ||
| if os.IsNotExist(err) { | ||
| os.MkdirAll(filepath.Dir(storageConf), 0755) |
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.
Check for an error here.
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.
Fixed
| if storageOpts.GraphRoot == "" { | ||
| storageOpts.GraphRoot = defaultRootlessGraphRoot | ||
| } | ||
| } |
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.
We should do something about non-nil errors that aren't IsNotExist errors.
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.
Added handling for this.
|
Some nits around error handling, but otherwise LGTM. |
13662fb to
7157a77
Compare
|
@giuseppe PTAL I rewrote some of the GetRootlessRuntimeDir functions. |
| return tmpDir, nil | ||
| } | ||
| } | ||
| tmpDir := fmt.Sprintf("%s/%d", os.TempDir(), rootlessUid) |
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.
filepath.Join?
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.
That fails to build because rootlessUid is an int.
|
LGTM |
utils.go
Outdated
| } | ||
| parsedUIDMap, err := idtools.ParseIDMap(UIDMapSlice, "UID") | ||
| if err != nil { | ||
| return nil, errors.Wrapf(err, "failed to create ParseIDMap UID=%s", UIDMapSlice) |
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.
to differentiate, could you s/ParseIDMap/ParseUidMap/ here and with ParseGidMap below at line 57?
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.
Fixed.
|
LGTM other than two small nits. Test errors are odd. All the go 1.11 tests pass, the others fail due to not being able to find md2man? |
…rage In an effort to remove cross vendoring, trying to fix buildah from importing from libpod. I beleive these libraries make more sense in containers/storage then in libpod. Signed-off-by: Daniel J Walsh <[email protected]>
Signed-off-by: Daniel J Walsh <[email protected]>
In an effort to remove cross vendoring, trying to fix buildah from importing from
libpod. I believe these libraries make more sense in containers/storage then in libpod.
Signed-off-by: Daniel J Walsh [email protected]