Skip to content
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-35956][K8S] Support auto assigning labels to decommissioning pods #33270

Conversation

holdenk
Copy link
Contributor

@holdenk holdenk commented Jul 8, 2021

What changes were proposed in this pull request?

Add a new configuration flag to allow Spark to provide hints to the scheduler when we are decommissioning or exiting a pod that this pod will have the least impact for a pre-emption event.

Why are the changes needed?

Kubernetes added the concepts of pod disruption budgets (which can have selectors based on labels) as well pod deletion for providing hints to the scheduler as to what we would prefer to have pre-empted.

Does this PR introduce any user-facing change?

New configuration flag

How was this patch tested?

The deletion unit test was extended.

@SparkQA
Copy link

SparkQA commented Jul 8, 2021

Test build #140814 has finished for PR 33270 at commit e6e0ae4.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jul 8, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/45325/

@SparkQA
Copy link

SparkQA commented Jul 8, 2021

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/45325/

@@ -284,6 +284,24 @@ private[spark] object Config extends Logging {
.toSequence
.createWithDefault(Nil)

val KUBERNETES_EXECUTOR_POD_DECOMMISSION_LABEL =
Copy link
Member

Choose a reason for hiding this comment

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

doc updating for new config: docs/running-on-kubernetes.md.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call :)

val KUBERNETES_EXECUTOR_POD_DECOMMISSION_LABEL_VALUE =
ConfigBuilder("spark.kubernetes.executor.pod.decommmissionLabelValue")
.doc("Label value to apply to a pod which is being decommissioned." +
" Designed for use with pod disruption budgets and similar mechanism " +
Copy link
Member

Choose a reason for hiding this comment

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

ditto, redundant space

val KUBERNETES_EXECUTOR_POD_DECOMMISSION_LABEL =
ConfigBuilder("spark.kubernetes.executor.pod.decommmissionLabel")
.doc("Label to apply to a pod which is being decommissioned." +
" Designed for use with pod disruption budgets and similar mechanism " +
Copy link
Member

Choose a reason for hiding this comment

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

nit: redundant space in line end.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks :)

.doc("Label value to apply to a pod which is being decommissioned." +
" Designed for use with pod disruption budgets and similar mechanism " +
" such as pod-deletion-cost.")
.version("3.2.0")
Copy link
Member

Choose a reason for hiding this comment

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

And maybe 3.3.0 for now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah good point

@dongjoon-hyun
Copy link
Member

Sorry for being late, @holdenk . I was on vacation last week.

@@ -181,7 +184,51 @@ private[spark] class KubernetesClusterSchedulerBackend(
super.getExecutorIds()
}

private def labelLowPriorityExecs(execIds: Seq[String]) = {
Copy link
Member

Choose a reason for hiding this comment

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

The naming labelLowPriorityExecs looks misleading to me because the pods already have PriorityClass.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. We could say labelExecsForDecommissioning?

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good to me.

" such as pod-deletion-cost.")
.version("3.2.0")
.stringConf
.createWithDefault("")
Copy link
Member

Choose a reason for hiding this comment

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

Shall we use createOptional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So my thought was that for a labels value we'd use an empty string if the user doesn't specify a value, but I'm down for something else.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, we can still attach LABEL without values with createOptional conf.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I don't have strong feelings about this one, but the label does need a value (albiet the empty string is a valid value), so I've switched to use optional and then we do a getOrElse on it but I can switch it back.

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

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

Could you address the review comments from @Yikun ? I also added some comments.

cc @attilapiros

@github-actions github-actions bot added the DOCS label Jul 15, 2021
@SparkQA
Copy link

SparkQA commented Jul 15, 2021

Test build #141090 has finished for PR 33270 at commit 937732e.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jul 15, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/45604/

@SparkQA
Copy link

SparkQA commented Jul 15, 2021

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/45604/

@dongjoon-hyun
Copy link
Member

Thank you for updating, @holdenk .

Copy link
Contributor

@attilapiros attilapiros left a comment

Choose a reason for hiding this comment

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

I think we could extend the integration tests of DecommissionSuite as well with the decommmissionLabel and decommmissionLabelValue configs and at the end of the tests we could check whether it is set. WDYT?

@holdenk
Copy link
Contributor Author

holdenk commented Jul 20, 2021

Yeah I think we can extend that test suite to pick it up as well so we aren't just depending on mocks/unit tests. I'll give that shot.

@holdenk holdenk force-pushed the SPARK-35956-support-auto-assigning-labels-to-decommissioning-pods branch from 937732e to 83be9be Compare July 20, 2021 17:39
@holdenk
Copy link
Contributor Author

holdenk commented Jul 20, 2021

Ah now I'm remembering why I didn't change the DecommissionSuite it's because we do K8s side decommissioning by triggering a delete event instead of Spark side decommissioning. But we do trigger a Spark side decom in one sub test so I'll add it there.

@SparkQA
Copy link

SparkQA commented Jul 20, 2021

Test build #141353 has finished for PR 33270 at commit 83be9be.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jul 20, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/45867/

@SparkQA
Copy link

SparkQA commented Jul 20, 2021

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/45867/

@SparkQA
Copy link

SparkQA commented Jul 21, 2021

Test build #141368 has finished for PR 33270 at commit e460e52.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jul 21, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/45884/

@SparkQA
Copy link

SparkQA commented Jul 21, 2021

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/45884/

@dongjoon-hyun
Copy link
Member

Could you take a look at K8s IT failure? You may want to re-trigger it simply.

- Test decommissioning with dynamic allocation & shuffle cleanups *** FAILED ***
  The code passed to eventually never returned normally. Attempted 70 times over 2.0080748925166665 minutes. Last failure message: Map("spark-app-locator" -> "5131e7f3300942dba80c225eb409f5f1", "spark-app-selector" -> "spark-d1019d7e577b40adbab20a965952b5d0", "spark-exec-id" -> "1", "spark-exec-resourceprofile-id" -> "0", "spark-role" -> "executor") did not contain key "solong". (DecommissionSuite.scala:120)

@SparkQA
Copy link

SparkQA commented Jul 21, 2021

Test build #141434 has finished for PR 33270 at commit bd9ae50.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@holdenk holdenk force-pushed the SPARK-35956-support-auto-assigning-labels-to-decommissioning-pods branch from e21d2c7 to bb52a4c Compare July 22, 2021 17:26
@SparkQA
Copy link

SparkQA commented Jul 22, 2021

Test build #141511 has finished for PR 33270 at commit bb52a4c.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

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

Like the existing Spark label configuration spark.kubernetes.executor.label., shall we use spark.kubernetes.executor.decommmissionLabel instead of adding a new namespace .pod.?

@SparkQA
Copy link

SparkQA commented Jul 22, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/46028/

</tr>
<tr>
<td><code>spark.kubernetes.executor.pod.decommmissionLabelValue<code></td>
<td>""</td>
Copy link
Member

Choose a reason for hiding this comment

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

"" -> (none).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks good catch.

@SparkQA
Copy link

SparkQA commented Jul 22, 2021

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/46028/

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

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

+1, LGTM (with two minor comments). K8s IT passed, too.

  • Avoiding .pod. namespace from the conf naming.
  • Fixing the default value for decommmissionLabelValue.

Thank you, @holdenk . After revising them, feel free to merge.

@SparkQA
Copy link

SparkQA commented Jul 23, 2021

Test build #141525 has finished for PR 33270 at commit 15d32ba.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jul 23, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/46043/

@SparkQA
Copy link

SparkQA commented Jul 23, 2021

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/46043/

@SparkQA
Copy link

SparkQA commented Jul 23, 2021

Test build #141533 has finished for PR 33270 at commit f7d85fa.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jul 23, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/46051/

@SparkQA
Copy link

SparkQA commented Jul 23, 2021

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/46051/

Copy link
Contributor

@attilapiros attilapiros left a comment

Choose a reason for hiding this comment

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

I went through it again and I haven't found any issue.

LGTM

@asfgit asfgit closed this in bee2799 Jul 23, 2021
@holdenk
Copy link
Contributor Author

holdenk commented Jul 23, 2021

Merged to the current master.

dongjoon-hyun added a commit that referenced this pull request Mar 8, 2022
### What changes were proposed in this pull request?

This is a follow-up of #33270 to fix typos in config names

```scala
- ConfigBuilder("spark.kubernetes.executor.decommmissionLabel")
+ ConfigBuilder("spark.kubernetes.executor.decommissionLabel")
- ConfigBuilder("spark.kubernetes.executor.decommmissionLabelValue")
+ ConfigBuilder("spark.kubernetes.executor.decommissionLabelValue")
```

### Why are the changes needed?

To fix them before Apache Spark 3.3 branch cut.

### Does this PR introduce _any_ user-facing change?

No, this is not released yet.

### How was this patch tested?

Pass the CIs.

Closes #35767 from dongjoon-hyun/SPARK-35956.

Authored-by: Dongjoon Hyun <dongjoon@apache.org>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants