Ingestion from a kafka topic fails when sample data is enabled
Affected module Ingestion Framework
Describe the bug When attempting to ingest metadata from a Kafka topic, where sample data is enabled, the ingestion fails when trying to sample data, with authentication errors:
File "/Users/cristicalugaru/.pyenv/versions/3.9.12/envs/open-metadata/lib/python3.9/site-packages/metadata/ingestion/source/kafka.py", line 219, in _get_sample_data
str(avro_serde.value.deserialize(message.value()))
File "/Users/cristicalugaru/.pyenv/versions/3.9.12/envs/open-metadata/lib/python3.9/site-packages/confluent_avro/serde.py", line 57, in deserialize
decoder = self._get_decoder(schema_id)
File "/Users/cristicalugaru/.pyenv/versions/3.9.12/envs/open-metadata/lib/python3.9/site-packages/confluent_avro/serde.py", line 84, in _get_decoder
schema_str = self.sr.get_schema(schema_id)
File "/Users/cristicalugaru/.pyenv/versions/3.9.12/envs/open-metadata/lib/python3.9/site-packages/confluent_avro/schema_registry/errors.py", line 109, in wrapper
raise UnauthorizedAccess(client_error.details)
confluent_avro.schema_registry.errors.UnauthorizedAccess: {'error_code': 401, 'message': 'Unauthorized', 'status_code': 401}
To Reproduce Ingest Kafka metadata from the command line, enabling generateSampleData flag.
Screenshots or steps to reproduce Sample ingestion yaml file:
source:
type: kafka
serviceName: the_service_name
serviceConnection:
config:
type: Kafka
bootstrapServers: the_server:9092
schemaRegistryURL: https://schema_server
consumerConfig:
security.protocol: SASL_SSL
sasl.mechanism: PLAIN
sasl.username: username
sasl.password: pass
schemaRegistryConfig:
basic.auth.user.info: schema_user:schema_pass
sourceConfig:
config:
topicFilterPattern:
includes:
- my_topic
generateSampleData: true
sink:
type: metadata-rest
config: {}
workflowConfig:
openMetadataServerConfig:
hostPort: http://localhost:8585/api
authProvider: no-auth
Expected behavior Ingestion should succeed
Version:
- OS: Mac OS Monterey
- Python version: 3.9.12
- OpenMetadata version: 0.10.12
- OpenMetadata Ingestion package version: [e.g.
openmetadata-ingestion[docker]==0.10.12]
Additional context Work around that fixes the issue: in metadata/ingestion/source/kafka.py line 207-211, add an auth parameter when initialising the SchemaRegistry:
registry_client = SchemaRegistry(
url=self.service_connection.schemaRegistryURL,
auth=self.connection.schema_registry_client._rest_client.session.auth,
headers={"Content-Type": "application/vnd.schemaregistry.v1+json"},
)
@cristiancalugaru can you please review it as well https://github.com/open-metadata/OpenMetadata/pull/5536