use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogs in project stackgres by ongres.
the class Fluentd method buildSource.
@NotNull
public HasMetadata buildSource(StackGresDistributedLogsContext context) {
final StackGresDistributedLogs cluster = context.getSource();
final String namespace = cluster.getMetadata().getNamespace();
final Map<String, String> data = ImmutableMap.of("fluentd.conf", getFluentdConfig(context));
final Map<String, String> clusterLabels = labelFactory.clusterLabels(cluster);
final ConfigMap configMap = new ConfigMapBuilder().withNewMetadata().withNamespace(namespace).withName(FluentdUtil.configName(cluster)).withLabels(clusterLabels).endMetadata().withData(data).build();
return configMap;
}
use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogs in project stackgres by ongres.
the class DistributedLogsReferenceValidatorTest method giveAnAttemptToUpdateToAnKnownProfile_shouldNotFail.
@Test
void giveAnAttemptToUpdateToAnKnownProfile_shouldNotFail() throws ValidationFailed {
final StackGresClusterReview review = JsonUtil.readFromJson("cluster_allow_requests/distributed_logs_update.json", StackGresClusterReview.class);
String distributedLogsName = review.getRequest().getObject().getSpec().getDistributedLogs().getDistributedLogs();
String namespace = review.getRequest().getObject().getMetadata().getNamespace();
StackGresDistributedLogs distributedLogs = JsonUtil.readFromJson("distributedlogs/default.json", StackGresDistributedLogs.class);
when(distributedLogsFinder.findByNameAndNamespace(distributedLogsName, namespace)).thenReturn(Optional.of(distributedLogs));
validator.validate(review);
verify(distributedLogsFinder).findByNameAndNamespace(anyString(), anyString());
}
use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogs in project stackgres by ongres.
the class DistributedLogsControllerReconciliator method reconcile.
@SuppressFBWarnings(value = "REC_CATCH_EXCEPTION", justification = "False positives")
@Override
protected ReconciliationResult<Void> reconcile(KubernetesClient client, StackGresDistributedLogsContext context) throws Exception {
boolean statusUpdated = false;
ReconciliationResult<Boolean> extensionReconciliationResult = extensionReconciliator.reconcile(client, context);
if (extensionReconciliationResult.result().orElse(false) && context.getCluster().getStatus() != null && context.getCluster().getStatus().getPodStatuses() != null) {
if (context.getDistributedLogs().getStatus() == null) {
context.getDistributedLogs().setStatus(new StackGresDistributedLogsStatus());
}
context.getDistributedLogs().getStatus().setPodStatuses(context.getCluster().getStatus().getPodStatuses());
}
ReconciliationResult<Boolean> clusterReconciliationResult = clusterReconciliator.reconcile(client, context);
statusUpdated = statusUpdated || clusterReconciliationResult.result().orElse(false);
if (extensionReconciliationResult.result().orElse(false) || clusterReconciliationResult.result().orElse(false)) {
distributedLogsScheduler.updateStatus(context.getDistributedLogs(), StackGresDistributedLogs::getStatus, StackGresDistributedLogs::setStatus);
}
return extensionReconciliationResult.join(clusterReconciliationResult);
}
use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogs in project stackgres by ongres.
the class EventController method sendEvent.
/**
* Send an event.
*/
public void sendEvent(EventReason reason, String message, KubernetesClient client) {
StackGresDistributedLogs distributedLogs = distributedLogsFinder.findByNameAndNamespace(DistributedLogsControllerProperty.DISTRIBUTEDLOGS_NAME.getString(), DistributedLogsControllerProperty.DISTRIBUTEDLOGS_NAMESPACE.getString()).orElse(null);
sendEvent(reason, message, distributedLogs, client);
}
use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogs in project stackgres by ongres.
the class ResourceWatcherFactory method onError.
@Override
public void onError(WatcherException cause) {
StackGresDistributedLogs distributedLogs = distributedLogsFinder.findByNameAndNamespace(DistributedLogsControllerProperty.DISTRIBUTEDLOGS_NAME.getString(), DistributedLogsControllerProperty.DISTRIBUTEDLOGS_NAMESPACE.getString()).orElse(null);
eventEmitter.sendEvent(DistributedLogsControllerEventReason.DISTRIBUTEDLOGS_CONTROLLER_ERROR, "Watcher was closed unexpectedly: " + (cause.getMessage() != null ? cause.getMessage() : "unknown reason"), distributedLogs);
}
Aggregations