You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/04/25 02:00:30 UTC

[GitHub] [flink-kubernetes-operator] wangyang0918 commented on a diff in pull request #181: [FLINK-27358] Fix NPE and avoid unnecessary configmap update

wangyang0918 commented on code in PR #181:
URL: https://github.com/apache/flink-kubernetes-operator/pull/181#discussion_r857213487


##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/utils/FlinkUtils.java:
##########
@@ -243,22 +244,21 @@ public static void deleteJobGraphInKubernetesHA(
                         .withLabels(haConfigMapLabels)
                         .list();
 
-        configMaps
-                .getItems()
-                .forEach(
-                        configMap -> {
-                            final boolean isDeleted =
-                                    configMap
-                                            .getData()
-                                            .entrySet()
-                                            .removeIf(FlinkUtils::isJobGraphKey);
-                            if (isDeleted) {
-                                LOG.info(
-                                        "Job graph in ConfigMap {} is deleted",
-                                        configMap.getMetadata().getName());
-                            }
-                        });
-        kubernetesClient.resourceList(configMaps).inNamespace(namespace).createOrReplace();
+        boolean shouldUpdate = false;
+        for (ConfigMap configMap : configMaps.getItems()) {
+            if (configMap.getData() == null || configMap.getData().isEmpty()) {
+                continue;
+            }
+            final boolean isDeleted =

Review Comment:
   I am afraid we could not set `shouldUpdate` here since it might be overridden to false by subsequent loop wrongly.
   
   BTW, the reason why I do not break the loop when `isDeleted` is true is we could have more than one ConfigMaps need to remove jobgraph when upgrading Flink version from 1.14 to 1.15.
   
   WDYT?



-- 
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-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org