Skip to content

Commit 5a90eed

Browse files
committed
[SPARK-49831] Provide empty RuntimeVersions object to ClusterSpec.runtimeVersions by default
### What changes were proposed in this pull request? Like the other fields of `ClusterSpec`, this PR aims to provide at least empty `RuntimeVersions` object to `ClusterSpec.runtimeVersions` field by default. ### Why are the changes needed? Although `ClusterSpec.runtimeVersions` field is a required field, it's `null` currently by default because this should be provided by the users. However, technically, we can create `RuntimeVersions` object with null fields when we don't know the values of `RuntimeVersion` class fields. By providing this intermediate object by default, we can write a test case more easily in other modules. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Pass the CIs with the updated test case. ### Was this patch authored or co-authored using generative AI tooling? No. Closes apache#140 from dongjoon-hyun/SPARK-49831. Authored-by: Dongjoon Hyun <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent cdad512 commit 5a90eed

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

spark-operator-api/src/main/java/org/apache/spark/k8s/operator/spec/ClusterSpec.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
@JsonInclude(JsonInclude.Include.NON_NULL)
3737
@JsonIgnoreProperties(ignoreUnknown = true)
3838
public class ClusterSpec extends BaseSpec {
39-
@Required protected RuntimeVersions runtimeVersions;
39+
@Required @Builder.Default protected RuntimeVersions runtimeVersions = new RuntimeVersions();
4040

4141
@Required @Builder.Default
4242
protected ClusterTolerations clusterTolerations = new ClusterTolerations();

spark-operator-api/src/test/java/org/apache/spark/k8s/operator/spec/ClusterSpecTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
package org.apache.spark.k8s.operator.spec;
2121

2222
import static org.junit.jupiter.api.Assertions.assertEquals;
23-
import static org.junit.jupiter.api.Assertions.assertNull;
2423

2524
import org.junit.jupiter.api.Test;
2625

@@ -35,7 +34,9 @@ void testBuilder() {
3534
@Test
3635
void testInitSpecWithDefaults() {
3736
ClusterSpec spec1 = new ClusterSpec();
38-
assertNull(spec1.runtimeVersions);
37+
assertEquals(null, spec1.runtimeVersions.jdkVersion);
38+
assertEquals(null, spec1.runtimeVersions.scalaVersion);
39+
assertEquals(null, spec1.runtimeVersions.sparkVersion);
3940
assertEquals(0, spec1.clusterTolerations.instanceConfig.initWorkers);
4041
assertEquals(0, spec1.clusterTolerations.instanceConfig.minWorkers);
4142
assertEquals(0, spec1.clusterTolerations.instanceConfig.maxWorkers);

0 commit comments

Comments
 (0)