-
Notifications
You must be signed in to change notification settings - Fork 53
driverdog: Add ability to detect and decompress objects #588
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
base: develop
Are you sure you want to change the base?
Conversation
The files that are linked at build time could be compressed which allows space savings on disk for a minor boot time increase. driverdog now can detect that the requested file may be compressed and have a .gz extension. If so, then it will decompress before working with the file. Signed-off-by: Matthew Yeazel <yeazelm@amazon.com>
^pushed a new change using OptionalCompressionReader and io::copy |
@@ -193,7 +193,7 @@ syn = { version = "2", default-features = false } | |||
tar = { version = "0.4", default-features = false } | |||
tempfile = "3" | |||
test-case = "3" | |||
tokio = { version = "~1.43", default-features = false } # LTS | |||
tokio = { version = "~1.43", default-features = false } # LTS |
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.
Don't need this change.
@@ -10,6 +10,7 @@ exclude = ["README.md"] | |||
|
|||
[dependencies] | |||
argh.workspace = true | |||
early-boot-config-provider.workspace = true |
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'd pictured a new crate that both of these could depend on.
/// Creates a temporary directory with test files for compression tests | ||
fn setup_test_files() -> TempDir { | ||
let temp_dir = tempfile::tempdir().expect("Failed to create temp directory"); | ||
|
||
// Create a regular object file | ||
let regular_file_path = temp_dir.path().join("module.o"); | ||
File::create(®ular_file_path).expect("Failed to create regular file"); |
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.
These tests seem to be just copies of the ones in main.rs
- seems like we can get rid of this whole file.
let compressed_file_path = temp_dir.path().join("compressed_module.o.gz"); | ||
File::create(&compressed_file_path).expect("Failed to create compressed file"); | ||
temp_dir |
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 isn't actually a compressed file, which feels like it could create a false sense of coverage.
use std::{ | ||
path::PathBuf, | ||
process::{Command, Output}, | ||
}; |
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.
The previous code seemed fine, I'm not a huge fan of this nested style.
match is_compressed(&from) { | ||
Some(compressed_path) => { | ||
info!("Found compressed file: {:?}", compressed_path); | ||
copy_and_decompress(&compressed_path, &object_file_path)?; | ||
} | ||
None => { | ||
info!("Copying {:?}", &from); | ||
copy_and_decompress(&from, &object_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.
It seems like we don't really need the is_compressed
check.
Either the package could just list the .o.gz
file directly in the driverdog config, or the package could compress the .o
file and include it without the gzip extension.
I.e. the change can just be:
- fs::copy(&from, &object_file_path)
+ copy_and_decompress(&from, &object_file_path)
Issue number:
Part of # bottlerocket-os/bottlerocket#4588
Description of changes:
The files that are linked at build time could be compressed which allows space savings on disk for a minor boot time increase.
driverdog
now can detect that the requested file may be compressed and have ano.gz
extension. If so, then it will decompress before working with the file.Testing done:
Built variants with and without compressed modules (see this commit for how they were compressed) and confirmed both work. For the compressed objects, the link-telsa-kernel-modules.service journal looks like this:
For non-compressed, they look like this:
Terms of contribution:
By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.