Github user mccheah commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19954#discussion_r157643654
  
    --- Diff: 
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/InitContainerBootstrap.scala
 ---
    @@ -0,0 +1,128 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.spark.deploy.k8s
    +
    +import scala.collection.JavaConverters._
    +
    +import io.fabric8.kubernetes.api.model.{ContainerBuilder, 
EmptyDirVolumeSource, EnvVarBuilder, PodBuilder, VolumeMount, 
VolumeMountBuilder}
    +
    +import org.apache.spark.{SparkConf, SparkException}
    +import org.apache.spark.deploy.k8s.Config._
    +import org.apache.spark.deploy.k8s.Constants._
    +
    +/**
    + * This is separated out from the init-container steps API because this 
component can be reused to
    + * set up the init-container for executors as well.
    + */
    +private[spark] trait InitContainerBootstrap {
    --- End diff --
    
    It's probably fine to just use the class here, but some classes can't be 
mocked, such as final classes or classes with final methods. Having traits 
everywhere ensures that even if we change the classes down the road to have 
such characteristics, our tests won't break.
    
    This also is not entirely without precedent. `TaskScheduler` is only 
implemented by `TaskSchedulerImpl` in the main scheduler code, as is 
`TaskContext` being extended only by `TaskContextImpl`. Putting a trait in 
front of an implementation communicates that it's expected for tests that 
dependency-inject instances of this to create stub implementations.
    
    But we might be splitting hairs at this point, so using only the class 
could suffice until we run into problems from having done so.


---

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

Reply via email to