Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Integer instead of int in KafkaClusterSpec replicas #9663

Merged
merged 3 commits into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class KafkaClusterSpec implements HasConfigurableMetrics, HasConfigurable
private String brokerRackInitImage;
private Rack rack;
private Logging logging;
private int replicas;
private Integer replicas;
private String image;
private ResourceRequirements resources;
private Probe livenessProbe;
Expand Down Expand Up @@ -164,11 +164,11 @@ public void setLogging(Logging logging) {
@Description("The number of pods in the cluster. " +
"This property is required when node pools are not used.")
@Minimum(1)
public int getReplicas() {
public Integer getReplicas() {
return replicas;
}

public void setReplicas(int replicas) {
public void setReplicas(Integer replicas) {
this.replicas = replicas;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static void validateKafkaCrForZooKeeper(KafkaSpec kafkaSpec, boolean node
}

if (!nodePoolsEnabled) {
if (kafkaSpec.getKafka().getReplicas() == 0) {
if (kafkaSpec.getKafka().getReplicas() == null || kafkaSpec.getKafka().getReplicas() == 0) {
errors.add("The .spec.kafka.replicas property of the Kafka custom resource is missing. " +
"This property is required for a ZooKeeper-based Kafka cluster that is not using Node Pools.");
}
Expand Down Expand Up @@ -136,6 +136,7 @@ public static void kraftWarnings(Kafka kafkaCr, KafkaStatus kafkaStatus) {
*/
public static void nodePoolWarnings(Kafka kafkaCr, KafkaStatus kafkaStatus) {
if (kafkaCr.getSpec().getKafka() != null
&& kafkaCr.getSpec().getKafka().getReplicas() != null
&& kafkaCr.getSpec().getKafka().getReplicas() > 0) {
kafkaStatus.addCondition(StatusUtils.buildWarningCondition("UnusedReplicasConfiguration",
"The .spec.kafka.replicas property in the Kafka custom resource is ignored when node pools " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ metadata:
name: my-cluster
spec:
kafka:
replicas: 1
listeners:
- name: plain
port: 9092
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ metadata:
name: my-cluster
spec:
kafka:
replicas: 1
listeners:
- name: plain
port: 9092
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ metadata:
name: my-cluster
spec:
kafka:
replicas: 1
listeners:
- name: plain
port: 9092
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ metadata:
name: my-cluster
spec:
kafka:
replicas: 1
listeners:
- name: plain
port: 9092
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ metadata:
name: my-cluster
spec:
kafka:
replicas: 1
listeners:
- name: plain
port: 9092
Expand Down
Loading