-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-27258][K8S]Deal with the k8s resource names that don't match their own regular expression #24839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| s"too long (must be <= $MAX_SERVICE_NAME_LENGTH characters). Falling back to use " + | ||
| s"$shorterServiceName as the driver service's name.") | ||
| s"too long (must be <= $MAX_SERVICE_NAME_LENGTH characters) or is not a valid service name." + | ||
| s"Falling back to use $shorterServiceName as the driver service's name.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be falling back to some default name. It is not necessarily the shorter if the preferred is invalid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only a method for dealing with the invalid service name. If the name is invalid and we don't deal with it, the job only has a driver pod.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am referring to the warning message could be made more specific and also the name of the variable shorterServiceName . Since it may be invalid and not shorter in some cases I would replace shorterServiceName with defaultServiceName. Anyway this is nit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh,I got it!
| private val preferredServiceName = s"${kubernetesConf.resourceNamePrefix}$DRIVER_SVC_POSTFIX" | ||
| private val resolvedServiceName = if (preferredServiceName.length <= MAX_SERVICE_NAME_LENGTH) { | ||
| private val resolvedServiceName = if (preferredServiceName.length <= MAX_SERVICE_NAME_LENGTH | ||
| && Character.isLetter(preferredServiceName.charAt(0))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the svc name valid in all cases according to com.google.common.net.InternetDomainName.isValid as mentioned in the other PR? It seems that the svc name which is up to 63 chars and has no dots in it matches a domain label (https://www.ietf.org/rfc/rfc3490.txt) so that method will cover the validation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the svc name valid in all cases according to
com.google.common.net.InternetDomainName.isValidas mentioned in the other PR? As it is now it seems valid according to the spec: https://en.wikipedia.org/wiki/Domain_name.
Now, fabric8 API has some limitations,
public class Service implements HasMetadata {
@NotNull
@JsonProperty("apiVersion")
private String apiVersion = "v1";
@NotNull
@JsonProperty("kind")
private String kind = "Service";
@JsonProperty("metadata")
@Valid
@CheckObjectMeta(
regexp = "^[a-z]([-a-z0-9]*[a-z0-9])?$",
max = 63
) @CheckObjectMeta( regexp = "^[a-z]([-a-z0-9]*[a-z0-9])?$", max = 63 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I saw that when digging into it. It should be ok from what I read: https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/ "Assume a Service named foo in the Kubernetes namespace bar. A Pod running in namespace bar can look up this service by simply doing a DNS query for foo. A Pod running in namespace quux can look up this service by doing a DNS query for foo.bar." so it matches the domain label, that is why there are these limitations. @liyinan926 can you verify this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the purpose of Character.isLetter here, we've already filtered this down to only allow [a-z0-9]
|
LGTM wrt validation part. |
Hi , how is progress now? In addition, is it planned to provide |
| .replaceAll("\\.", "-") | ||
| .replaceAll("[^a-z0-9\\-]", "") | ||
| .replaceAll("-+", "-") | ||
| .replaceAll("^-", "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still needed then, if you're simply validating and replacing the name if it starts with "-"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still needed then, if you're simply validating and replacing the name if it starts with "-"?
The '^-' is used for all kubernetes resources. If the resource name starts with "-",we replace it with "" ,which can run normally .
The service name that starts with 0-9 is replace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we need to match the fabric8 regex bellow, shouldn't this be .replaceAll("^[^a-z]", "") to replace any leading/first non alpha character?
srowen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know enough to evaluate; @skonto does this look reasonable at this point?
|
Test build #4823 has finished for PR 24839 at commit
|
|
? |
|
Jenkins ok to test |
holdenk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this, I've got a question about two of the checks I'd like to understand more.
| private val preferredServiceName = s"${kubernetesConf.resourceNamePrefix}$DRIVER_SVC_POSTFIX" | ||
| private val resolvedServiceName = if (preferredServiceName.length <= MAX_SERVICE_NAME_LENGTH) { | ||
| private val resolvedServiceName = if (preferredServiceName.length <= MAX_SERVICE_NAME_LENGTH | ||
| && Character.isLetter(preferredServiceName.charAt(0))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the purpose of Character.isLetter here, we've already filtered this down to only allow [a-z0-9]
| .replaceAll("\\.", "-") | ||
| .replaceAll("[^a-z0-9\\-]", "") | ||
| .replaceAll("-+", "-") | ||
| .replaceAll("^-", "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we need to match the fabric8 regex bellow, shouldn't this be .replaceAll("^[^a-z]", "") to replace any leading/first non alpha character?
|
Test build #110712 has finished for PR 24839 at commit
|
|
Kubernetes integration test starting |
|
@holdenk Hi,
|
|
Kubernetes integration test status success |
|
Hi @hehuiyuan I don't completely understand your response. Let me write my understanding and you can point out where we're not matching up: So the resourceNamePrefix is (with the change) gauranteed to start with something in If that's the case maybe just add a comment about that, because it takes a bit of tracing through the code to build up that context. |
Hi, it is ok. All resources (Pod /Service / Secret ..) will start with the first character is The changes I've made are more detailed.
|
|
We're closing this PR because it hasn't been updated in a while. If you'd like to revive this PR, please reopen it! |

What changes were proposed in this pull request?
The regex of Pod is ^a-z0-9?(.a-z0-9?).
The regex of Servive is ^a-z?.
The regex of Secret is ^a-z0-9?(.a-z0-9?).
If --name=-min, the first character is '-' ,which does not satisfy the regex for Pod ,Service,Secret.
if --name=1min, the first character is digit, which does not satisfy the regex for Service.
Previous Conflict PR