Skip to content

Commit

Permalink
Improved KafkaRebalance columns for rebalancing status and template (
Browse files Browse the repository at this point in the history
…#10686)

Signed-off-by: Paolo Patierno <[email protected]>
  • Loading branch information
ppatierno authored Oct 8, 2024
1 parent ade9d12 commit 4ffe9f1
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 85 deletions.
5 changes: 5 additions & 0 deletions api/src/main/java/io/strimzi/api/ResourceAnnotations.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public class ResourceAnnotations {
*/
public static final String ANNO_STRIMZI_IO_REBALANCE_AUTOAPPROVAL = STRIMZI_DOMAIN + "rebalance-auto-approval";

/**
* Use this boolean annotation to set the KafkaRebalance as a template to be used for auto-rebalancing operations
*/
public static final String ANNO_STRIMZI_IO_REBALANCE_TEMPLATE = STRIMZI_DOMAIN + "rebalance-template";

/**
* Annotation which enabled the use of the connector operator
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,35 +51,15 @@
jsonPath = ".metadata.labels.strimzi\\.io/cluster",
type = "string"),
@Crd.Spec.AdditionalPrinterColumn(
name = "PendingProposal",
description = "A proposal has been requested from Cruise Control",
jsonPath = ".status.conditions[?(@.type==\"PendingProposal\")].status",
name = "Template",
description = "If this rebalance resource is a template",
jsonPath = ".metadata.annotations.strimzi\\.io/rebalance-template",
type = "string"),
@Crd.Spec.AdditionalPrinterColumn(
name = "ProposalReady",
description = "A proposal is ready and waiting for approval",
jsonPath = ".status.conditions[?(@.type==\"ProposalReady\")].status",
type = "string"),
@Crd.Spec.AdditionalPrinterColumn(
name = "Rebalancing",
description = "Cruise Control is doing the rebalance",
jsonPath = ".status.conditions[?(@.type==\"Rebalancing\")].status",
type = "string"),
@Crd.Spec.AdditionalPrinterColumn(
name = "Ready",
description = "The rebalance is complete",
jsonPath = ".status.conditions[?(@.type==\"Ready\")].status",
type = "string"),
@Crd.Spec.AdditionalPrinterColumn(
name = "NotReady",
description = "There is an error on the custom resource",
jsonPath = ".status.conditions[?(@.type==\"NotReady\")].status",
type = "string"),
@Crd.Spec.AdditionalPrinterColumn(
name = "Stopped",
description = "Processing the proposal or running rebalancing was stopped",
jsonPath = ".status.conditions[?(@.type==\"Stopped\")].status",
type = "string")
name = "Status",
description = "Status of the current rebalancing operation",
jsonPath = ".status.conditions[*].type",
type = "string")
}
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ public enum KafkaRebalanceAnnotation {
* This value should only be used when in the {@code ProposalReady} or {@code Stopped} states.
*/
refresh,
/**
* Used to represent a KafkaRebalance custom resource that represents a configuration template.
* This is used for auto-rebalancing on scaling to define the configuration template to be used for a specific
* rebalancing mode, as add-brokers or remove-brokers.
* When this annotation is applied to a KafkaRebalance custom resource, it doesn't trigger any actual auto-rebalance,
* instead the resource is just ignored.
*/
template,
/**
* Any other unsupported/unknown annotation value.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static io.strimzi.api.ResourceAnnotations.ANNO_STRIMZI_IO_REBALANCE_TEMPLATE;
import static io.strimzi.operator.cluster.operator.resource.cruisecontrol.CruiseControlApiImpl.HTTP_DEFAULT_IDLE_TIMEOUT_SECONDS;
import static io.strimzi.operator.common.Annotations.ANNO_STRIMZI_IO_REBALANCE;
import static io.strimzi.operator.common.Annotations.ANNO_STRIMZI_IO_REBALANCE_AUTOAPPROVAL;
Expand Down Expand Up @@ -996,8 +997,8 @@ private Future<MapAndStatus<ConfigMap, KafkaRebalanceStatus>> onReady(Reconcilia
return Future.succeededFuture();
}

KafkaRebalanceAnnotation rebalanceAnnotation = rebalanceAnnotation(kafkaRebalance);
if (rebalanceAnnotation == KafkaRebalanceAnnotation.template) {
boolean isTemplate = Annotations.booleanAnnotation(kafkaRebalance, ANNO_STRIMZI_IO_REBALANCE_TEMPLATE, false);
if (isTemplate) {
LOGGER.traceCr(reconciliation, "KafkaRebalance {} is a template configuration. Skipping it.", kafkaRebalance.getMetadata().getName());
return Future.succeededFuture();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@

import static io.strimzi.api.ResourceAnnotations.ANNO_STRIMZI_IO_NEXT_NODE_IDS;
import static io.strimzi.api.ResourceAnnotations.ANNO_STRIMZI_IO_REBALANCE;
import static io.strimzi.api.ResourceAnnotations.ANNO_STRIMZI_IO_REBALANCE_TEMPLATE;
import static io.strimzi.api.ResourceAnnotations.ANNO_STRIMZI_IO_REMOVE_NODE_IDS;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
Expand Down Expand Up @@ -1203,7 +1204,7 @@ private KafkaRebalance buildKafkaRebalanceTemplate(String name, List<String> goa
return new KafkaRebalanceBuilder()
.withNewMetadata()
.withName(name)
.withAnnotations(Map.of(ANNO_STRIMZI_IO_REBALANCE, "template"))
.withAnnotations(Map.of(ANNO_STRIMZI_IO_REBALANCE_TEMPLATE, "true"))
.endMetadata()
.withNewSpec()
.withGoals(goals)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1670,7 +1670,7 @@ public void testCruiseControlNotReachable(VertxTestContext context) {
public void testRebalanceTemplate(VertxTestContext context) {
KafkaRebalance kr = new KafkaRebalanceBuilder(createKafkaRebalance(namespace, null, RESOURCE_NAME, EMPTY_KAFKA_REBALANCE_SPEC, false))
.editMetadata()
.addToAnnotations(Annotations.ANNO_STRIMZI_IO_REBALANCE, KafkaRebalanceAnnotation.template.toString())
.addToAnnotations(Annotations.ANNO_STRIMZI_IO_REBALANCE_TEMPLATE, "true")
.endMetadata()
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ kind: KafkaRebalance
metadata:
name: my-add-brokers-rebalancing-template
annotations:
strimzi.io/rebalance: template
strimzi.io/rebalance-template: "true"
# no goals specified, using the default goals from the Cruise Control configuration
spec: {}
---
Expand All @@ -54,6 +54,6 @@ kind: KafkaRebalance
metadata:
name: my-remove-brokers-rebalancing-template
annotations:
strimzi.io/rebalance: template
strimzi.io/rebalance-template: "true"
# no goals specified, using the default goals from the Cruise Control configuration
spec: {}
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,13 @@ spec:
description: The name of the Kafka cluster this resource rebalances
jsonPath: .metadata.labels.strimzi\.io/cluster
type: string
- name: PendingProposal
description: A proposal has been requested from Cruise Control
jsonPath: ".status.conditions[?(@.type==\"PendingProposal\")].status"
- name: Template
description: If this rebalance resource is a template
jsonPath: .metadata.annotations.strimzi\.io/rebalance-template
type: string
- name: ProposalReady
description: A proposal is ready and waiting for approval
jsonPath: ".status.conditions[?(@.type==\"ProposalReady\")].status"
type: string
- name: Rebalancing
description: Cruise Control is doing the rebalance
jsonPath: ".status.conditions[?(@.type==\"Rebalancing\")].status"
type: string
- name: Ready
description: The rebalance is complete
jsonPath: ".status.conditions[?(@.type==\"Ready\")].status"
type: string
- name: NotReady
description: There is an error on the custom resource
jsonPath: ".status.conditions[?(@.type==\"NotReady\")].status"
type: string
- name: Stopped
description: Processing the proposal or running rebalancing was stopped
jsonPath: ".status.conditions[?(@.type==\"Stopped\")].status"
- name: Status
description: Status of the current rebalancing operation
jsonPath: ".status.conditions[*].type"
type: string
schema:
openAPIV3Schema:
Expand Down
28 changes: 6 additions & 22 deletions packaging/install/cluster-operator/049-Crd-kafkarebalance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,13 @@ spec:
description: The name of the Kafka cluster this resource rebalances
jsonPath: .metadata.labels.strimzi\.io/cluster
type: string
- name: PendingProposal
description: A proposal has been requested from Cruise Control
jsonPath: ".status.conditions[?(@.type==\"PendingProposal\")].status"
- name: Template
description: If this rebalance resource is a template
jsonPath: .metadata.annotations.strimzi\.io/rebalance-template
type: string
- name: ProposalReady
description: A proposal is ready and waiting for approval
jsonPath: ".status.conditions[?(@.type==\"ProposalReady\")].status"
type: string
- name: Rebalancing
description: Cruise Control is doing the rebalance
jsonPath: ".status.conditions[?(@.type==\"Rebalancing\")].status"
type: string
- name: Ready
description: The rebalance is complete
jsonPath: ".status.conditions[?(@.type==\"Ready\")].status"
type: string
- name: NotReady
description: There is an error on the custom resource
jsonPath: ".status.conditions[?(@.type==\"NotReady\")].status"
type: string
- name: Stopped
description: Processing the proposal or running rebalancing was stopped
jsonPath: ".status.conditions[?(@.type==\"Stopped\")].status"
- name: Status
description: Status of the current rebalancing operation
jsonPath: ".status.conditions[*].type"
type: string
schema:
openAPIV3Schema:
Expand Down

0 comments on commit 4ffe9f1

Please sign in to comment.