Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MULTI-315: Add canary rollbacks #42

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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