Skip to content

Commit 6ab01c6

Browse files
authored
remove extra logs from cli (#659)
1 parent aec1371 commit 6ab01c6

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

cli/src/main.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,18 @@ async fn main() -> Result<()> {
120120
let state = get_world_state(nats.clone()).await?;
121121
let stream = nats.jetstream.get_stream("plane_state").await.unwrap();
122122

123+
let mut removed_backends = 0;
124+
123125
for (cluster_name, cluster) in &state.clusters {
124126
for (backend_id, backend) in &cluster.backends {
125127
if let Some((timestamp, state)) = backend.state_timestamp() {
126128
if state.terminal() {
127-
println!(
128-
"Removing backend {} from cluster {}, {} at {}",
129-
backend_id, cluster_name, state, timestamp
130-
);
129+
if dry_run {
130+
println!(
131+
"Would remove backend {} from cluster {}, {} at {}",
132+
backend_id, cluster_name, state, timestamp
133+
);
134+
}
131135
} else if timestamp < chrono::Utc::now() - chrono::Duration::hours(24)
132136
&& (state != BackendState::Ready)
133137
{
@@ -162,7 +166,7 @@ async fn main() -> Result<()> {
162166
if dry_run {
163167
println!("Would purge {:?}", subjects);
164168
} else {
165-
println!("Purging {:?}", subjects);
169+
removed_backends += 1;
166170

167171
for subject in subjects.iter() {
168172
stream.purge().filter(subject).await.unwrap();
@@ -175,6 +179,12 @@ async fn main() -> Result<()> {
175179
}
176180
}
177181
}
182+
183+
if dry_run {
184+
println!("Would have removed {} backends", removed_backends);
185+
} else {
186+
println!("Removed {} backends", removed_backends);
187+
}
178188
}
179189
Command::DumpState => {
180190
let state = get_world_state(nats.clone()).await?;

0 commit comments

Comments
 (0)