MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / execute_docker_command

Method execute_docker_command

src/mz-debug/src/docker_dumper.rs:46–81  ·  view source on GitHub ↗

Execute a Docker command and return (stdout, stderr).

(
        &self,
        args: &[String],
    )

Source from the content-addressed store, hash-verified

44
45 /// Execute a Docker command and return (stdout, stderr).
46 async fn execute_docker_command(
47 &self,
48 args: &[String],
49 ) -> Result<(Vec<u8>, Vec<u8>), anyhow::Error> {
50 retry::Retry::default()
51 .max_duration(DOCKER_RESOURCE_DUMP_TIMEOUT)
52 .retry_async(|_| {
53 let args = args.to_vec();
54 async move {
55 let output = tokio::process::Command::new("docker")
56 .args(&args)
57 .output()
58 .await;
59
60 match output {
61 Ok(output) if output.status.success() => {
62 RetryResult::Ok((output.stdout, output.stderr))
63 }
64 Ok(output) => {
65 let err_msg = format!(
66 "Docker command failed: {:#}. Retrying...",
67 String::from_utf8_lossy(&output.stderr)
68 );
69 warn!("{}", err_msg);
70 RetryResult::RetryableErr(anyhow::anyhow!(err_msg))
71 }
72 Err(err) => {
73 let err_msg = format!("Failed to execute Docker command: {:#}", err);
74 warn!("{}", err_msg);
75 RetryResult::RetryableErr(anyhow::anyhow!(err_msg))
76 }
77 }
78 }
79 })
80 .await
81 }
82
83 async fn dump_logs(&self) -> Result<(), anyhow::Error> {
84 let (stdout, stderr) = self

Callers 4

dump_logsMethod · 0.80
dump_inspectMethod · 0.80
dump_statsMethod · 0.80
dump_topMethod · 0.80

Calls 6

retry_asyncMethod · 0.80
max_durationMethod · 0.80
to_vecMethod · 0.80
outputMethod · 0.80
successMethod · 0.80
argsMethod · 0.45

Tested by

no test coverage detected