Skip to content

Commit e154511

Browse files
committed
fix: Work around lack of idempotency in IP allocation API
1 parent fce7486 commit e154511

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

  • workflow/deployer-workflow/impl-flyio/src

workflow/deployer-workflow/impl-flyio/src/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,15 @@ fn allocate_ip(app_name: &str) -> Result<(), AppInitModifyError> {
5858
},
5959
)
6060
.map(|_ip| ())
61-
.map_err(AppInitModifyError::IpAllocateError)
61+
.map_err(AppInitModifyError::IpAllocateError)?;
62+
// Since this API is not idempotent, make sure just one IP has been allocated.
63+
let ips =
64+
activity_fly_http::ips::list(app_name).map_err(AppInitModifyError::IpAllocateError)?;
65+
for ip_detail in ips.into_iter().skip(1) {
66+
activity_fly_http::ips::release(app_name, &ip_detail.ip)
67+
.map_err(AppInitModifyError::IpAllocateError)?;
68+
}
69+
Ok(())
6270
}
6371

6472
fn setup_volume(app_name: &str, obelisk_toml: &str) -> Result<(), AppInitModifyError> {

0 commit comments

Comments
 (0)