1996fanrui commented on code in PR #710:
URL: 
https://github.com/apache/flink-kubernetes-operator/pull/710#discussion_r1391256838


##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/autoscaler/ConfigMapStore.java:
##########
@@ -67,19 +67,14 @@ protected Optional<String> getSerializedState(
     }
 
     protected void removeSerializedState(KubernetesJobAutoScalerContext 
jobContext, String key) {
-        getConfigMap(jobContext)
-                .ifPresentOrElse(
-                        configMap -> configMap.getData().remove(key),
-                        () -> {
-                            throw new IllegalStateException(
-                                    "The configMap isn't created, so the 
remove is unavailable.");
-                        });
+        getConfigMap(jobContext).ifPresent(configMap -> 
configMap.getData().remove(key));
     }
 
     public void flush(KubernetesJobAutoScalerContext jobContext) {
         Optional<ConfigMap> configMapOpt = cache.get(jobContext.getJobKey());
         if (configMapOpt == null || configMapOpt.isEmpty()) {
             LOG.debug("The configMap isn't updated, so skip the flush.");
+            // Do not flush if there are no updates.

Review Comment:
   We may need to added an extra cache to store the state that last updated. 
When the flush is called, then compare them. And call kubernetes if they are 
not same.
   
   And it's better to add a test to check the flush doesn't call kubernetes if 
state isn't updated.
   
   Also, I'm not sure whether this PR is reasonable. After this refactor, the 
clean up logic is indeed clear. However, these complex operations are moved 
into state store. When we implememt other persistent state stores in the 
future, we still need to re-implememt this similar logic again. 
   
   If this logic can be retained in autoscaler, only one code is fine.
   
   Please correct me if I miss some information, thanks



-- 
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]

Reply via email to