use of io.strimzi.operator.common.Annotations.ANNO_STRIMZI_IO_REBALANCE in project strimzi by strimzi.
the class KafkaRebalanceAssemblyOperator method reconcile.
private Future<Void> reconcile(Reconciliation reconciliation, String host, CruiseControlApi apiClient, KafkaRebalance kafkaRebalance, KafkaRebalanceState currentState, KafkaRebalanceAnnotation rebalanceAnnotation) {
LOGGER.infoCr(reconciliation, "Rebalance action from state [{}]", currentState);
if (Annotations.isReconciliationPausedWithAnnotation(kafkaRebalance)) {
// we need to do this check again because it was triggered by a watcher
KafkaRebalanceStatus status = new KafkaRebalanceStatus();
Set<Condition> unknownAndDeprecatedConditions = validate(reconciliation, kafkaRebalance);
unknownAndDeprecatedConditions.add(StatusUtils.getPausedCondition());
status.setConditions(new ArrayList<>(unknownAndDeprecatedConditions));
return updateStatus(reconciliation, kafkaRebalance, status, null).compose(i -> Future.succeededFuture());
}
RebalanceOptions.RebalanceOptionsBuilder rebalanceOptionsBuilder = convertRebalanceSpecToRebalanceOptions(kafkaRebalance.getSpec(), usingJbodStorage);
return computeNextStatus(reconciliation, host, apiClient, kafkaRebalance, currentState, rebalanceAnnotation, rebalanceOptionsBuilder).compose(desiredStatusAndMap -> {
// do a new get to retrieve the current resource state.
return kafkaRebalanceOperator.getAsync(reconciliation.namespace(), reconciliation.name()).compose(currentKafkaRebalance -> {
if (currentKafkaRebalance != null) {
return configMapOperator.reconcile(reconciliation, kafkaRebalance.getMetadata().getNamespace(), kafkaRebalance.getMetadata().getName(), desiredStatusAndMap.getLoadMap()).compose(i -> updateStatus(reconciliation, currentKafkaRebalance, desiredStatusAndMap.getStatus(), null)).compose(updatedKafkaRebalance -> {
LOGGER.infoCr(reconciliation, "State updated to [{}] with annotation {}={} ", rebalanceStateConditionType(updatedKafkaRebalance.getStatus()), ANNO_STRIMZI_IO_REBALANCE, rawRebalanceAnnotation(updatedKafkaRebalance));
if (hasRebalanceAnnotation(updatedKafkaRebalance)) {
LOGGER.debugCr(reconciliation, "Removing annotation {}={}", ANNO_STRIMZI_IO_REBALANCE, rawRebalanceAnnotation(updatedKafkaRebalance));
// Updated KafkaRebalance has rebalance annotation removed as
// action specified by user has been completed.
KafkaRebalance patchedKafkaRebalance = new KafkaRebalanceBuilder(updatedKafkaRebalance).editMetadata().removeFromAnnotations(ANNO_STRIMZI_IO_REBALANCE).endMetadata().build();
return kafkaRebalanceOperator.patchAsync(reconciliation, patchedKafkaRebalance);
} else {
LOGGER.debugCr(reconciliation, "No annotation {}", ANNO_STRIMZI_IO_REBALANCE);
return Future.succeededFuture();
}
}).mapEmpty();
} else {
return Future.succeededFuture();
}
}, exception -> {
LOGGER.errorCr(reconciliation, "Status updated to [NotReady] due to error: {}", exception.getMessage());
return updateStatus(reconciliation, kafkaRebalance, new KafkaRebalanceStatus(), exception).mapEmpty();
});
}, exception -> {
LOGGER.errorCr(reconciliation, "Status updated to [NotReady] due to error: {}", exception.getMessage());
return updateStatus(reconciliation, kafkaRebalance, new KafkaRebalanceStatus(), exception).mapEmpty();
});
}
use of io.strimzi.operator.common.Annotations.ANNO_STRIMZI_IO_REBALANCE in project strimzi-kafka-operator by strimzi.
the class KafkaRebalanceAssemblyOperator method reconcile.
private Future<Void> reconcile(Reconciliation reconciliation, String host, CruiseControlApi apiClient, KafkaRebalance kafkaRebalance, KafkaRebalanceState currentState, KafkaRebalanceAnnotation rebalanceAnnotation) {
LOGGER.infoCr(reconciliation, "Rebalance action from state [{}]", currentState);
if (Annotations.isReconciliationPausedWithAnnotation(kafkaRebalance)) {
// we need to do this check again because it was triggered by a watcher
KafkaRebalanceStatus status = new KafkaRebalanceStatus();
Set<Condition> unknownAndDeprecatedConditions = validate(reconciliation, kafkaRebalance);
unknownAndDeprecatedConditions.add(StatusUtils.getPausedCondition());
status.setConditions(new ArrayList<>(unknownAndDeprecatedConditions));
return updateStatus(reconciliation, kafkaRebalance, status, null).compose(i -> Future.succeededFuture());
}
RebalanceOptions.RebalanceOptionsBuilder rebalanceOptionsBuilder = convertRebalanceSpecToRebalanceOptions(kafkaRebalance.getSpec(), usingJbodStorage);
return computeNextStatus(reconciliation, host, apiClient, kafkaRebalance, currentState, rebalanceAnnotation, rebalanceOptionsBuilder).compose(desiredStatusAndMap -> {
// do a new get to retrieve the current resource state.
return kafkaRebalanceOperator.getAsync(reconciliation.namespace(), reconciliation.name()).compose(currentKafkaRebalance -> {
if (currentKafkaRebalance != null) {
return configMapOperator.reconcile(reconciliation, kafkaRebalance.getMetadata().getNamespace(), kafkaRebalance.getMetadata().getName(), desiredStatusAndMap.getLoadMap()).compose(i -> updateStatus(reconciliation, currentKafkaRebalance, desiredStatusAndMap.getStatus(), null)).compose(updatedKafkaRebalance -> {
LOGGER.infoCr(reconciliation, "State updated to [{}] with annotation {}={} ", rebalanceStateConditionType(updatedKafkaRebalance.getStatus()), ANNO_STRIMZI_IO_REBALANCE, rawRebalanceAnnotation(updatedKafkaRebalance));
if (hasRebalanceAnnotation(updatedKafkaRebalance)) {
LOGGER.debugCr(reconciliation, "Removing annotation {}={}", ANNO_STRIMZI_IO_REBALANCE, rawRebalanceAnnotation(updatedKafkaRebalance));
// Updated KafkaRebalance has rebalance annotation removed as
// action specified by user has been completed.
KafkaRebalance patchedKafkaRebalance = new KafkaRebalanceBuilder(updatedKafkaRebalance).editMetadata().removeFromAnnotations(ANNO_STRIMZI_IO_REBALANCE).endMetadata().build();
return kafkaRebalanceOperator.patchAsync(reconciliation, patchedKafkaRebalance);
} else {
LOGGER.debugCr(reconciliation, "No annotation {}", ANNO_STRIMZI_IO_REBALANCE);
return Future.succeededFuture();
}
}).mapEmpty();
} else {
return Future.succeededFuture();
}
}, exception -> {
LOGGER.errorCr(reconciliation, "Status updated to [NotReady] due to error: {}", exception.getMessage());
return updateStatus(reconciliation, kafkaRebalance, new KafkaRebalanceStatus(), exception).mapEmpty();
});
}, exception -> {
LOGGER.errorCr(reconciliation, "Status updated to [NotReady] due to error: {}", exception.getMessage());
return updateStatus(reconciliation, kafkaRebalance, new KafkaRebalanceStatus(), exception).mapEmpty();
});
}
Aggregations