tillrohrmann commented on a change in pull request #14629:
URL: https://github.com/apache/flink/pull/14629#discussion_r584550780



##########
File path: 
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/utils/KubernetesUtils.java
##########
@@ -431,6 +435,61 @@ public static File getTaskManagerPodTemplateFileInPod() {
                 Constants.POD_TEMPLATE_DIR_IN_POD, 
Constants.TASK_MANAGER_POD_TEMPLATE_FILE_NAME);
     }
 
+    /**
+     * Resolve the user defined value with the precedence. First an explicit 
config option value is
+     * taken, then the value in pod template and at last the default value of 
a config option if
+     * nothing is specified.
+     *
+     * @param flinkConfig flink configuration
+     * @param configOption the config option to define the Kubernetes fields
+     * @param valueOfConfigOptionOrDefault the value defined by explicit 
config option or default
+     * @param valueOfPodTemplate the value defined in the pod template
+     * @param fieldDescription Kubernetes fields description
+     * @param <T> The type of value associated with the configuration option.
+     * @return the resolved value
+     */
+    public static <T> String resolveUserDefinedValue(
+            Configuration flinkConfig,
+            ConfigOption<T> configOption,
+            String valueOfConfigOptionOrDefault,
+            @Nullable String valueOfPodTemplate,
+            String fieldDescription) {
+        final String resolvedValue;
+        if (valueOfPodTemplate != null) {
+            // The config option is explicitly set.
+            if (flinkConfig.contains(configOption)) {
+                resolvedValue = valueOfConfigOptionOrDefault;
+                LOG.info(
+                        "The {} configured in pod template will be overwritten 
to '{}' "
+                                + "because of explicitly configured options.",
+                        fieldDescription,
+                        resolvedValue);
+            } else {
+                resolvedValue = valueOfPodTemplate;
+            }
+        } else {
+            resolvedValue = valueOfConfigOptionOrDefault;
+        }
+        return resolvedValue;
+    }
+
+    /**
+     * Get the service account from the input pod first, if not specified, the 
service account name
+     * will be used.

Review comment:
       What is the difference between service account and service account name?




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to