mbalassi commented on code in PR #558: URL: https://github.com/apache/flink-kubernetes-operator/pull/558#discussion_r1155589002
########## flink-kubernetes-operator/src/test/java/org/apache/flink/kubernetes/operator/metrics/FlinkDeploymentMetricsTest.java: ########## @@ -187,6 +193,66 @@ public void testMetricsMultiNamespace() { } } + @Test + public void testResourceMetrics() { + var namespace1 = "ns1"; + var namespace2 = "ns2"; + var deployment1 = TestUtils.buildApplicationCluster("deployment1", namespace1); + var deployment2 = TestUtils.buildApplicationCluster("deployment2", namespace1); + var deployment3 = TestUtils.buildApplicationCluster("deployment3", namespace2); + + deployment1 + .getStatus() + .getClusterInfo() + .putAll( + Map.of( + AbstractFlinkService.FIELD_NAME_TOTAL_CPU, "5", Review Comment: Could you please add a test that has unexpected values (null, empty string etc) - given that the status field could be (but not expected to be) modified externally we want to make sure that the operator logic does not fail on that (This is why I used `NumberUtils` in the implementation). ########## flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/service/AbstractFlinkService.java: ########## @@ -645,10 +641,19 @@ public Map<String, String> getClusterInfo(Configuration conf) throws Exception { dashboardConfiguration.getFlinkRevision()); } - // JobManager resource usage can be deduced from the CR - var jmParameters = - new KubernetesJobManagerParameters( - conf, new KubernetesClusterClientFactory().getClusterSpecification(conf)); + clusterInfo.putAll( + calculateClusterResourceMetrics( + conf, getTaskManagersInfo(conf).getTaskManagerInfos().size())); + + return clusterInfo; + } + + private HashMap<String, String> calculateClusterResourceMetrics( Review Comment: nit: maybe call this `calculateClusterResourceUsage` or `calculateClusterResourceFootprint`, since technically not the metrics yet. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org