mateczagany commented on code in PR #558: URL: https://github.com/apache/flink-kubernetes-operator/pull/558#discussion_r1154613982
########## flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/service/AbstractFlinkService.java: ########## @@ -627,14 +637,42 @@ public Map<String, String> getClusterInfo(Configuration conf) throws Exception { .toSeconds(), TimeUnit.SECONDS); - runtimeVersion.put( + clusterInfo.put( DashboardConfiguration.FIELD_NAME_FLINK_VERSION, dashboardConfiguration.getFlinkVersion()); - runtimeVersion.put( + clusterInfo.put( DashboardConfiguration.FIELD_NAME_FLINK_REVISION, dashboardConfiguration.getFlinkRevision()); } - return runtimeVersion; + + // JobManager resource usage can be deduced from the CR + var jmParameters = + new KubernetesJobManagerParameters( + conf, new KubernetesClusterClientFactory().getClusterSpecification(conf)); + var jmTotalCpu = + jmParameters.getJobManagerCPU() + * jmParameters.getJobManagerCPULimitFactor() + * jmParameters.getReplicas(); + var jmTotalMemory = + Math.round( + jmParameters.getJobManagerMemoryMB() + * Math.pow(1024, 2) + * jmParameters.getJobManagerMemoryLimitFactor() + * jmParameters.getReplicas()); + + // TaskManager resource usage is best gathered from the REST API to get current replicas Review Comment: I tried to implement the same logic for `tmTotalCpu` as what you did the with `jmTotalCpu`, and I think it should be valid: `tmCpuRequest * tmCpuLimitFactor * numberOfTaskManagers` `tmCpuRequest` and `tmCpuLimitFactor` are accessible the same way as for the JM. Just retrieve `kubernetes.taskmanager.cpu` and `kubernetes.taskmanager.cpu.limit-factor` from the Flink config. I'm not sure about `numberOfTaskManagers`, in my test I just downloaded the number of TMs from the Flink REST API, maybe we could just use `FlinkUtils#getNumTaskManagers` instead. Code: ``` var tmTotalCpu = tmHardwareDesc.get().count() * conf.getDouble(KubernetesConfigOptions.TASK_MANAGER_CPU) * conf.getDouble(KubernetesConfigOptions.TASK_MANAGER_CPU_LIMIT_FACTOR); ``` Limit factors: ``` kubernetes.taskmanager.cpu.limit-factor = 1.3 kubernetes.jobmanager.cpu.limit-factor = 1.3 ``` Result: ``` Job Manager: Replicas: 2 Resource: Cpu: 0.5 Memory: 1g Task Manager: Replicas: 2 Resource: Cpu: 0.5 Memory: 1g Status: Cluster Info: Total - Cpu: 2.6 Total - Memory: 4294967296 ``` Do you think this could work? -- 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