mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(pipes): register kafka-clients reflection metadata for native image (#2068)
* fix(pipes): register kafka-clients reflection metadata for native image Kafka and MSK pipe sources worked on the JVM but silently delivered nothing from the native image. kafka-clients ships no native-image metadata, and Floci depends on it directly rather than through the Quarkus Kafka extension, so AbstractConfig could not resolve the consumer's CLASS-typed settings: poll error: Invalid value org.apache.kafka.common.serialization.ByteArrayDeserializer for configuration key.deserializer: Class ... could not be found (ConfigException) PipesPoller catches that per poll cycle and logs a warning, so the pipe stayed reported as RUNNING while no records reached the target. The registered list is what the GraalVM tracing agent recorded across a self-managed Kafka pipe and an MSK pipe run end to end. SASL and SSL defaults are excluded: Floci connects over PLAINTEXT, and registering DefaultJwtValidator aborts the native build because its constructor references jose4j, an optional kafka-clients dependency Floci does not ship. * fix(pipes): narrow Kafka reflection list to config-resolved classes The registration carried three entries the GraalVM tracing agent reported but ConsumerConfig never resolves: AppInfoParser.AppInfo, AppInfoParser.AppInfoMBean and the shaded ExtensionRegistry. The guard test derives its expectations from ConsumerConfig, so it could not see them — dropping one would have left the test green while native regressed. Native runs deliver 5/5 on both self-managed Kafka and MSK without them, with AppInfoParser and the telemetry reporter logging normally, so they are removed rather than pinned by a change-detector assertion. The registration is now exactly the config-resolved set and the test asserts equality in both directions, so list and guard cannot drift. Also fixes a hole in the test itself: metric.reporters resolves to a class name rather than a Class, so JmxReporter was registered but unguarded. Collection now mirrors AbstractConfig.getConfiguredInstances and accepts both forms. * fix(pipes): guard the reflection list against the real consumer properties PipesKafkaNativeSupportTest re-declared the properties createConsumer sets instead of reading them, so it was pinned to a copy. Adding a config-resolved setting such as interceptor.classes — or the sasl.* that MSK IAM auth would need — left the test green while the native build lost a registration and the consumer failed silently through the PipesPoller swallow this PR exists to close. consumerProperties is now package-private, createConsumer calls it, and the test reads it, so the registration and its guard cannot drift. Also corrects the test javadoc: the compatibility suite already runs against the native image, it just has no Kafka source case yet. * fix(pipes): disable KIP-714 metrics push for pipe consumers enable.metrics.push defaults to true, so a pipe consumer would push client telemetry to the user's broker given one that advertises support. Floci has no reason to do that. It also closed an open question from the previous commit. The tracing agent recorded a reflective lookup on the shaded protobuf ExtensionRegistry, which is only reachable through the telemetry path — and neither apache/kafka nor the Redpanda container Floci starts for MSK ships a ClientTelemetry plugin, so no broker available to us exercises it. Turning the push off removes the question rather than leaving it untested. Verified against the native image: both self-managed Kafka and MSK pipes deliver 5/5 to SQS, and ClientTelemetryReporter no longer appears in the logs. Binary size is unchanged at 202.1MB — the telemetry classes stay statically reachable, only the reflective path goes away.
This commit is contained in:
1 parent
96c7aa68ee
commit
ab733798a3
3 files changed
+169
-5
No files matched your search
+14
-5
@@ -131,13 +131,12 @@ public class PipesKafkaConsumerManager {
|
||||
return resolveConsumerGroupId(pipe, kafkaParameters(pipe));
|
||||
}
|
||||
|
||||
private KafkaConsumer<byte[], byte[]> createConsumer(Pipe pipe) {
|
||||
String bootstrapServers = resolveBootstrapServers(pipe);
|
||||
String topicName = resolveTopicName(pipe);
|
||||
/** Package-private so {@code PipesKafkaNativeSupportTest} guards the real settings, not a copy. */
|
||||
Properties consumerProperties(Pipe pipe) {
|
||||
JsonNode params = kafkaParameters(pipe);
|
||||
|
||||
Properties properties = new Properties();
|
||||
properties.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
|
||||
properties.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, resolveBootstrapServers(pipe));
|
||||
properties.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, ByteArrayDeserializer.class.getName());
|
||||
properties.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, ByteArrayDeserializer.class.getName());
|
||||
properties.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "false");
|
||||
@@ -145,11 +144,21 @@ public class PipesKafkaConsumerManager {
|
||||
properties.put(ConsumerConfig.GROUP_ID_CONFIG, resolveConsumerGroupId(pipe, params));
|
||||
properties.put(ConsumerConfig.CLIENT_ID_CONFIG, "floci-pipes-" + UUID.randomUUID());
|
||||
properties.put(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, Integer.toString(resolveBatchSize(pipe, 100)));
|
||||
// On by default (KIP-714). Floci has no reason to push metrics to a user's broker, and it
|
||||
// makes the shaded protobuf serializer reflectively reachable on a path no broker we test
|
||||
// against exercises.
|
||||
properties.put(ConsumerConfig.ENABLE_METRICS_PUSH_CONFIG, "false");
|
||||
return properties;
|
||||
}
|
||||
|
||||
private KafkaConsumer<byte[], byte[]> createConsumer(Pipe pipe) {
|
||||
Properties properties = consumerProperties(pipe);
|
||||
String topicName = resolveTopicName(pipe);
|
||||
|
||||
KafkaConsumer<byte[], byte[]> consumer = new KafkaConsumer<>(properties);
|
||||
consumer.subscribe(List.of(topicName));
|
||||
LOG.infov("Pipe {0}: subscribed Kafka consumer to topic {1} via {2}",
|
||||
pipe.getName(), topicName, bootstrapServers);
|
||||
pipe.getName(), topicName, properties.get(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG));
|
||||
return consumer;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package io.github.hectorvent.floci.services.pipes;
|
||||
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import org.apache.kafka.clients.consumer.CooperativeStickyAssignor;
|
||||
import org.apache.kafka.clients.consumer.RangeAssignor;
|
||||
import org.apache.kafka.common.metrics.JmxReporter;
|
||||
import org.apache.kafka.common.serialization.ByteArrayDeserializer;
|
||||
|
||||
/**
|
||||
* Registers the kafka-clients classes that GraalVM cannot discover statically.
|
||||
*
|
||||
* <p>kafka-clients ships no native-image metadata and Floci uses it directly rather than through
|
||||
* the Quarkus Kafka extension. {@code AbstractConfig} resolves {@code CLASS}-typed settings by
|
||||
* name, so without these a native build cannot construct a consumer — which {@link PipesPoller}
|
||||
* swallows per poll cycle, leaving the pipe RUNNING and delivering nothing.
|
||||
*
|
||||
* <p>Entries are exactly what {@link PipesKafkaConsumerManager#consumerProperties} resolves, and
|
||||
* {@code PipesKafkaNativeSupportTest} reads that same method, so the two cannot drift.
|
||||
*
|
||||
* <p>SASL and SSL defaults are excluded: Floci is PLAINTEXT-only, and {@code DefaultJwtValidator}
|
||||
* fails the native build by referencing jose4j, an optional dependency Floci omits.
|
||||
*/
|
||||
@RegisterForReflection(targets = {
|
||||
// key.deserializer / value.deserializer — set explicitly by PipesKafkaConsumerManager
|
||||
ByteArrayDeserializer.class,
|
||||
// partition.assignment.strategy — ConsumerConfig defaults
|
||||
RangeAssignor.class,
|
||||
CooperativeStickyAssignor.class,
|
||||
// metric.reporters — ConsumerConfig default
|
||||
JmxReporter.class
|
||||
})
|
||||
public class PipesKafkaNativeSupport {
|
||||
}
|
||||
Reference in new issue
Block a user