dongjoon-hyun commented on code in PR #58730:
URL: https://github.com/apache/spark/pull/58730#discussion_r4047669831


##########
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/features/MountVolumesFeatureStep.scala:
##########
@@ -134,6 +134,19 @@ private[spark] class MountVolumesFeatureStep(conf: 
KubernetesConf)
               .withPath(path)
               .withServer(server)
             .endNfs()
+
+        case KubernetesCSIVolumeConf(driverName, attributes, fsType, 
nodePublishSecretName) =>
+          val nodePublishSecretRef = nodePublishSecretName
+            .map(name => new 
LocalObjectReferenceBuilder().withName(name).build())
+            .orNull
+          new VolumeBuilder()
+            .withNewCsi()
+              .withDriver(driverName)
+              .withReadOnly(spec.mountReadOnly)
+              .withFsType(fsType.orNull)
+              .withVolumeAttributes(attributes.asJava)
+              .withNodePublishSecretRef(nodePublishSecretRef)

Review Comment:
   nit: `LocalObjectReference` has a `LocalObjectReference(String name)` 
constructor, so we don't need the builder and the separate `val` here. This 
keeps the whole volume in a single builder chain with the same `Option.orNull` 
pattern as `fsType`.
   
   ```suggestion
             new VolumeBuilder()
               .withNewCsi()
                 .withDriver(driverName)
                 .withReadOnly(spec.mountReadOnly)
                 .withFsType(fsType.orNull)
                 .withVolumeAttributes(attributes.asJava)
                 .withNodePublishSecretRef(nodePublishSecretName.map(new 
LocalObjectReference(_)).orNull)
   ```
   
   Note that `.withNewNodePublishSecretRef(nodePublishSecretName.orNull)` would 
not work, because it always creates a `LocalObjectReference` and would emit 
`nodePublishSecretRef: {}` when no secret is given.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to