Skip to content

Conversation

@jiangzho
Copy link
Contributor

@jiangzho jiangzho commented Jul 2, 2024

What changes were proposed in this pull request?

This is a breakdown PR of #12 - introducing config loading framework for controller module. It includes a config map reconciler that can watch properties updates for hot properties loading.

Why are the changes needed?

These are needed to enable user-configurable behavior of the operator.

Does this PR introduce any user-facing change?

No to existing Spark users.

How was this patch tested?

Tested via unit test coverage.

Was this patch authored or co-authored using generative AI tooling?

No.

SparkOperatorConf includes below groups / namespaces:

group / namespace | notes
---|---
spark.kubernetes.operator. | general operator conf, e.g. name, namespace, watched namespaces
spark.kubernetes.operator.reconciler. | reconciler behavior, e.g. parallelism, reconcile timeouts / interval, whether to enable history trimming . etc
spark.kubernetes.operator.dynamicConfig. | dynamic config monitor behavior
spark.kubernetes.operator.rateLimiter. | rate limiter behavior, interval, limits, multiplier . etc
spark.kubernetes.operator.retry. | retry behavior, including client retry config and additional retry behavior on k8s server error / status patching
spark.kubernetes.operator.metrics. | metrics behavior, e.g. whether to enable metrics sets for josdk / k8s client, metrics server port .etc
spark.kubernetes.operator.health. | health check / probe behavior
spark.kubernetes.operator.leaderElection. | leader election behavior for operator HA mode
@@ -0,0 +1,49 @@
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we move this to test/resources?

public class SparkOperatorConf {
public static final ConfigOption<String> OperatorAppName =
ConfigOption.<String>builder()
.key("spark.kubernetes.operator.name")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove all actual configuration (spark.kubernetes.operator.*) variables from this PR in order to focus on ConfigOption framework.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifically, let's remove from line 43 to 405 and all dependent lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure - this PR has been narrowed down to config loaders only

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for making a narrow-downed PR. We need to focus on new ConfigOption framework itself in this PR, @jiangzho . Could you address the following?

@jiangzho jiangzho changed the title [SPARK-48786]Define Conf Properties for Spark Operator Controller [SPARK-48786]Define Config Loading Framework for Spark Operator Controller Jul 3, 2024
public static final String LABEL_SPARK_OPERATOR_NAME = "spark.operator/name";
public static final String LABEL_SENTINEL_RESOURCE = "spark.operator/sentinel";
public static final String LABEL_RESOURCE_NAME = "app.kubernetes.io/name";
public static final String LABEL_COMPONENT_NAME = "app.kubernetes.io/component";
Copy link
Member

@dongjoon-hyun dongjoon-hyun Jul 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reordering this? Never mind. I found that the ordering is not consistent already.

@dongjoon-hyun
Copy link
Member

Could you make CI happy, @jiangzho ?

@dongjoon-hyun dongjoon-hyun changed the title [SPARK-48786]Define Config Loading Framework for Spark Operator Controller [SPARK-48786] Define Config Loading Framework for Spark Operator Controller Jul 9, 2024
Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, LGTM (Pending CIs).

@jiangzho jiangzho deleted the conf branch July 23, 2024 23:05
@dongjoon-hyun dongjoon-hyun mentioned this pull request Jul 29, 2024
jiangzho added a commit to jiangzho/spark-kubernetes-operator that referenced this pull request Jul 17, 2025
Refactor package name for Spark Clusters
dongjoon-hyun added a commit that referenced this pull request Oct 7, 2025
…tead of `ToStringBuilder`

### What changes were proposed in this pull request?

This PR aims to improve `SentinelResourceState.toString` by JEP-280 instead of `ToStringBuilder`.

### Why are the changes needed?

This is aligned with Apache Spark main repository improvement.
- apache/spark#51572

Since Java 9, `String Concatenation` has been handled better by default.

| ID | DESCRIPTION |
| - | - |
| JEP-280 | [Indify String Concatenation](https://openjdk.org/jeps/280) |

For example, `SentinelResourceState.toString` is changed like the following by this PR.

**BEFORE**

```
  public java.lang.String toString();
    Code:
         0: new           #43                 // class org/apache/commons/lang3/builder/ToStringBuilder
         3: dup
         4: aload_0
         5: invokespecial #45                 // Method org/apache/commons/lang3/builder/ToStringBuilder."<init>":(Ljava/lang/Object;)V
         8: ldc           #48                 // String resource
        10: aload_0
        11: getfield      #17                 // Field resource:Lorg/apache/spark/k8s/operator/BaseResource;
        14: invokevirtual #49                 // Method org/apache/commons/lang3/builder/ToStringBuilder.append:(Ljava/lang/String;Ljava/lang/Object;)Lorg/apache/commons/lang3/builder/ToStringBuilder;
        17: ldc           #53                 // String previousGeneration
        19: aload_0
        20: getfield      #39                 // Field previousGeneration:J
        23: invokevirtual #54                 // Method org/apache/commons/lang3/builder/ToStringBuilder.append:(Ljava/lang/String;J)Lorg/apache/commons/lang3/builder/ToStringBuilder;
        26: ldc           #57                 // String isHealthy
        28: aload_0
        29: getfield      #13                 // Field isHealthy:Z
        32: invokevirtual #58                 // Method org/apache/commons/lang3/builder/ToStringBuilder.append:(Ljava/lang/String;Z)Lorg/apache/commons/lang3/builder/ToStringBuilder;
        35: invokevirtual #61                 // Method org/apache/commons/lang3/builder/ToStringBuilder.toString:()Ljava/lang/String;
        38: areturn
```

**AFTER**

```
  public java.lang.String toString();
    Code:
         0: aload_0
         1: getfield      #17                 // Field resource:Lorg/apache/spark/k8s/operator/BaseResource;
         4: invokestatic  #43                 // Method java/lang/String.valueOf:(Ljava/lang/Object;)Ljava/lang/String;
         7: aload_0
         8: getfield      #39                 // Field previousGeneration:J
        11: aload_0
        12: getfield      #13                 // Field isHealthy:Z
        15: invokedynamic #49,  0             // InvokeDynamic #0:makeConcatWithConstants:(Ljava/lang/String;JZ)Ljava/lang/String;
        20: areturn
```

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Pass the CIs.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes #369 from dongjoon-hyun/SPARK-53818.

Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants