-
Notifications
You must be signed in to change notification settings - Fork 285
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
CP-49213: Add new tar unpacking module #5787
CP-49213: Add new tar unpacking module #5787
Conversation
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 add the script that generated the tar file instead of the binary tar files?
Binary files are best avoided, even if just for test code.
Can this module be used to replace existing tar-unpacking code? |
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.
Is xapi/
the right place for this module? I feel this is just a utility module rather than a xapi functionality?
Some code can be replaced. But most of the tar-unpacking code doesn't unpack the files to disk. The extracted files are processed directly and not saved on disk. |
Can we make "saving to files" or "extract into some memory" options of this module? |
76936a8
to
e38bda9
Compare
I don't think we need this option. It can call directly |
e38bda9
to
d5ed93a
Compare
d5ed93a
to
ac1ff01
Compare
712b273
to
00a4807
Compare
|
c8afacc
to
9d0fdd2
Compare
Yes, I was trying to resolve the build and test failure. Now it's fixed. |
9d0fdd2
to
6d6b690
Compare
13c0b05
to
548b1f9
Compare
548b1f9
to
34fdf75
Compare
34fdf75
to
56e9f7d
Compare
let create_temp_dir () = | ||
let mktemp = Cmd.v "mktemp" in | ||
let mktemp' = Cmd.(mktemp % "-d") in | ||
let result = OS.Cmd.(run_out mktemp' |> to_string) in | ||
match result with | ||
| Ok path -> | ||
path | ||
| Error (`Msg s) -> | ||
Alcotest.fail | ||
(Printf.sprintf "Test tar_ext creating temp dir failure: %s" s) |
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 logic should be put in gen_tar_ext_test_file.sh
as otherwise it will be required every where the gen_tar_ext_test_file.sh
is called.
56e9f7d
to
9f79e14
Compare
I would like to suggest to think about the following approach: use |
Just a question for this tar unpacking feature, what's the performance impact (CPU usage) on the host as the unpacking might take long time for a big file, I think we should avoid consuming too much CPU of the host. |
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 looks good to me. I now understand the protection against escaping the directory better and think it's ok (checking against paths .
, ..
, and /
).
just tested it, I uploaded a tar file of about 500M, and it used not more than 8% (1 processor of 16). This took about 1 second as I uploaded the file from local, so it finished soon. |
Add a module Tar_ext to unpack a tar file. During the unpacking process, verify the tar file, containing total file size, file type, file path, file integrity, etc. Signed-off-by: Bengang Yuan <bengang.yuan@cloud.com>
Signed-off-by: Bengang Yuan <bengang.yuan@cloud.com>
9f79e14
to
a9b0ef7
Compare
bfa96cb
into
xapi-project:feature/non-cdn-update
I don't find a proper place for it. But it's only used for xapi in the current stage, so I think it's OK to place here. |
Add a module Tar_ext to unpack a tar file.
During the unpacking process, verify the tar file, containing total file size,
file type, file path, file integrity, etc.