gyfora commented on code in PR #677: URL: https://github.com/apache/flink-kubernetes-operator/pull/677#discussion_r1354365364
########## flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/controller/FlinkResourceContext.java: ########## @@ -47,6 +55,48 @@ public abstract class FlinkResourceContext<CR extends AbstractFlinkResource<?, ? private FlinkOperatorConfiguration operatorConfig; private Configuration observeConfig; private FlinkService flinkService; + private KubernetesJobAutoScalerContext autoScalerContext; + + public KubernetesJobAutoScalerContext getJobAutoScalerContext() { + if (autoScalerContext != null) { + return autoScalerContext; + } + return autoScalerContext = createJobAutoScalerContext(); + } + + private KubernetesJobAutoScalerContext createJobAutoScalerContext() { + Configuration conf = new Configuration(getObserveConfig()); + conf.set( + AutoScalerOptions.FLINK_CLIENT_TIMEOUT, + getOperatorConfig().getFlinkClientTimeout()); + + CommonStatus<?> status = getResource().getStatus(); + String jobId = status.getJobStatus().getJobId(); + + JobStatus jobStatus = generateJobStatusEnum(status); + + return new KubernetesJobAutoScalerContext( + jobId == null ? null : JobID.fromHexString(jobId), + jobStatus, + conf, + getResourceMetricGroup(), + () -> getFlinkService().getClusterClient(conf), + resource, + getKubernetesClient()); + } + + @Nullable + private JobStatus generateJobStatusEnum(CommonStatus<?> status) { + if (status.getLifecycleState() != ResourceLifecycleState.STABLE) { + return null; + } + + String state = status.getJobStatus().getState(); + if (state == null) { + return null; + } + return JobStatus.valueOf(state); Review Comment: Let's not change this as part of this PR but feel free to open a JIRA for this -- 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