Reputation: 1
I am trying to write Python code that configures producer bandwidth quotas on user principals, something we currently do using the Kafka CLI scripts and Ansible. However, the documentation for the Confluent Kafka Python AdminClient doesn't seemingly allow for "user" ResourceType configurations to be created, and no matter what I try, I can't find a combination that works.
The current CLI method:
/usr/bin/kafka-configs
{{ kafka_bootstrap_options }}
--entity-type users
--entity-name "NameOfUserPrincipal"
--alter
--add-config producer_byte_rate=256000
This is what I am trying to recreate using Python instead.
I've been trying all kinds of combinations of ResourceType values, and figured maybe what the CLI tools call "user" is what the Python code calls "TRANSACTIONAL_ID":
cr = ConfigResource(
restype=ResourceType.TRANSACTIONAL_ID,
name="NameOfUserPrincipal"
incremental_configs=[
ConfigEntry(
name="producer_byte_rate",
value="2097152",
incremental_operation=AlterConfigOpType.APPEND
)
]
)
fs = a.incremental_alter_configs([cr])
for res, f in fs.items():
try:
f.result() # empty, but raises exception on failure
print("{} configuration successfully altered".format(res))
except Exception:
raise
However, I always end up with the following exception:
KafkaException: KafkaError{code=INVALID_REQUEST,val=42,str="Unknown resource type 5"}
I don't understand if I am doing something wrong, or if this is a genuine bug, since ResourceType 5 does exist, and is documented in the code documentation.
Since I also can't find any mention of or example how to configure producer bandwidth quotas anywhere in the code docs, it's hard to know what they intend for me to do in order to apply configurations to a "user" entity-type.
Upvotes: 0
Views: 16