-
Notifications
You must be signed in to change notification settings - Fork 206
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
nydus-image: add backend-config
support to nydus-image unpack
#1082
Conversation
@loheagn , a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/50984 |
backend-config
support to nydus-image unpack
backend-config
support to nydus-image unpack
@loheagn , the title has been updated, so a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/50989 |
353033a
to
0543499
Compare
@loheagn , the code has been updated, so a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/50990 |
@loheagn , The CI test is completed, please check result:
Congratulations, your test job passed! |
@loheagn , The CI test is completed, please check result:
Congratulations, your test job passed! |
How about using "-C, --config " instead? We are going to switch from "--backend-config" to "--config" and "--backend-config" will get deprecated. |
@jiangliu But I think this will be conflict with the |
Are you going to support this usage scenario?
|
Yes. For example, by now, when we use the |
Can we let nydus-image to handle the bootstrap part too? |
@jiangliu Yes, I think we can. We need to implement the logic of extracting the bootstrap and blob data from the whole nydus image layer (which is implemented in nydus-snapshotter by now) and let the caller tell nydus-image the loacation of the image layer by some argument (may be What's your option? @imeoer |
We may discuss offline. I hope we can enhance nydus-image to directly handle remote image, the same to nydusd. |
Does this work for you?
|
api/src/config.rs
Outdated
@@ -250,6 +250,7 @@ pub struct BackendConfigV2 { | |||
/// Configuration for container registry backend. | |||
pub registry: Option<RegistryConfig>, | |||
/// Configuration for local http proxy. | |||
#[serde(rename = "http-proxy")] | |||
pub http_proxy: Option<HttpProxyConfig>, |
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.
This deserves a dedicated PR:)
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.
Here's the pr #1086 .
src/bin/nydus-image/main.rs
Outdated
@@ -17,16 +17,19 @@ extern crate lazy_static; | |||
use std::fs::{self, metadata, DirEntry, File, OpenOptions}; | |||
use std::os::unix::fs::FileTypeExt; | |||
use std::path::{Path, PathBuf}; | |||
use std::result::Result::Ok; |
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.
This may be unnecessary.
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.
Yes. Fixed :)
0543499
to
10fedc2
Compare
@loheagn , the code has been updated, so a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/51269 |
NO. The argument |
@loheagn , The CI test is completed, please check result:
Congratulations, your test job passed! |
10fedc2
to
d6821a6
Compare
@loheagn , the code has been updated, so a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/51285 |
|
||
Ok(backend) | ||
} | ||
|
||
fn get_blob_id(matches: &ArgMatches) -> Result<String> { | ||
let mut blob_id = String::new(); | ||
|
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.
our review
- The code contains unused imports like nix and nydus_storage.
- The code is missing type annotations, which makes it difficult to understand what is going on in the code.
- The code does not have any comments, which can help explain the purpose of the code.
- In the prepare_cmd_args function, the argument for the backend-config should be made required.
- In the get_backend function, the backend-config argument should be checked for validity before being used.
- In the get_blob_id function, the blob_id variable should be initialized with a meaningful value before being used.
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.
You are so smart 💯
@loheagn , The CI test is completed, please check result:
Congratulations, your test job passed! |
The `nydus-image unpack` only support reading nydus blob from the blob files on local machine (by the argument `blob`) by now. This patch adds a new argument `backend-config` to this command to allow `nydus-image unpack` to read blob data from all kinds of backends. Signed-off-by: Nan Li <loheagn@icloud.com>
d6821a6
to
081c8f9
Compare
@loheagn , the code has been updated, so a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/51290 |
|
||
Ok(backend) | ||
} | ||
|
||
fn get_blob_id(matches: &ArgMatches) -> Result<String> { | ||
let mut blob_id = String::new(); | ||
|
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.
with a brief introduction about the code,
The code is a part of an application written in Rust programming language. It implements a Command struct and Command trait which provides functionality for configuring backend from config file, importing chunk dictionary and unpack metadata. The code is also responsible for validating user provided arguments such as --output and --blob.
Now, let's move on to the code review.
First, the code contains some missing error handling for the LocalFs::new() method call. This should be added to prevent any unexpected errors.
Second, it would be better to use pattern matching when checking the blob argument instead of using if-else statements. This will make the code more readable and maintainable.
Third, the get_backend() function can be simplified by using the shorthand notation for destructuring the Option type. This will make the code more concise.
Fourth, the get_blob_id() method can be improved by using the Result type instead of returning a String. This will help in better error handling.
Finally, it would be better to use the Result combinators such as map_err() and map() to improve the readability of the code and make it more concise.
@loheagn , The CI test is completed, please check result:
Congratulations, your test job passed! |
With nydus 2.2, the "--bootstrap" option for |
The
nydus-image unpack
only support reading nydus blob from the blob files on local machine (by the argumentblob
) by now. This patch adds a new argumentbackend-config
to this command to allownydus-image unpack
to read blob data from all kinds of backends.