Skip to content

Conversation

@zwangsheng
Copy link
Contributor

@zwangsheng zwangsheng commented Aug 22, 2023

What changes were proposed in this pull request?

Move Utils. SubstituteAppNExecIds logic into KubernetesConf.annotations as the default logic,

Why are the changes needed?

Easy for users to reuse, rather than to rewrite it again at the same logic.

When user write custom feature step and using annotations, before this pr, they should call Utils. SubstituteAppNExecIds once.

Does this PR introduce any user-facing change?

Yes, but no sense for user to use annotations.

How was this patch tested?

Add unit test

Was this patch authored or co-authored using generative AI tooling?

No


override def annotations: Map[String, String] = {
KubernetesUtils.parsePrefixedKeyValuePairs(sparkConf, KUBERNETES_EXECUTOR_ANNOTATION_PREFIX)
.map { case (k, v) => (k, Utils.substituteAppNExecIds(v, appId, "")) }
Copy link
Member

Choose a reason for hiding this comment

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

where is the executorId?

Copy link
Contributor Author

@zwangsheng zwangsheng Aug 22, 2023

Choose a reason for hiding this comment

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

sry, missing the executorId param, fixed.

@yaooqinn
Copy link
Member

Easy for users to reuse

Is this user-facing Or just for developers

@zwangsheng
Copy link
Contributor Author

Easy for users to reuse

Is this user-facing Or just for developers

Who want to build custom feature steps and use sparkConf#annotations, can be user and developers.

@yaooqinn
Copy link
Member

cc @dongjoon-hyun

@dongjoon-hyun
Copy link
Member

Thank you for pinging me, @yaooqinn .

KubernetesUtils.parsePrefixedKeyValuePairs(sparkConf, KUBERNETES_DRIVER_ANNOTATION_PREFIX).map {
case(k, v) =>
(k, Utils.substituteAppNExecIds(v, appId, ""))
}
Copy link
Member

Choose a reason for hiding this comment

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

If you don't mind, shall we use the consistent short style like KubernetesExecutorConf, @zwangsheng ?

@dongjoon-hyun dongjoon-hyun changed the title [SPARK-44906][K8S] Move Utils. SubstituteAppNExecIds logic into KubernetesConf.annotations [SPARK-44906][K8S] Make Kubernetes[Driver|Executor]Conf.annotations substitute annotations instead of feature steps Aug 22, 2023
assert(conf.annotations === CUSTOM_ANNOTATIONS)
assert(conf.annotations === CUSTOM_ANNOTATIONS.map {
case (k, v) =>
(k, Utils.substituteAppNExecIds(v, conf.appId, ""))
Copy link
Member

Choose a reason for hiding this comment

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

You can merge it into one line.

-      case (k, v) =>
-        (k, Utils.substituteAppNExecIds(v, conf.appId, ""))
+      case (k, v) => (k, Utils.substituteAppNExecIds(v, conf.appId, ""))

assert(conf.annotations === CUSTOM_ANNOTATIONS)
assert(conf.annotations === CUSTOM_ANNOTATIONS.map {
case (k, v) =>
(k, Utils.substituteAppNExecIds(v, conf.appId, EXECUTOR_ID))
Copy link
Member

Choose a reason for hiding this comment

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

ditto

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.

Thank you for proposing this, @zwangsheng . I left a few comments.

@zwangsheng
Copy link
Contributor Author

Thanks for your review @dongjoon-hyun!

Addressed, let me know if anything missed.


override def annotations: Map[String, String] = {
KubernetesUtils.parsePrefixedKeyValuePairs(sparkConf, KUBERNETES_DRIVER_ANNOTATION_PREFIX)
.map(p => (p._1, Utils.substituteAppNExecIds(p._2, appId, "")))
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, but what I suggested (#42600 (comment)) is the following style instead of p => ....

case (k, v) => ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, i misunderstood the consistent short style.

Does the following code conform

.map{ case(k, v) => (k, Utils.substituteAppNExecIds(v, appId, executorId)) }

Copy link
Member

Choose a reason for hiding this comment

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

The following?

.map { case (k, v) => (k, Utils.substituteAppNExecIds(v, appId, executorId)) }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I mean does this format conform to the consistent short style?

.map { case (k, v) => (k, Utils.substituteAppNExecIds(v, appId, executorId)) }


override def annotations: Map[String, String] = {
KubernetesUtils.parsePrefixedKeyValuePairs(sparkConf, KUBERNETES_EXECUTOR_ANNOTATION_PREFIX)
.map(p => (p._1, Utils.substituteAppNExecIds(p._2, appId, executorId)))
Copy link
Member

Choose a reason for hiding this comment

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

ditto.

@dongjoon-hyun
Copy link
Member

Thank you for update, @zwangsheng . It seems that there is a minor miscommunication in the above. I added two comments.

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. Thank you, @zwangsheng and @yaooqinn .

@dongjoon-hyun
Copy link
Member

Welcome to the Apache Spark community, @zwangsheng .
I added you to the Apache Spark contributor group and assigned SPARK-44906 to you.
Thank you again for making a PR and revising according to the review comments. :)

@zwangsheng
Copy link
Contributor Author

Thanks for your help and review, @dongjoon-hyun @yaooqinn.

@yaooqinn
Copy link
Member

I added you to the Apache Spark contributor group and assigned SPARK-44906 to you.

Could we add this step to the merge PR script?

Welcome to the Apache Spark community

Thanks @dongjoon-hyun. As his colleague, Welcome @zwangsheng too. However, I guess he's not a first-time contributor, LOL.

@dongjoon-hyun
Copy link
Member

Oh, that's a good suggestion, but it required ASF JIRA Spark PMC permission.

Could we add this step to the merge PR script?

Here is a link. Could you try that?

@dongjoon-hyun
Copy link
Member

Oh, got it.

However, I guess he's not a first-time contributor, LOL.

But, it seems that he created new JIRA ID, @yaooqinn . That's the reason why the merge script fails.

@yaooqinn
Copy link
Member

Oh, that's a good suggestion, but it required ASF JIRA Spark PMC permission.

It appears that the committers of the Spark Jira Project are also admins. I once added someone to the contributor role.

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.

3 participants