Skip to content
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
38 changes: 19 additions & 19 deletions src/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,25 +93,19 @@ impl Cluster {
}

pub async fn main_loop(self: Arc<Self>) {
if self.args.manage_resources {
if self.failover {
let futures: Vec<_> = self.hosts.values().map(|h| h.manage_ha(&self)).collect();
if self.failover {
let futures: Vec<_> = self.hosts.values().map(|h| h.manage_ha(&self)).collect();

let _ = future::join_all(futures).await;
} else {
let futures: Vec<_> = self.hosts.values().map(|h| h.manage(&self)).collect();

let _ = future::join_all(futures).await;
}
} else if self.failover {
let futures: Vec<_> = self.hosts.values().map(|h| h.observe_ha(&self)).collect();
let _ = future::join_all(futures).await;
} else if self.args.manage_resources {
let futures: Vec<_> = self.hosts.values().map(|h| h.manage(&self)).collect();

let _ = future::join_all(futures).await;
} else {
let futures: Vec<_> = self.hosts.values().map(|h| h.observe(&self)).collect();

let _ = future::join_all(futures).await;
};
}
}

pub fn resource_groups(&self) -> impl Iterator<Item = &ResourceGroup> {
Expand Down Expand Up @@ -260,6 +254,13 @@ impl Cluster {

new.apply_state();

// If the cluster is running in "observe-only" mode, mark every resource group as unmanaged
if !args.manage_resources {
for rg in new.resource_groups() {
rg.set_managed(false);
}
}

Ok(new)
}

Expand Down Expand Up @@ -306,7 +307,9 @@ impl Cluster {
)
})
.collect();
Resource::from_config(self.me, dependents, host, failover_host, self.id, args)
Resource::from_config(
self.me, dependents, /*host, failover_host,*/ self.id, args,
)
}
}

Expand Down Expand Up @@ -366,7 +369,7 @@ impl Cluster {
failover_host.clone(),
args.clone(),
);
ResourceGroup::new(root, args.clone())
ResourceGroup::new(root, args.clone(), Arc::clone(&host), failover_host.clone())
})
.collect()
}
Expand All @@ -387,14 +390,11 @@ impl Cluster {
pub fn print_summary(&self) {
println!("=== Resource Groups ===");
for rg in &self.resource_groups {
println!("\thome node: {}", rg.home_node().id());
println!("\tfailover node: {:?}", rg.failover_node().map(|h| h.id()));
for res in rg.resources() {
print!("{}: ", res.id);
println!("{}", res.params_string());
println!("\thome node: {}", res.home_node.id());
println!(
"\tfailover node: {:?}",
res.failover_node.as_ref().map(|h| h.id())
);
}
}

Expand Down
Loading
Loading