Skip to content

Commit

Permalink
fix: update meta DB state even on factory failure (#332)
Browse files Browse the repository at this point in the history
  • Loading branch information
brokad authored Sep 9, 2022
1 parent a1ef6b7 commit 94c0878
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions api/src/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,24 @@ impl Deployment {
meta.project.clone(),
);
let addr = SocketAddr::new(Ipv4Addr::LOCALHOST.into(), port);
match loader.load(&mut factory, addr, run_logs_tx, meta.id).await {

let load_result = loader.load(&mut factory, addr, run_logs_tx, meta.id).await;

// Even in case `load_result.is_err()`, we want to
// make sure `self.meta` reflects the latest of
// the state that was achieved through the
// phase. Otherwise we end up in a situation where
// a DB was provisioned, but the `meta` does not
// know about it.
self.meta.write().await.database_deployment = factory.into_database_info();

match load_result {
Err(e) => {
debug!("{}: factory phase FAILED: {:?}", meta.project, e);
DeploymentState::Error(e.into())
}
Ok((handle, so)) => {
debug!("{}: factory phase DONE", meta.project);
self.meta.write().await.database_deployment =
factory.into_database_info();

// Remove stale active deployments
if let Some(stale_id) = context.router.promote(meta.host, meta.id).await
{
Expand Down

0 comments on commit 94c0878

Please sign in to comment.