You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by do...@apache.org on 2026/09/28 15:58:35 UTC
(spark-kubernetes-operator) branch main updated: [SPARK-59826] Do not serialize `is(Admitted|QuotaReserved|Finished)` of Kueue `WorkloadStatus`
This is an automated email from the ASF dual-hosted git repository.
dongjoon-hyun 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 6cfb5cc0 [SPARK-59826] Do not serialize `is(Admitted|QuotaReserved|Finished)` of Kueue `WorkloadStatus`
6cfb5cc0 is described below
commit 6cfb5cc0a83f37394672f559955ce944a010d935
Author: Dongjoon Hyun <do...@apache.org>
AuthorDate: Mon Sep 28 08:58:27 2026 -0700
[SPARK-59826] Do not serialize `is(Admitted|QuotaReserved|Finished)` of Kueue `WorkloadStatus`
### What changes were proposed in this pull request?
This PR aims to exclude the condition helpers of the Kueue `WorkloadStatus`, `isAdmitted()`, `isQuotaReserved()` and `isFinished()`, from the JSON serialization by annotating them with `JsonIgnore`.
The helpers themselves are kept because they are used throughout the code.
### Why are the changes needed?
Jackson auto-detects `boolean is*()` methods as properties. So, every serialized `WorkloadStatus` contains three extra fields which the Kueue `Workload` CRD does not have.
```
{"conditions":[...],"quotaReserved":true,"admitted":true,"finished":false}
```
For example, `KueueWorkloadUtils.finishWorkload` records the Kueue `Finished` condition with `editStatus`, and fabric8 builds a JSON Patch from the diff. So, the patch includes a `replace` operation for the non-existent `/status/finished` field.
**BEFORE**
```
[{"op":"add","path":"/status/conditions/2","value":{...}},{"op":"replace","path":"/status/finished","value":true}]
```
**AFTER**
```
[{"op":"add","path":"/status/conditions/2","value":{...}}]
```
It currently works only because the API server's JSON Patch tolerates `replace` on a missing object key and the structural schema prunes the field. This is fragile, and every `Workload` create and update also sends these fields.
### Does this PR introduce _any_ user-facing change?
No for the released versions, because the Kueue integration is not released yet in [v1.0.0](https://github.com/apache/spark-kubernetes-operator/releases/tag/1.0.0) (2026-07-26).
### How was this patch tested?
Pass the CIs with the newly added test case in `WorkloadTest`. The JSON Patch bodies above were also checked manually with the fabric8 `KubernetesMockServer`.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 5.5
Closes #898 from dongjoon-hyun/SPARK-59826.
Authored-by: Dongjoon Hyun <do...@apache.org>
Signed-off-by: Dongjoon Hyun <do...@apache.org>
---
.../k8s/operator/kueue/v1beta2/WorkloadStatus.java | 4 ++++
.../spark/k8s/operator/kueue/v1beta2/WorkloadTest.java | 18 ++++++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/spark-operator/src/main/java/org/apache/spark/k8s/operator/kueue/v1beta2/WorkloadStatus.java b/spark-operator/src/main/java/org/apache/spark/k8s/operator/kueue/v1beta2/WorkloadStatus.java
index 226e6172..50129896 100644
--- a/spark-operator/src/main/java/org/apache/spark/k8s/operator/kueue/v1beta2/WorkloadStatus.java
+++ b/spark-operator/src/main/java/org/apache/spark/k8s/operator/kueue/v1beta2/WorkloadStatus.java
@@ -22,6 +22,7 @@ package org.apache.spark.k8s.operator.kueue.v1beta2;
import java.util.ArrayList;
import java.util.List;
+import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.fabric8.kubernetes.api.model.Condition;
@@ -50,6 +51,7 @@ public class WorkloadStatus {
*
* @return true if an "Admitted" condition exists with status "True", false otherwise.
*/
+ @JsonIgnore
public boolean isAdmitted() {
return conditions != null
&& conditions.stream()
@@ -64,6 +66,7 @@ public class WorkloadStatus {
*
* @return true if a "QuotaReserved" condition exists with status "True", false otherwise.
*/
+ @JsonIgnore
public boolean isQuotaReserved() {
return conditions != null
&& conditions.stream()
@@ -78,6 +81,7 @@ public class WorkloadStatus {
*
* @return true if a "Finished" condition exists with status "True", false otherwise.
*/
+ @JsonIgnore
public boolean isFinished() {
return conditions != null
&& conditions.stream()
diff --git a/spark-operator/src/test/java/org/apache/spark/k8s/operator/kueue/v1beta2/WorkloadTest.java b/spark-operator/src/test/java/org/apache/spark/k8s/operator/kueue/v1beta2/WorkloadTest.java
index 77e5ba8c..92c9a6e4 100644
--- a/spark-operator/src/test/java/org/apache/spark/k8s/operator/kueue/v1beta2/WorkloadTest.java
+++ b/spark-operator/src/test/java/org/apache/spark/k8s/operator/kueue/v1beta2/WorkloadTest.java
@@ -27,6 +27,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import java.util.Map;
+import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.fabric8.kubernetes.api.model.Condition;
import io.fabric8.kubernetes.api.model.ConditionBuilder;
@@ -158,6 +159,23 @@ class WorkloadTest {
assertTrue(status.isFinished());
}
+ @Test
+ void testWorkloadStatusSerializationExcludesConditionHelpers() {
+ WorkloadStatus status =
+ WorkloadStatus.builder()
+ .conditions(
+ List.of(
+ new ConditionBuilder().withType("QuotaReserved").withStatus("True").build(),
+ new ConditionBuilder().withType("Admitted").withStatus("True").build()))
+ .build();
+
+ JsonNode json = OBJECT_MAPPER.valueToTree(status);
+ assertTrue(json.has("conditions"));
+ assertFalse(json.has("admitted"));
+ assertFalse(json.has("quotaReserved"));
+ assertFalse(json.has("finished"));
+ }
+
@Test
void testInitSpecAndStatus() {
Workload workload = new Workload();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org