Skip to content

Conversation

@parisni
Copy link

@parisni parisni commented Jul 24, 2025

This aims at simplifying the executor template management by letting the user to just pass the yaml content for the executor template and let the lib manage a configmap and manage it's lifecycle

The pr :

  • adds some example documentation
  • adds some tests
  • keep backward compatibility with the previous executor_pod_template_path
  • has been tested with success on k8s

Let me know

Copy link
Owner

@hussein-awala hussein-awala left a comment

Choose a reason for hiding this comment

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

Thanks @parisni for the PR, glad to see you contributing to the project.

I added some comments, I'll merge the PR once they're addressed, and sorry for the delay in the first review.

("--executor-template", "executor_template"),
type=str,
default=Configuration.SPARK_ON_K8S_EXECUTOR_TEMPLATE,
show_default=True,
Copy link
Owner

Choose a reason for hiding this comment

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

Showing the default could be a bit annoying if it's too big, but let's show it and check if we have any negative feedback

Copy link
Author

Choose a reason for hiding this comment

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

done

Comment on lines 416 to 417
# Set Spark configuration to use the mounted template
basic_conf["spark.kubernetes.executor.podTemplateFile"] = "/opt/spark/executor-template/executor-template.yaml"
Copy link
Owner

Choose a reason for hiding this comment

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

It would be better to override executor_pod_template_path and replace the elif above with an if, and also change the if configuration of this block to fail if both executor_pod_template_path and executor_template are provided

Copy link
Author

Choose a reason for hiding this comment

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

i did take most of what you ask, however i kept both variables independent (no override) to avoid unexpected side effect in the futur

Comment on lines 456 to 472
# If this is the executor template ConfigMap, only add it to executor volume mounts
# (driver mount was already added earlier when processing executor_template)
if executor_template_configmap and configmap.metadata.name == f"{app_id}-executor-template":
executor_volume_mounts.append(
k8s.V1VolumeMount(
name=configmap.metadata.name,
mount_path=configmap_mount_path,
)
)
else:
# Mount to driver for other ConfigMaps (like driver_ephemeral_configmaps_volumes)
driver_volume_mounts.append(
k8s.V1VolumeMount(
name=configmap.metadata.name,
mount_path=configmap_mount_path,
)
)
Copy link
Owner

Choose a reason for hiding this comment

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

the executor does not need to know what its pod template is, only the driver needs it to create the executor pods, you can revert the chanes in this block

Copy link
Author

Choose a reason for hiding this comment

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

good catch, done

executor_labels: dict[str, str] | ArgNotSet = NOTSET,
driver_tolerations: list[k8s.V1Toleration] | ArgNotSet = NOTSET,
executor_pod_template_path: str | ArgNotSet = NOTSET,
executor_template: str | ArgNotSet = NOTSET,
Copy link
Owner

Choose a reason for hiding this comment

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

I believe executor_pod_template is a better name, as we use executor_pod_template_path for the alternative option

Copy link
Author

Choose a reason for hiding this comment

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

done

Comment on lines 126 to 128
if (executor_template.startswith(('.', '/', '~')) or
executor_template.endswith(('.yaml', '.yml')) or
os.path.exists(executor_template)):
Copy link
Owner

Choose a reason for hiding this comment

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

if os.path.exists(executor_template) is false, then with open(os.path.expanduser(executor_template), 'r') as f: would fail, so the logic needs to be udpated

Copy link
Author

Choose a reason for hiding this comment

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

done: improve the logic, and add few tests

@parisni parisni requested a review from hussein-awala August 18, 2025 12:05
@parisni
Copy link
Author

parisni commented Aug 18, 2025

thanks for the review, i tried to address your feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants