-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add a new cluster state "Unhealthy" #63
base: main
Are you sure you want to change the base?
Changes from 10 commits
211be1e
28c220a
f6e5e75
1585b1e
76a29ea
800db29
b795fca
907cbf3
7d3f518
78f47ec
a9726af
5e5b022
5c8051e
373ab07
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,11 +136,7 @@ impl QueryCountFetcher { | |
self.clusters | ||
.iter() | ||
.zip(cluster_states) | ||
.filter_map(|(cluster, state)| match state{ | ||
ClusterState::Unknown | ClusterState::Stopped | ClusterState::Starting | ClusterState::Terminating | ClusterState::Deactivated => None, | ||
ClusterState::Ready | ClusterState::Draining{ .. } => Some(cluster), | ||
}) | ||
.map(|cluster| self.process_cluster(cluster)), | ||
.map(|(cluster, state)| self.process_cluster(cluster, state)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: It seems like we are not actually mapping anything here. Does it maybe make more sense to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope, as we are using https://docs.rs/futures/latest/futures/future/fn.join_all.html here
We could do some things around Not sure if that's worth it |
||
) | ||
.await; | ||
|
||
|
@@ -152,8 +148,34 @@ impl QueryCountFetcher { | |
} | ||
} | ||
|
||
#[instrument(skip(self))] | ||
async fn process_cluster(&self, cluster: &TrinoClusterConfig) { | ||
#[instrument(skip(self, cluster), fields(cluster_name = cluster.name))] | ||
async fn process_cluster(&self, cluster: &TrinoClusterConfig, state: ClusterState) { | ||
Comment on lines
+157
to
+158
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: You should add a small doc comment explaining what this method does. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added in 373ab07 |
||
match state { | ||
ClusterState::Ready | ClusterState::Unhealthy | ClusterState::Draining { .. } => { | ||
self.fetch_and_store_query_count(cluster).await; | ||
} | ||
ClusterState::Unknown | ||
| ClusterState::Stopped | ||
| ClusterState::Starting | ||
| ClusterState::Terminating | ||
| ClusterState::Deactivated => { | ||
if let Err(err) = self | ||
.persistence | ||
.set_cluster_query_count(&cluster.name, 0) | ||
.await | ||
Comment on lines
+168
to
+171
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: Why exactly do we set the number of queries to zero here? Can you add a developer comment here which shortly explains it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added some rustdoc in 373ab07 explaining it. Is that sufficient in this case here? |
||
{ | ||
error!( | ||
cluster = cluster.name, | ||
?err, | ||
"QueryCountFetcher: Failed to set current cluster query count to zero" | ||
); | ||
} | ||
} | ||
} | ||
} | ||
|
||
#[instrument(skip(self, cluster), fields(cluster_name = cluster.name))] | ||
async fn fetch_and_store_query_count(&self, cluster: &TrinoClusterConfig) { | ||
let cluster_info = | ||
get_cluster_info(&cluster.endpoint, self.ignore_certs, &cluster.credentials).await; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: I don't quite understand the sentence in line 15. It is either wrong, or worded weirdly.
note: markdownlint complains about the
<br />
tag. I think we should remove it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, there was a typo: a9726af
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL a backslash also works: 5e5b022