gyfora commented on code in PR #633:
URL:
https://github.com/apache/flink-kubernetes-operator/pull/633#discussion_r1266825520
##########
flink-kubernetes-operator-autoscaler/src/main/java/org/apache/flink/kubernetes/operator/autoscaler/JobAutoScalerImpl.java:
##########
@@ -69,19 +72,45 @@ public JobAutoScalerImpl(
this.evaluator = evaluator;
this.scalingExecutor = scalingExecutor;
this.eventRecorder = eventRecorder;
+ this.infoManager = new AutoscalerInfoManager(kubernetesClient);
}
@Override
- public void cleanup(AbstractFlinkResource<?, ?> cr) {
+ public void cleanup(FlinkResourceContext<?> ctx) {
LOG.info("Cleaning up autoscaling meta data");
+ var cr = ctx.getResource();
metricsCollector.cleanup(cr);
var resourceId = ResourceID.fromResource(cr);
lastEvaluatedMetrics.remove(resourceId);
flinkMetrics.remove(resourceId);
+ infoManager.removeInfoFromCache(cr);
}
@Override
- public boolean scale(FlinkResourceContext<? extends
AbstractFlinkResource<?, ?>> ctx) {
+ public Map<String, String> getParallelismOverrides(FlinkResourceContext<?>
ctx) {
+ var conf = ctx.getObserveConfig();
+ try {
+ var infoOpt = infoManager.getInfo(ctx.getResource());
+ if (infoOpt.isPresent()) {
+ var info = infoOpt.get();
+ // If autoscaler/scaling was disabled after enabling, we need
to delete the
+ // overrides
+ if (!conf.getBoolean(AUTOSCALER_ENABLED)
+ ||
!conf.getBoolean(AutoScalerOptions.SCALING_ENABLED)) {
+ info.removeCurrentOverrides();
Review Comment:
makes sense, I will change 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]