Skip to content

Commit 25bf514

Browse files
committed
expose errors
1 parent 318bcc9 commit 25bf514

File tree

2 files changed

+45
-30
lines changed

2 files changed

+45
-30
lines changed

.dev/dev_arm64.yaml

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This is a compose file designed for arm64/Apple Silicon systems
2-
# To adapt this to x86 please find and replace ".arm64" with empty
2+
# To adapt this to x86 please find and replace "" with empty
33

44
# ARM64 supported images for kafka can be found here
55
# https://hub.docker.com/r/confluentinc/cp-kafka/tags?page=1&name=arm64
@@ -9,36 +9,37 @@ name: "kafbat-ui-dev"
99

1010
services:
1111

12-
kafbat-ui:
13-
container_name: kafbat-ui
14-
image: ghcr.io/kafbat/kafka-ui:latest
15-
ports:
16-
- 8080:8080
17-
depends_on:
18-
- kafka0
19-
- schema-registry0
20-
- kafka-connect0
21-
- ksqldb0
22-
environment:
23-
KAFKA_CLUSTERS_0_NAME: local
24-
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka0:29092
25-
KAFKA_CLUSTERS_0_METRICS_PORT: 9997
26-
KAFKA_CLUSTERS_0_SCHEMAREGISTRY: http://schema-registry0:8085
27-
KAFKA_CLUSTERS_0_KAFKACONNECT_0_NAME: first
28-
KAFKA_CLUSTERS_0_KAFKACONNECT_0_ADDRESS: http://kafka-connect0:8083
29-
KAFKA_CLUSTERS_0_KSQLDBSERVER: http://ksqldb0:8088
30-
DYNAMIC_CONFIG_ENABLED: 'true'
31-
KAFKA_CLUSTERS_0_AUDIT_TOPICAUDITENABLED: 'true'
32-
KAFKA_CLUSTERS_0_AUDIT_CONSOLEAUDITENABLED: 'true'
12+
#kafbat-ui:
13+
# container_name: kafbat-ui
14+
# image: ghcr.io/kafbat/kafka-ui:latest
15+
# ports:
16+
# - 8080:8080
17+
# depends_on:
18+
# - kafka0
19+
# - schema-registry0
20+
# - kafka-connect0
21+
# - ksqldb0
22+
# environment:
23+
# KAFKA_CLUSTERS_0_NAME: local
24+
# KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka0:29092
25+
# KAFKA_CLUSTERS_0_METRICS_PORT: 9997
26+
# KAFKA_CLUSTERS_0_SCHEMAREGISTRY: http://schema-registry0:8085
27+
# KAFKA_CLUSTERS_0_KAFKACONNECT_0_NAME: first
28+
# KAFKA_CLUSTERS_0_KAFKACONNECT_0_ADDRESS: http://kafka-connect0:8083
29+
# KAFKA_CLUSTERS_0_KSQLDBSERVER: http://ksqldb0:8088
30+
# DYNAMIC_CONFIG_ENABLED: 'true'
31+
# KAFKA_CLUSTERS_0_AUDIT_TOPICAUDITENABLED: 'true'
32+
# KAFKA_CLUSTERS_0_AUDIT_CONSOLEAUDITENABLED: 'true'
3333

3434
kafka0:
35-
image: confluentinc/cp-kafka:7.6.0.arm64
35+
image: confluentinc/cp-kafka:7.6.0
3636
user: "0:0"
3737
hostname: kafka0
3838
container_name: kafka0
3939
ports:
4040
- 9092:9092
4141
- 9997:9997
42+
- 29092:29092
4243
environment:
4344
KAFKA_BROKER_ID: 1
4445
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,CONTROLLER:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
@@ -55,12 +56,12 @@ services:
5556
KAFKA_CONTROLLER_LISTENER_NAMES: 'CONTROLLER'
5657
KAFKA_LOG_DIRS: '/tmp/kraft-combined-logs'
5758
KAFKA_JMX_PORT: 9997
58-
# KAFKA_JMX_HOSTNAME: localhost # uncomment this line and comment the next one if running with kafka-ui as a jar
59+
KAFKA_JMX_HOSTNAME: localhost # uncomment this line and comment the next one if running with kafka-ui as a jar
5960
KAFKA_JMX_OPTS: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=kafka0 -Dcom.sun.management.jmxremote.rmi.port=9997
6061
CLUSTER_ID: 'MkU3OEVBNTcwNTJENDM2Qk'
6162

6263
schema-registry0:
63-
image: confluentinc/cp-schema-registry:7.6.0.arm64
64+
image: confluentinc/cp-schema-registry:7.6.0
6465
ports:
6566
- 8085:8085
6667
depends_on:
@@ -76,7 +77,7 @@ services:
7677
SCHEMA_REGISTRY_KAFKASTORE_TOPIC: _schemas
7778

7879
kafka-connect0:
79-
image: confluentinc/cp-kafka-connect:7.6.0.arm64
80+
image: confluentinc/cp-kafka-connect:7.6.0
8081
ports:
8182
- 8083:8083
8283
depends_on:
@@ -101,7 +102,7 @@ services:
101102
CONNECT_PLUGIN_PATH: "/usr/share/java,/usr/share/confluent-hub-components,/usr/local/share/kafka/plugins,/usr/share/filestream-connectors"
102103

103104
ksqldb0:
104-
image: confluentinc/cp-ksqldb-server:7.6.0.arm64
105+
image: confluentinc/cp-ksqldb-server:7.6.0
105106
depends_on:
106107
- kafka0
107108
- kafka-connect0
@@ -119,7 +120,7 @@ services:
119120
KSQL_CACHE_MAX_BYTES_BUFFERING: 0
120121

121122
kafka-init-topics:
122-
image: confluentinc/cp-kafka:7.6.0.arm64
123+
image: confluentinc/cp-kafka:7.6.0
123124
volumes:
124125
- ../documentation/compose/data/message.json:/data/message.json
125126
depends_on:

api/src/main/java/io/kafbat/ui/client/RetryingKafkaConnectClient.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.kafbat.ui.client;
22

3+
import com.fasterxml.jackson.annotation.JsonCreator;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
35
import io.kafbat.ui.config.ClustersProperties;
46
import io.kafbat.ui.connect.ApiClient;
57
import io.kafbat.ui.connect.api.KafkaConnectClientApi;
@@ -17,6 +19,7 @@
1719
import java.time.Duration;
1820
import java.util.List;
1921
import java.util.Map;
22+
import java.util.Objects;
2023
import javax.annotation.Nullable;
2124
import lombok.extern.slf4j.Slf4j;
2225
import org.springframework.http.ResponseEntity;
@@ -56,10 +59,21 @@ private static <T> Flux<T> withRetryOnConflict(Flux<T> publisher) {
5659
return publisher.retryWhen(conflictCodeRetry());
5760
}
5861

62+
// Adapted from https://github.com/apache/kafka/blob/a0a501952b6d61f6f273bdb8f842346b51e9dfce/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/entities/ErrorMessage.java#L35
63+
private record ErrorMessage(@JsonProperty("message") String message) {
64+
}
65+
5966
private static <T> Mono<T> withBadRequestErrorHandling(Mono<T> publisher) {
6067
return publisher
61-
.onErrorResume(WebClientResponseException.BadRequest.class, e ->
62-
Mono.error(new ValidationException("Invalid configuration")))
68+
.onErrorResume(WebClientResponseException.BadRequest.class, e -> {
69+
final var errorMessage = e.getResponseBodyAs(ErrorMessage.class);
70+
71+
if (errorMessage != null && errorMessage.message() != null) {
72+
return Mono.error(new ValidationException(errorMessage.message()));
73+
}
74+
75+
return Mono.error(new ValidationException("Invalid configuration"));
76+
})
6377
.onErrorResume(WebClientResponseException.InternalServerError.class, e ->
6478
Mono.error(new ValidationException("Invalid configuration")));
6579
}

0 commit comments

Comments
 (0)