retry app config update on app deployment

This commit is contained in:
Noor 2025-03-20 03:20:13 +05:30
parent 0a53aebcdb
commit a0bc0958fc
Signed by: noormohammedb
GPG Key ID: D83EFB8B3B967146
4 changed files with 19 additions and 4 deletions

12
Cargo.lock generated

@ -1058,6 +1058,7 @@ dependencies = [
"rand",
"rand_core",
"reqwest",
"retry",
"rustls",
"serde",
"serde_json",
@ -2755,6 +2756,15 @@ dependencies = [
"windows-registry",
]
[[package]]
name = "retry"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9166d72162de3575f950507683fac47e30f6f2c3836b71b7fbc61aa517c9c5f4"
dependencies = [
"rand",
]
[[package]]
name = "rfc6979"
version = "0.4.0"
@ -3356,7 +3366,7 @@ dependencies = [
"getrandom 0.3.1",
"once_cell",
"rustix",
"windows-sys 0.52.0",
"windows-sys 0.59.0",
]
[[package]]

@ -31,6 +31,7 @@ rustls = "0.23.23"
tower = "0.5.2"
hyper-rustls = { version = "0.27.5", features = ["http2"] }
openssl = { version = "0.10.71", features = ["vendored"] }
retry = "2.0.0"
detee-sgx = { git = "ssh://git@gitea.detee.cloud/testnet/detee-sgx.git", branch = "hratls", features=["hratls", "qvl"] }
detee-shared = { git = "ssh://git@gitea.detee.cloud/testnet/proto.git", branch = "main" }

@ -9,6 +9,8 @@ use crate::{cli_print, SimpleOutput};
use clap::ArgMatches;
use detee_shared::sgx::types::brain::AppDeployConfig;
use detee_shared::sgx::types::brain::Resource;
use retry::delay::Fixed;
use retry::retry;
use super::grpc_brain::list_apps;
use super::{get_app_node, AppContract, AppDeployResponse};
@ -104,8 +106,10 @@ fn handle_deploy(
match block_on(new_app(app_deploy_config)) {
Ok(new_app_res) if new_app_res.error == "" => {
println!("Deploying...");
std::thread::sleep(std::time::Duration::from_secs(8));
block_on(attest_and_send_config(launch_config, &new_app_res.uuid))?;
std::thread::sleep(std::time::Duration::from_millis(3100));
retry(Fixed::from_millis(500).take(4), || {
block_on(attest_and_send_config(launch_config.clone(), &new_app_res.uuid))
})?;
Ok(new_app_res.into())
}
Ok(new_app_res) => Err(Box::new(std::io::Error::other(new_app_res.error))),

@ -16,7 +16,7 @@ use crate::{config::Config, utils::hratls_url_and_mr_enclave_from_app_id};
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("Failed to connect to the brain: {0}")]
#[error("Failed to connect to the dtpm: {0}")]
BrainConnection(#[from] tonic::transport::Error),
#[error("Received error from dtpm: {}", _0.message())]
ResponseStatus(#[from] tonic::Status),