dongjoon-hyun commented on a change in pull request #29941:
URL: https://github.com/apache/spark/pull/29941#discussion_r499294360
##########
File path:
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/KubernetesVolumeUtils.scala
##########
@@ -67,17 +70,31 @@ private[spark] object KubernetesVolumeUtils {
volumeType match {
case KUBERNETES_VOLUMES_HOSTPATH_TYPE =>
val pathKey =
s"$volumeType.$volumeName.$KUBERNETES_VOLUMES_OPTIONS_PATH_KEY"
- KubernetesHostPathVolumeConf(options(pathKey))
+ Try(KubernetesHostPathVolumeConf(options(pathKey)))
+ .fold(
+ _ => throw new NoSuchElementException(s"When using
$KUBERNETES_VOLUMES_HOSTPATH_TYPE " +
+ "Kubernetes volumes, it is necessary to define " +
+
s"$KUBERNETES_VOLUMES_HOSTPATH_TYPE.volumeName.$KUBERNETES_VOLUMES_OPTIONS_PATH_KEY"
+
+ s" property"),
+ kubernetesHostPathVolumeConf => kubernetesHostPathVolumeConf
+ )
case KUBERNETES_VOLUMES_PVC_TYPE =>
val claimNameKey =
s"$volumeType.$volumeName.$KUBERNETES_VOLUMES_OPTIONS_CLAIM_NAME_KEY"
val storageClassKey =
s"$volumeType.$volumeName.$KUBERNETES_VOLUMES_OPTIONS_CLAIM_STORAGE_CLASS_KEY"
val sizeLimitKey =
s"$volumeType.$volumeName.$KUBERNETES_VOLUMES_OPTIONS_SIZE_LIMIT_KEY"
- KubernetesPVCVolumeConf(
+ Try(KubernetesPVCVolumeConf(
options(claimNameKey),
options.get(storageClassKey),
- options.get(sizeLimitKey))
+ options.get(sizeLimitKey)))
+ .fold(
+ _ => throw new NoSuchElementException(s"When using
$KUBERNETES_VOLUMES_PVC_TYPE " +
Review comment:
`IllegalArgumentException` is better than `NoSuchElementException`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]