feat: adding more logs to docker push

This commit is contained in:
Pierre Mavro
2021-05-05 12:07:41 +02:00
committed by Pierre Mavro
parent 351f34970d
commit 9cd10a6512
3 changed files with 22 additions and 7 deletions

4
Cargo.lock generated
View File

@@ -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",
]

View File

@@ -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"

View File

@@ -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,