Skip to content

Commit

Permalink
remove extra logs from cli (#659)
Browse files Browse the repository at this point in the history
  • Loading branch information
rolyatmax authored Mar 11, 2024
1 parent aec1371 commit 6ab01c6
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,18 @@ async fn main() -> Result<()> {
let state = get_world_state(nats.clone()).await?;
let stream = nats.jetstream.get_stream("plane_state").await.unwrap();

let mut removed_backends = 0;

for (cluster_name, cluster) in &state.clusters {
for (backend_id, backend) in &cluster.backends {
if let Some((timestamp, state)) = backend.state_timestamp() {
if state.terminal() {
println!(
"Removing backend {} from cluster {}, {} at {}",
backend_id, cluster_name, state, timestamp
);
if dry_run {
println!(
"Would remove backend {} from cluster {}, {} at {}",
backend_id, cluster_name, state, timestamp
);
}
} else if timestamp < chrono::Utc::now() - chrono::Duration::hours(24)
&& (state != BackendState::Ready)
{
Expand Down Expand Up @@ -162,7 +166,7 @@ async fn main() -> Result<()> {
if dry_run {
println!("Would purge {:?}", subjects);
} else {
println!("Purging {:?}", subjects);
removed_backends += 1;

for subject in subjects.iter() {
stream.purge().filter(subject).await.unwrap();
Expand All @@ -175,6 +179,12 @@ async fn main() -> Result<()> {
}
}
}

if dry_run {
println!("Would have removed {} backends", removed_backends);
} else {
println!("Removed {} backends", removed_backends);
}
}
Command::DumpState => {
let state = get_world_state(nats.clone()).await?;
Expand Down

0 comments on commit 6ab01c6

Please sign in to comment.