Skip to content

Commit

Permalink
delete frontends and backends when deleting the parent cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
Keksoj committed Sep 22, 2023
1 parent 386446f commit a550eda
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions command/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,22 @@ impl ConfigState {
Ok(())
}

/// Remove a cluster and all its children (frontends and backends)
fn remove_cluster(&mut self, cluster_id: &str) -> Result<(), StateError> {
self.http_fronts
.retain(|_, front| front.cluster_id != cluster_id);

self.https_fronts
.retain(|_, front| front.cluster_id != cluster_id);

self.tcp_fronts.retain(|_, fronts| {
!fronts
.iter()
.map(|f| f.cluster_id == cluster_id)
.collect::<Vec<bool>>()
.contains(&true)
});

match self.clusters.remove(cluster_id) {
Some(_) => Ok(()),
None => Err(StateError::NotFound {
Expand Down

0 comments on commit a550eda

Please sign in to comment.