wangyang0918 commented on a change in pull request #13644:
URL: https://github.com/apache/flink/pull/13644#discussion_r507380643
##########
File path:
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/utils/KubernetesUtils.java
##########
@@ -106,13 +110,37 @@ public static String getDeploymentName(String clusterId) {
* @return Task manager labels.
*/
public static Map<String, String> getTaskManagerLabels(String
clusterId) {
- final Map<String, String> labels = new HashMap<>();
- labels.put(Constants.LABEL_TYPE_KEY,
Constants.LABEL_TYPE_NATIVE_TYPE);
- labels.put(Constants.LABEL_APP_KEY, clusterId);
+ final Map<String, String> labels = new
HashMap<>(getCommonLabels(clusterId));
labels.put(Constants.LABEL_COMPONENT_KEY,
Constants.LABEL_COMPONENT_TASK_MANAGER);
return Collections.unmodifiableMap(labels);
}
+ /**
+ * Get the common labels for Flink native clusters. All the Kubernetes
resources will be set with these labels.
+ *
+ * @param clusterId cluster id
+ * @return Return common labels map
+ */
+ public static Map<String, String> getCommonLabels(String clusterId) {
+ Map<String, String> commonLabels = new HashMap<>();
+ commonLabels.put(Constants.LABEL_TYPE_KEY,
Constants.LABEL_TYPE_NATIVE_TYPE);
+ commonLabels.put(Constants.LABEL_APP_KEY, clusterId);
+
+ return Collections.unmodifiableMap(commonLabels);
Review comment:
Yes. There's no harm to return a modifiable in the
`KubernetesUtils#getCommonLabels`. For `KubernetesUtils#getTaskManagerLabels`
and `KubernetesUtils#getConfigMapLabels`, we do not want the returned map to be
updated. So we still return a unmodifiable Map.
----------------------------------------------------------------
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]