-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-37331][K8S] Add the ability to create resources before driverPod creating #34599
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -133,15 +133,41 @@ private[spark] class Client( | |
| .build() | ||
| val driverPodName = resolvedDriverPod.getMetadata.getName | ||
|
|
||
| // setup resources before pod creation | ||
| val preKubernetesResources = resolvedDriverSpec.driverPreKubernetesResources | ||
| try { | ||
| kubernetesClient.resourceList(preKubernetesResources: _*).createOrReplace() | ||
| } catch { | ||
| case NonFatal(e) => | ||
| logError("Please check \"kubectl auth can-i create [resource]\" first." + | ||
| " It should be yes. And please also check your feature step implementation.") | ||
| kubernetesClient.resourceList(preKubernetesResources: _*).delete() | ||
| throw e | ||
| } | ||
|
|
||
| var watch: Watch = null | ||
| var createdDriverPod: Pod = null | ||
| try { | ||
| createdDriverPod = kubernetesClient.pods().create(resolvedDriverPod) | ||
| } catch { | ||
| case NonFatal(e) => | ||
| kubernetesClient.resourceList(preKubernetesResources: _*).delete() | ||
| logError("Please check \"kubectl auth can-i create pod\" first. It should be yes.") | ||
| throw e | ||
| } | ||
|
|
||
| // Refresh all pre-resources' owner references | ||
| try { | ||
| addOwnerReference(createdDriverPod, preKubernetesResources) | ||
| kubernetesClient.resourceList(preKubernetesResources: _*).createOrReplace() | ||
| } catch { | ||
| case NonFatal(e) => | ||
| kubernetesClient.pods().delete(createdDriverPod) | ||
| kubernetesClient.resourceList(preKubernetesResources: _*).delete() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens when the previous line deletes some of the resources of
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, it's okay, I also write a simple test to delete non-existing crd in real env, it passed as expected. test("Deleting nonExisting crds") {
val crd = new CustomResourceDefinitionBuilder()
.withNewMetadata()
.withName("nonExisting1")
.endMetadata()
.build()
val crd2 = new CustomResourceDefinitionBuilder()
.withNewMetadata()
.withName("nonExisting")
.endMetadata()
.build()
val crds = Seq(crd, crd2)
val client = new DefaultKubernetesClient("https://127.0.0.1:52878")
assert(client.inNamespace("default").resourceList(crd).delete() === false)
assert(client.inNamespace("default").resourceList(crds: _*).delete() == false)
} |
||
| throw e | ||
| } | ||
|
|
||
| // setup resources after pod creation, and refresh all resources' owner references | ||
| try { | ||
| val otherKubernetesResources = resolvedDriverSpec.driverKubernetesResources ++ Seq(configMap) | ||
| addOwnerReference(createdDriverPod, otherKubernetesResources) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
Since this is the first error causing Job failure, could you add a user-friendly error message with
logError?Uh oh!
There was an error while loading. Please reload this page.
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.
Sure, how about: