Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions core-dump-composer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub struct CoreConfig {
pub os_hostname: String,
pub filename_template: String,
pub params: CoreParams,
pub disable_compression: bool,
}

#[derive(Serialize)]
Expand Down Expand Up @@ -59,9 +60,10 @@ impl CoreConfig {
let pathname = matches.value_of("pathname").unwrap_or("").to_string();
let timeout = matches
.value_of("timeout")
.unwrap_or("120")
.unwrap_or("600")
.parse::<u64>()
.unwrap();
let disable_compression = matches.contains_id("disable-compression");

let uuid = Uuid::new_v4();

Expand Down Expand Up @@ -144,6 +146,7 @@ impl CoreConfig {
filename_template,
log_length,
params,
disable_compression,
})
}

Expand Down Expand Up @@ -208,11 +211,11 @@ impl CoreConfig {
format!("{}-ps-info.json", self.get_templated_name())
}

pub fn get_image_filename(&self, counter: u32) -> String {
pub fn get_image_filename(&self, counter: usize) -> String {
format!("{}-{}-image-info.json", self.get_templated_name(), counter)
}

pub fn get_log_filename(&self, counter: u32) -> String {
pub fn get_log_filename(&self, counter: usize) -> String {
format!("{}-{}.log", self.get_templated_name(), counter)
}
pub fn get_zip_full_path(&self) -> String {
Expand Down Expand Up @@ -315,6 +318,13 @@ pub fn try_get_matches() -> clap::Result<ArgMatches> {
.takes_value(true)
.help("test-threads mapped to support the test scenarios"),
)
.arg(
Arg::new("disable-compression")
.short('D')
.long("disable-compression")
.takes_value(false)
.help("Disables deflate compression in resulting zip file and stores data uncompressed."),
)
.try_get_matches()
}

Expand Down
28 changes: 13 additions & 15 deletions core-dump-composer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,13 @@ fn handle(mut cc: config::CoreConfig) -> Result<(), anyhow::Error> {
cc.set_podname(podname.to_string());

// Create the base zip file that we are going to put everything into
let compression_method = if cc.disable_compression {
zip::CompressionMethod::Stored
} else {
zip::CompressionMethod::Deflated
};
let options = FileOptions::default()
.compression_method(zip::CompressionMethod::Deflated)
.compression_method(compression_method)
.unix_permissions(0o444)
.large_file(true);

Expand Down Expand Up @@ -159,20 +164,14 @@ fn handle(mut cc: config::CoreConfig) -> Result<(), anyhow::Error> {

let stdin = io::stdin();
let mut stdin = stdin.lock();
let mut data = [0u8; 8192];

while let Ok(n) = stdin.read(&mut data) {
if n == 0 {
break;
match io::copy(&mut stdin, &mut zip) {
Ok(v) => v,
Err(e) => {
error!("Error writing core file \n{}", e);
process::exit(1);
}
match zip.write_all(&data) {
Ok(v) => v,
Err(e) => {
error!("Error writing core file \n{}", e);
process::exit(1);
}
};
}
};
zip.flush()?;

if cc.ignore_crio {
Expand Down Expand Up @@ -306,8 +305,7 @@ fn handle(mut cc: config::CoreConfig) -> Result<(), anyhow::Error> {
debug!("Successfully got the process details {}", ps_object);

if let Some(containers) = ps_object["containers"].as_array() {
for container in containers {
let counter = 0;
for (counter, container) in containers.iter().enumerate() {
let img_ref = match container["imageRef"].as_str() {
Some(v) => v,
None => {
Expand Down