From 9cd10a6512483db1464cd57bdbeb7193e57ca83f Mon Sep 17 00:00:00 2001 From: Pierre Mavro Date: Wed, 5 May 2021 12:07:41 +0200 Subject: [PATCH] feat: adding more logs to docker push --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- src/container_registry/utilities.rs | 23 +++++++++++++++++++---- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1a8e176a..43326529 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2298,9 +2298,9 @@ dependencies = [ [[package]] name = "retry" -version = "1.1.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddadf3a46af916aa0fe6b8283e676b6bb5cbdf835d986d98a49d7345072341e5" +checksum = "d0ee4a654b43dd7e3768be7a1c0fc20e90f0a84b72a60ffb6c11e1cae2545c2e" dependencies = [ "rand 0.7.3", ] diff --git a/Cargo.toml b/Cargo.toml index b9f8d8d6..56af6c68 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ itertools = "0.9.0" base64 = "0.12.3" dirs = "3.0.1" rust-crypto = "0.2.36" -retry = "1.0.0" +retry = "1.2.1" trust-dns-resolver = "0.19.6" rand = "0.7.3" gethostname = "0.2.1" diff --git a/src/container_registry/utilities.rs b/src/container_registry/utilities.rs index 2f467c9f..f404a21e 100644 --- a/src/container_registry/utilities.rs +++ b/src/container_registry/utilities.rs @@ -1,6 +1,7 @@ use crate::cmd; use crate::container_registry::Kind; use crate::error::{SimpleError, SimpleErrorKind}; +use chrono::Duration; use retry::delay::Fibonacci; use retry::Error::Operation; use retry::OperationResult; @@ -37,8 +38,22 @@ pub fn docker_tag_and_push_image( _ => {} } - match retry::retry(Fibonacci::from_millis(5000).take(5), || { - match cmd::utilities::exec("docker", vec!["push", dest.as_str()], &docker_envs) { + match retry::retry( + Fibonacci::from_millis(5000).take(5), + || match cmd::utilities::exec_with_envs_and_output( + "docker", + vec!["push", dest.as_str()], + docker_envs.clone(), + |line| { + let line_string = line.unwrap_or_default(); + info!("{}", line_string.as_str()); + }, + |line| { + let line_string = line.unwrap_or_default(); + error!("{}", line_string.as_str()); + }, + Duration::minutes(10), + ) { Ok(_) => OperationResult::Ok(()), Err(e) => { warn!( @@ -47,8 +62,8 @@ pub fn docker_tag_and_push_image( ); OperationResult::Retry(e) } - } - }) { + }, + ) { Err(Operation { error, .. }) => Err(error), Err(e) => Err(SimpleError::new( SimpleErrorKind::Other,