Skip to content

Commit

Permalink
Merge pull request #42 from wack/eric/multi-315-v2
Browse files Browse the repository at this point in the history
MULTI-315: Add canary rollbacks
  • Loading branch information
EricGhildyal authored Nov 26, 2024
2 parents b03e917 + d824af1 commit 6c4aeb1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
28 changes: 28 additions & 0 deletions src/adapters/ingresses/apig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,27 @@ impl AwsApiGateway {

Ok(())
}

async fn delete_canary(&self, api_name: &str, stage_name: &str) -> Result<()> {
let api = self.get_api_id_by_name(api_name).await?;

// Updates the stage to delete any canary settings from the API Gateway
let patch_op = PatchOperation::builder()
.op(Op::Remove)
.path("/canarySettings")
.build();

self.apig_client
.update_stage()
.rest_api_id(api.id.unwrap_or_default())
.stage_name(stage_name)
.patch_operations(patch_op)
.send()
.await
.into_diagnostic()?;

Ok(())
}
}

/// given a path to a file, load it as an array of bytes.
Expand Down Expand Up @@ -200,4 +221,11 @@ impl Ingress for AwsApiGateway {

Ok(())
}

async fn rollback_canary(&mut self) -> Result<()> {
self.delete_canary(&self.gateway_name, &self.stage_name)
.await?;

Ok(())
}
}
6 changes: 5 additions & 1 deletion src/adapters/ingresses/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub trait Ingress {
async fn deploy(&mut self) -> Result<()>;

// TODO: define the other methods on this type.
// async fn yank_canary(&mut self) -> Result<()>;
async fn rollback_canary(&mut self) -> Result<()>;
// async fn promote_canary(&mut self) -> Result<()>;
async fn set_canary_traffic(&mut self, percent: WholePercent) -> Result<()>;
}
Expand All @@ -29,6 +29,10 @@ impl Ingress for MockIngress {
async fn set_canary_traffic(&mut self, _percent: WholePercent) -> Result<()> {
todo!()
}

async fn rollback_canary(&mut self) -> Result<()> {
todo!()
}
}

impl From<MockIngress> for BoxIngress {
Expand Down

0 comments on commit 6c4aeb1

Please sign in to comment.