wangyang0918 commented on a change in pull request #13644:
URL: https://github.com/apache/flink/pull/13644#discussion_r507371480



##########
File path: 
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/kubeclient/Fabric8FlinkKubeClient.java
##########
@@ -219,6 +230,68 @@ public KubernetesWatch watchPodsAndDoCallback(
                                .watch(new 
KubernetesPodsWatcher(podCallbackHandler)));
        }
 
+       @Override
+       public CompletableFuture<Void> createConfigMap(KubernetesConfigMap 
configMap) {
+               return CompletableFuture.runAsync(
+                       () -> {
+                               if 
(!getConfigMap(configMap.getName()).isPresent()) {
+                                       
this.internalClient.configMaps().create(configMap.getInternalResource());
+                               }
+                       },
+                       kubeClientExecutorService);

Review comment:
       Yes. This is already in the plan. I have left a comments on the 
FLINK-19037. I have created a new ticket FLINK-19700 to follow this.

##########
File path: 
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/kubeclient/FlinkKubeClient.java
##########
@@ -104,6 +107,67 @@ KubernetesWatch watchPodsAndDoCallback(
                Map<String, String> labels,
                WatchCallbackHandler<KubernetesPod> podCallbackHandler);
 
+       /**
+        * Create the ConfigMap with specified content. If the ConfigMap 
already exists, nothing will happen.
+        *
+        * @param configMap ConfigMap.
+        *
+        * @return Return the ConfigMap create future.
+        */
+       CompletableFuture<Void> createConfigMap(KubernetesConfigMap configMap);
+
+       /**
+        * Get the ConfigMap with specified name.
+        *
+        * @param name ConfigMap name.
+        *
+        * @return Return empty if the ConfigMap does not exist.
+        */
+       Optional<KubernetesConfigMap> getConfigMap(String name);
+
+       /**
+        * Update an existing ConfigMap with the data.
+        *
+        * @param configMapName ConfigMap to be replaced with. Benefit from <a 
href=https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions>
+        *                      resource version</a> and combined with {@link 
#getConfigMap(String)}, we could perform a get-check-and-update
+        *                      transactional operation. Since concurrent 
modification could happen on a same ConfigMap,
+        *                      the update operation may fail. We need to retry 
internally. The max retry attempts could be
+        *                      configured via {@link 
org.apache.flink.kubernetes.configuration.KubernetesConfigOptions#KUBERNETES_MAX_RETRY_ATTEMPTS}.
+        * @param checker       Only the checker return true, the ConfigMap 
will be updated.
+        * @param function      The obtained ConfigMap will be applied to this 
function and get a new one to replace.
+        *
+        * @return Return the ConfigMap update future.
+        */

Review comment:
       Make sense.




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to