Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ private[spark] class KubernetesDriverConf(

override val resourceNamePrefix: String = {
val custom = if (Utils.isTesting) get(KUBERNETES_DRIVER_POD_NAME_PREFIX) else None
custom.getOrElse(KubernetesConf.getResourceNamePrefix(appName))
val resourceNamePrefix = custom.getOrElse(KubernetesConf.getResourceNamePrefix(appName))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable name is confusing since this is in override val resourceNamePrefix: String = {}.

// If the first character of resourceNamePrefix is number,add the extra prefix : "spark-".
val prefix = "spark-" + resourceNamePrefix.charAt(0)
resourceNamePrefix.replaceAll("^[0-9]", prefix)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, did you run the test locally?

Copy link
Author

@hehuiyuan hehuiyuan Mar 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. For example: resourceNamePrefix = 1min-xxx

After execute this code:

val prefix = "spark-" + resourceNamePrefix.charAt(0) resourceNamePrefix.replaceAll("^[0-9]", prefix)

resourceNamePrefix = spark-1min-xxx,which satisfies the regular expression [a-z]([-a-z0-9]*[a-z0-9])?

  1. For example : resourceNamePrefix = min-xxx

After execute this code:

val prefix = "spark-" + resourceNamePrefix.charAt(0) resourceNamePrefix.replaceAll("^[0-9]", prefix)

resourceNamePrefix = min-xxx,which does not change.

Local testing was done for thisoverride val resourceNamePrefix only.

Copy link
Member

@srowen srowen Mar 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just prepend "spark-" if the first character is a digit? if (Character.isDigit(resourceNamePrefix(0))) But don't you actually need to check if it starts with a-z?

Copy link
Author

@hehuiyuan hehuiyuan Mar 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just prepend "spark-" if the first character is a digit? if (Character.isDigit(resourceNamePrefix(0))) But don't you actually need to check if it starts with a-z?


Hi, this code does not change the resourceNamePrefix that the first character is not a digit.

1: For example: resourceNamePrefix = 1min-xxx
After execute this code:

val prefix = "spark-" + resourceNamePrefix.charAt(0) resourceNamePrefix.replaceAll("^[0-9]", prefix)

resourceNamePrefix = spark-1min-xxx,
which satisfies the regular expression [a-z]([-a-z0-9]*[a-z0-9])?

2 : For example : resourceNamePrefix = min-xxx
After execute this code:

val prefix = "spark-" + resourceNamePrefix.charAt(0) resourceNamePrefix.replaceAll("^[0-9]", prefix)

resourceNamePrefix = min-xxx,which does not change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, it's just more complex than it needs to be, and doesn't catch all the cases that would fail the pattern you show above: [a-z]([-a-z0-9]*[a-z0-9])?)

}

override def labels: Map[String, String] = {
Expand Down