Skip to content

Commit

Permalink
Support bundle fixes into 1.0.9 (#2766)
Browse files Browse the repository at this point in the history
This fixes 2 bugs. First, large enough logs weren't being written to the bundle b/c write was used instead of writre_all. Second, windows didn't respect time zones properly. This fixes that.
  • Loading branch information
lfitchett authored Mar 31, 2020
1 parent 1f7cf6a commit a8f0f62
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions edgelet/iotedge/src/support_bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,12 @@ where
NaiveDateTime::from_timestamp(state.log_options.since().into(), 0),
Utc,
);
let since = since_time.format("%F %T").to_string();

#[cfg(unix)]
let inspect = ShellCommand::new("journalctl")
.arg("-a")
.args(&["-u", "iotedge"])
.args(&["-S", &since])
.args(&["-S", &since_time.format("%F %T").to_string()])
.arg("--no-pager")
.output();

Expand All @@ -236,7 +235,7 @@ where
.arg(&format!(r"Get-WinEvent -ea SilentlyContinue -FilterHashtable @{{ProviderName='iotedged';LogName='application';StartTime='{}'}} |
Select TimeCreated, Message |
Sort-Object @{{Expression='TimeCreated';Descending=$false}} |
Format-List", since))
Format-List", since_time.to_rfc3339()))
.output();

let (file_name, output) = if let Ok(result) = inspect {
Expand All @@ -258,7 +257,7 @@ where

state
.zip_writer
.write(&output)
.write_all(&output)
.map_err(|err| Error::from(err.context(ErrorKind::SupportBundle)))?;

state.print_verbose("Got logs for iotedged");
Expand All @@ -271,13 +270,12 @@ where
NaiveDateTime::from_timestamp(state.log_options.since().into(), 0),
Utc,
);
let since = since_time.format("%F %T").to_string();

#[cfg(unix)]
let inspect = ShellCommand::new("journalctl")
.arg("-a")
.args(&["-u", "docker"])
.args(&["-S", &since])
.args(&["-S", &since_time.format("%F %T").to_string()])
.arg("--no-pager")
.output();

Expand All @@ -290,7 +288,7 @@ where
r#"Get-EventLog -LogName Application -Source Docker -After "{}" |
Sort-Object Time |
Format-List"#,
since
since_time.to_rfc3339()
))
.output();

Expand All @@ -313,7 +311,7 @@ where

state
.zip_writer
.write(&output)
.write_all(&output)
.map_err(|err| Error::from(err.context(ErrorKind::SupportBundle)))?;

state.print_verbose("Got logs for docker");
Expand Down Expand Up @@ -341,7 +339,7 @@ where

state
.zip_writer
.write(&check.stdout)
.write_all(&check.stdout)
.map_err(|err| Error::from(err.context(ErrorKind::SupportBundle)))?;

state.print_verbose("Wrote check output to file");
Expand Down Expand Up @@ -392,7 +390,7 @@ where

state
.zip_writer
.write(&output)
.write_all(&output)
.map_err(|err| Error::from(err.context(ErrorKind::SupportBundle)))?;

state.print_verbose(&format!("Got docker inspect for {}", module_name));
Expand Down Expand Up @@ -474,7 +472,7 @@ where

state
.zip_writer
.write(&output)
.write_all(&output)
.map_err(|err| Error::from(err.context(ErrorKind::SupportBundle)))?;

state.print_verbose(&format!("Got docker network inspect for {}", network_name));
Expand Down

0 comments on commit a8f0f62

Please sign in to comment.