-
Notifications
You must be signed in to change notification settings - Fork 354
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
Handle relative paths #740
Conversation
Signed-off-by: Szymon Gibała <[email protected]>
Codecov Report
@@ Coverage Diff @@
## main #740 +/- ##
==========================================
+ Coverage 71.87% 72.16% +0.28%
==========================================
Files 87 87
Lines 11854 11912 +58
==========================================
+ Hits 8520 8596 +76
+ Misses 3334 3316 -18 |
Signed-off-by: Szymon Gibała <[email protected]>
Signed-off-by: Szymon Gibała <[email protected]>
self.root_path = path | ||
.into() | ||
.canonicalize() | ||
.context("failed to canonicalize root path")?; |
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.
.context("failed to canonicalize root path")?; | |
.with_context(||format!("failed to canonicalize root path {:?}", path))?; |
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.
Needed to adjust it slightly as Into<PathBuf>
is not Debug
.
Some( | ||
p.into() | ||
.canonicalize() | ||
.context("failed canonicalize pid file path")?, |
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.
.context("failed canonicalize pid file path")?, | |
.with_context(|| format!("failed canonicalize pid file path"))?, |
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.
Did you mean to add the path
here too? Adjusted it similarly to the other one.
let spec = self.load_spec().context("failed to load spec")?; | ||
let container_dir = self | ||
.create_container_dir() | ||
.context("failed to create container dir")?; | ||
|
||
let mut container = self | ||
.create_container_state(&container_dir) | ||
.context("failed to create container state")?; |
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.
👍
Signed-off-by: Szymon Gibała <[email protected]>
a738f40
to
58fdcb4
Compare
This PR improves the handling of relative paths for
root_path
andpid_file
. I decided to create the specified directory early indetermine_root_path
if it does not exist, as this seems to be the only way tocanonicalize
path prior to creating container dir (path needs to exist otherwisecanonicalize
will fail). This results in the directory being created for other commands likelist
ordelete
also which might not be ideal, butrunc
seems to work this way either so decided to stick with it.Also not sure about canonicalizing those paths in
ContainerBuilder
as it disrupts the interface slightly by introducingResult<Self>
as a return type to some methods, however, I did not find a better place for that so if anyone has some suggestions please let me know.Additionally, I have added context to a few errors that made it easier to initially troubleshoot.
Fixes #720