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
[SPARK-29233][K8S] Add regex expression checks for executorEnv… #25920
Conversation
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.
Hi, @merrily01 . Thank you for making this PR. Can we have additional integration test for the following?
Otherwise, it will lead to the problem that the pod can not be created normally and the tasks will be suspended.
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.
BTW, did you run this PR locally, @merrily01 ? This doesn't compile yet.
1371532
to
ca729a4
Compare
...rce-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/KubernetesConf.scala
Outdated
Show resolved
Hide resolved
...rce-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/KubernetesConf.scala
Outdated
Show resolved
Hide resolved
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/Constants.scala
Outdated
Show resolved
Hide resolved
ca729a4
to
ddeffb6
Compare
@srowen @dongjoon-hyun If so, I might need to modify the rules and code. |
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.
What versions would work, not work, with or without this change?
...rce-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/KubernetesConf.scala
Show resolved
Hide resolved
...rce-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/KubernetesConf.scala
Outdated
Show resolved
Hide resolved
ddeffb6
to
2200fdd
Compare
This change was submitted in commit 604dfb3 of k8s release-1.8 version. This current code will take effect for k8s release-1.8 and later versions. |
2200fdd
to
562b367
Compare
How about just using a more lenient regex then, that would allow both? this is more of a preemptive check than something that must exactly match? |
That's a good idea!I'll try it later. |
ok to test |
Test build #111370 has finished for PR 25920 at commit
|
Kubernetes integration test starting |
Kubernetes integration test status success |
Hey~ @srowen I was so sleepy last night that my mind was a little unclear. After my careful consideration, I have something to tell you:
|
562b367
to
81a30fc
Compare
Test build #111421 has finished for PR 25920 at commit
|
Wonder why it failed?@AmplabJenkins |
Unless there's an easy way to know what version of K8S will be in use, I think you have to keep the looser check here. It may let through invalid configs, and something will fail, but you get a failure either way. This change just tries to bring it forward. AmplabJenkins is a bot. Click the link to see why the build failed. It may be unrelated though: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/16460/console |
81a30fc
to
c64fbd2
Compare
Sorry for misoperation and reopen. Now using a looser check,could you please kindly review? i m so sorry . @srowen @dongjoon-hyun |
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.
Looks OK pending tests
Test build #4888 has finished for PR 25920 at commit
|
Thank you so much @srowen and @dongjoon-hyun please recheck ,i have added addition test and it can be tested and compiled. thanks a lot ! |
I'm going to try retriggering the K8S tests by closing and reopening |
Retest this please. |
...rce-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/KubernetesConf.scala
Outdated
Show resolved
Hide resolved
...rce-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/KubernetesConf.scala
Outdated
Show resolved
Hide resolved
...rce-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/KubernetesConf.scala
Outdated
Show resolved
Hide resolved
private val EXECUTOR_ENV_VARS = Map( | ||
"spark.executorEnv.1executorEnvVars1/var1" -> "executorEnvVars1", | ||
"spark.executorEnv.executorEnvVars2*var2" -> "executorEnvVars2", | ||
"spark.executorEnv.executorEnvVars3_var3" -> "executorEnvVars3") |
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.
Shall we move this into the test case? Do we have a plan to reuse this in another test case?
Never mind. This existing one looks good, too.
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.
BTW, please add another test case like "spark.executorEnv.4executorEnvVars4/var4" -> "executorEnvVars4"
in order to show clearly that this is only key
-constraint.
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.
@dongjoon-hyun "spark.executorEnv.4executorEnvVars4/var4" -> "executorEnvVars4" is the same as "spark.executorEnv.1executorEnvVars1/var1" -> "executorEnvVars1" . BTW, I added two test cases, which I think will prove that this is only key-constraint.
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, @merrily01 . Look fine except a few minor comments.
Test build #111577 has finished for PR 25920 at commit
|
Kubernetes integration test starting |
Kubernetes integration test status success |
@merrily01 do you want to make these last updates per above? |
@srowen @dongjoon-hyun done , thanks a lot ! |
… in K8S mode In kubernetes, there are some naming regular expression requirements and restrictions on environment variable names, such as: - In kubernetes version release-1.7 and earlier, the naming rules of pod environment variable names should meet the requirements of regular expressions: [[A-Za-z_] [A-Za-z0-9_]*](https://github.com/kubernetes/kubernetes/blob/release-1.7/staging/src/k8s.io/apimachinery/pkg/util/validation/validation.go#L169) - In kubernetes version release-1.8 and later, the naming rules of pod environment variable names should meet the requirements of regular expressions: [[-. _ A-ZA-Z][-. _ A-ZA-Z0-9].*](https://github.com/kubernetes/kubernetes/blob/release-1.8/staging/src/k8s.io/apimachinery/pkg/util/validation/validation.go#L305) However, in spark on k8s mode, spark should add restrictions on environmental variable names when creating executorEnv. In addition, we need to use regular expressions adapted to the high version of k8s to increase the restrictions on the names of environmental variables. Otherwise, the pod will not be created properly and the spark application will be suspended. To solve the problem above, a regular validation to executorEnv is added and committed. Unit tests have been added.
Test build #4891 has finished for PR 25920 at commit
|
Merged to master |
Forget to say thank you. |
What changes were proposed in this pull request?
In kubernetes, there are some naming regular expression requirements and restrictions on environment variable names, such as:
However, in spark on k8s mode, spark should add restrictions on environmental variable names when creating executorEnv.
In addition, we need to use regular expressions adapted to the high version of k8s to increase the restrictions on the names of environmental variables.
Otherwise, the pod will not be created properly and the spark application will be suspended.
To solve the problem above, a regular validation to executorEnv is added and committed.
Why are the changes needed?
If no validation rules are added, the environment variable names that don't meet the requirements will cause the pod to not be created properly and the application will be suspended.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Add unit tests and manually run.