This is an automated email from the ASF dual-hosted git repository.
dongjoon pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/spark-kubernetes-operator.git
The following commit(s) were added to refs/heads/main by this push:
new 6961d62 [SPARK-54674] Fix `AppValidateStep` to prevent `ClientMode`
deployment correctly
6961d62 is described below
commit 6961d62c766a1c4524c2e3dc92e3fc3a300e15d7
Author: Dongjoon Hyun <[email protected]>
AuthorDate: Wed Dec 10 13:59:59 2025 -0800
[SPARK-54674] Fix `AppValidateStep` to prevent `ClientMode` deployment
correctly
### What changes were proposed in this pull request?
This PR aims to fix `AppValidateStep` to prevent `ClientMode` deployment.
### Why are the changes needed?
Unfortunately, this feature never works before because it didn't work from
the initial implementation since v0.1.
- https://github.com/apache/spark-kubernetes-operator/pull/12
To protect users from invalid use cases.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Pass the CIs with newly added test case.
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes #426 from dongjoon-hyun/SPARK-54674.
Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
---
.../reconciler/reconcilesteps/AppValidateStep.java | 2 +-
.../reconciler/reconcilesteps/AppInitStepTest.java | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git
a/spark-operator/src/main/java/org/apache/spark/k8s/operator/reconciler/reconcilesteps/AppValidateStep.java
b/spark-operator/src/main/java/org/apache/spark/k8s/operator/reconciler/reconcilesteps/AppValidateStep.java
index 174328d..73466e9 100644
---
a/spark-operator/src/main/java/org/apache/spark/k8s/operator/reconciler/reconcilesteps/AppValidateStep.java
+++
b/spark-operator/src/main/java/org/apache/spark/k8s/operator/reconciler/reconcilesteps/AppValidateStep.java
@@ -50,7 +50,7 @@ public class AppValidateStep extends AppReconcileStep {
log.warn("Spark application found with empty status. Resetting to
initial state.");
return attemptStatusUpdate(context, statusRecorder, new
ApplicationStatus(), proceed());
}
- if (ClientMode.equals(context.getResource().getSpec())) {
+ if
(ClientMode.equals(context.getResource().getSpec().getDeploymentMode())) {
ApplicationState failure =
new ApplicationState(ApplicationStateSummary.Failed, "Client mode is
not supported yet.");
return attemptStatusUpdate(
diff --git
a/spark-operator/src/test/java/org/apache/spark/k8s/operator/reconciler/reconcilesteps/AppInitStepTest.java
b/spark-operator/src/test/java/org/apache/spark/k8s/operator/reconciler/reconcilesteps/AppInitStepTest.java
index 6d6a362..7f5af21 100644
---
a/spark-operator/src/test/java/org/apache/spark/k8s/operator/reconciler/reconcilesteps/AppInitStepTest.java
+++
b/spark-operator/src/test/java/org/apache/spark/k8s/operator/reconciler/reconcilesteps/AppInitStepTest.java
@@ -50,6 +50,7 @@ import org.mockito.ArgumentCaptor;
import org.apache.spark.k8s.operator.SparkApplication;
import org.apache.spark.k8s.operator.context.SparkAppContext;
import org.apache.spark.k8s.operator.reconciler.ReconcileProgress;
+import org.apache.spark.k8s.operator.spec.DeploymentMode;
import org.apache.spark.k8s.operator.utils.SparkAppStatusRecorder;
@EnableKubernetesMockClient(crud = true)
@@ -224,4 +225,19 @@ class AppInitStepTest {
Assertions.assertNotNull(createCM);
Assertions.assertNotNull(createdPod);
}
+
+ @Test
+ void banClientMode() {
+ AppValidateStep appValidateStep = new AppValidateStep();
+ SparkAppContext mocksparkAppContext = mock(SparkAppContext.class);
+ SparkAppStatusRecorder recorder = mock(SparkAppStatusRecorder.class);
+ SparkApplication application = new SparkApplication();
+ application.setMetadata(applicationMetadata);
+ application.getSpec().setDeploymentMode(DeploymentMode.ClientMode);
+ when(mocksparkAppContext.getResource()).thenReturn(application);
+
+ appValidateStep.reconcile(mocksparkAppContext, recorder);
+ ReconcileProgress progress =
appValidateStep.reconcile(mocksparkAppContext, recorder);
+ Assertions.assertEquals(ReconcileProgress.completeAndImmediateRequeue(),
progress);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]