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/24 07:06:50 UTC

[GitHub] [flink-kubernetes-operator] wangyang0918 opened a new pull request, #181: [FLINK-27358] Fix NPE and avoid unnecessary configmap update

wangyang0918 opened a new pull request, #181:
URL: https://github.com/apache/flink-kubernetes-operator/pull/181

   This PR tries to fix the potential NPE in `deleteJobGraphInKubernetesHA` and avoid the unnecessary ConfigMap update.


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


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

Posted by GitBox <gi...@apache.org>.
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


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

Posted by GitBox <gi...@apache.org>.
wangyang0918 commented on PR #181:
URL: https://github.com/apache/flink-kubernetes-operator/pull/181#issuecomment-1107989903

   Merging now.


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


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

Posted by GitBox <gi...@apache.org>.
Aitozi commented on code in PR #181:
URL: https://github.com/apache/flink-kubernetes-operator/pull/181#discussion_r857214425


##########
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:
   Oh, yes. I misunderstand it, I ignore that it's in a loop :( .     +1 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-unsubscribe@flink.apache.org

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


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

Posted by GitBox <gi...@apache.org>.
Aitozi commented on code in PR #181:
URL: https://github.com/apache/flink-kubernetes-operator/pull/181#discussion_r857102946


##########
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:
   nit: It seems we can directly assign to `shouldUpdate` here ? 



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


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

Posted by GitBox <gi...@apache.org>.
wangyang0918 commented on PR #181:
URL: https://github.com/apache/flink-kubernetes-operator/pull/181#issuecomment-1107796757

   cc @gyfora @Aitozi Could you like have a look on this PR?


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


[GitHub] [flink-kubernetes-operator] wangyang0918 merged pull request #181: [FLINK-27358] Fix NPE and avoid unnecessary configmap update

Posted by GitBox <gi...@apache.org>.
wangyang0918 merged PR #181:
URL: https://github.com/apache/flink-kubernetes-operator/pull/181


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


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

Posted by GitBox <gi...@apache.org>.
Aitozi commented on code in PR #181:
URL: https://github.com/apache/flink-kubernetes-operator/pull/181#discussion_r857102946


##########
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:
   nit: It seems we can directly use `shouldUpdate` here ? 



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


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

Posted by GitBox <gi...@apache.org>.
wangyang0918 commented on code in PR #181:
URL: https://github.com/apache/flink-kubernetes-operator/pull/181#discussion_r857215453


##########
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:
   Thanks for the confirmation.



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