// Module included in the following assemblies:
//
// assembly-cruise-control-concepts.adoc

[id='proc-approving-optimization-proposal-{context}']

= Approving optimization proposals

[role="_abstract"]
You can approve an xref:con-optimization-proposals-{context}[optimization proposal] generated by Cruise Control, if its status is `ProposalReady`.
Cruise Control will then apply the optimization proposal to the Kafka cluster, reassigning partitions to brokers and changing partition leadership.

[CAUTION]
====
*This is not a dry run.* Before you approve an optimization proposal, you must:

* Refresh the proposal in case it has become out of date.
* Carefully review the xref:contents-optimization-proposals[contents of the proposal].
====

.Prerequisites

* You have xref:proc-generating-optimization-proposals-{context}[generated an optimization proposal] from Cruise Control.

* The `KafkaRebalance` custom resource status is `ProposalReady`.

.Procedure

Perform these steps for the optimization proposal that you want to approve.

. Unless the optimization proposal is newly generated, check that it is based on current information about the state of the Kafka cluster.
To do so, annotate the `KafkaRebalance` resource to refresh the optimization proposal and make sure it uses the latest cluster metrics:
+
[source,shell]
----
kubectl annotate kafkarebalance <kafka_rebalance_resource_name> strimzi.io/rebalance="refresh"
----

. Wait for the status of the optimization proposal to change to `ProposalReady`:
+
[source,shell]
----
kubectl get kafkarebalance -o wide -w -n <namespace>
----
+
--
`PendingProposal`:: A `PendingProposal` status means the rebalance operator is polling the Cruise Control API to check if the optimization proposal is ready.
`ProposalReady`:: A `ProposalReady` status means the optimization proposal is ready for review and approval.
--
+
When the status changes to `ProposalReady`, the optimization proposal is ready to approve.

. Annotate the `KafkaRebalance` resource to approve the optimization proposal:
+
[source,shell]
----
kubectl annotate kafkarebalance <kafka_rebalance_resource_name> strimzi.io/rebalance="approve"
----

. The Cluster Operator detects the annotated resource and instructs Cruise Control to rebalance the Kafka cluster.

. Wait for the status of the optimization proposal to change to `Ready`:
+
[source,shell]
----
kubectl get kafkarebalance -o wide -w -n <namespace>
----
+
--
`Rebalancing`:: A `Rebalancing` status means the rebalancing is in progress.
`Ready`:: A `Ready` status means the rebalance is complete.
`NotReady`:: A `NotReady` status means an error occurred--see xref:proc-fixing-problems-with-kafkarebalance-{context}[Fixing problems with a `KafkaRebalance` resource].
--
+
When the status changes to `Ready`, the rebalance is complete.
+
To use the same `KafkaRebalance` custom resource to generate another optimization proposal, apply the `refresh` annotation to the custom resource.
This moves the custom resource to the `PendingProposal` or `ProposalReady` state. You can then review the optimization proposal and approve it, if desired.

[role="_additional-resources"]
.Additional resources
* xref:con-optimization-proposals-{context}[]
* xref:proc-stopping-cluster-rebalance-{context}[]
