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 8f135c8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions command/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,18 @@ 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(|id, _| id != cluster_id);

self.backends.retain(|id, _| id != cluster_id);

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

0 comments on commit 8f135c8

Please sign in to comment.