Skip to content

Replace StatsUpdater with multi-cluster aware ClusterHealthManager #374

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

joncombe
Copy link
Collaborator

@joncombe joncombe commented May 30, 2025

Summary of changes

☝️ In short, the old StatsUpdater worked, but was only aware of one cluster. This means when used in cloud-ui, and switching between clusters, cluster A's stats were mixed with cluster B's meaning none of the numbers are correct.

  • Actually, I don't think this goes far enough, because when we switch clusters in cloud-ui, it will stop polling the "unfocused" cluster. Perhaps we could have the component poll all the clusters the org has access to. A subject for a future ticket, however.
  • Using these stats, we could discard all the old API polling used in cloud-ui today. Stats would require the cluster being JWT compatible, however.
  • There are no tests for ClusterHealthManager but there were none for StatsUpdater either. I think writing tests here will be very difficult as the component exports zero output. I am happy to try but I am not sure it is worth the effort at this time.

Checklist

  • Link to issue this PR refers to: https://github.com/crate/cloud/issues/2260
  • Relevant changes are reflected in CHANGES.md.
  • Added or changed code is covered by tests.
  • Required Grand Central APIs are already merged.

@joncombe joncombe requested a review from alexdametto as a code owner May 30, 2025 11:37
@joncombe
Copy link
Collaborator Author

I see tests are failing. I don't have time to fix those today. @alexdametto as you are away on Monday, please sanity check this PR today if you have time so I can fix up the tests and any issues you find on Monday. Thank you.

Copy link
Collaborator

@alexdametto alexdametto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a couple of small proposals, nothing crazy 😁

@@ -39,7 +40,7 @@ function App() {

return (
<GcAdminAntdProvider>
<StatsUpdater />
<ClusterHealthManager clusterId="" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here you are missing the clusterId prop.

Note: another approach could be removing the parameter into the component and the component can get the cluster id from the context itself. Fine for me both ways.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh but maybe the clusterId prop is needed in cloud-ui to allow pre-fetch / multiple clusters, in that case ignore the comment above

const { data: nodes } = useClusterNodeStatus(clusterId);
const [prevNodeData, setPrevNodesData] = useState<NodeStatusInfo[] | []>();

const getFs = (nodes: NodeStatusInfo[]): { [key: string]: FSStats } => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that

Suggested change
const getFs = (nodes: NodeStatusInfo[]): { [key: string]: FSStats } => {
const getFs = (nodes: NodeStatusInfo[]): Record<string, FSStats> => {

is more readable

fsStats: { [key: string]: FSStats };

// health
clusterHealth: { [clusterId: string]: ClusterHealth };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
clusterHealth: { [clusterId: string]: ClusterHealth };
clusterHealth: Record<string, ClusterHealth>;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants