I am trying to create a Python script to automate topic creation and configuration.
I have managed to make the topic creation part work. I get a runtime error when trying to alter the configuration.
ValueError: expected non-empty list of ConfigEntry to alter incrementally in incremental_configs field
Here's my code:
config = {
'min.insync.replicas': '3'
}
resource = ConfigResource(ResourceType.TOPIC, name=topic_name, set_config=config, described_configs=None)
futures = admin_client.incremental_alter_configs(resources=[resource])
for config_resource, future in futures.items():
try:
future.result()
print(f'Updated topic config for topic {config_resource}')
except Exception as exception:
print(f'Failed to update topic config for topic {config_resource}, {exception}')
I found the documentation quite hard to follow.
I based this code on this example. It seemed from reading the docs altering the config could be done in a similar way to topic creation. I am not totally sure what is wrong.
Some helpful debug info, helps to explain what the data structure of
ConfigEntryitems should be:Solution
If you want to do more than once config at once: