confluentinc / confluent-kafka-go

Confluent's Apache Kafka Golang client
Apache License 2.0
4.66k stars 658 forks source link

[AdminApi] Dynamically Changing Cluster-Wide Configs does not work #396

Open twiechert opened 5 years ago

twiechert commented 5 years ago

Description

Analyzing the bundled kafka client tools, the admin protocol expects resource name set to <default> when dynamically changing cluster-wide properties. However, trying to change a cluster property such as background.threads referring to ConnfigResource.name == <default>yields the following error generated in librdkafka.

error: Expected an int32 broker_id for ConfigResource(type=BROKER, name=<default>)

I am not sure if this is a limitation of the librdkafka implementation in general or the way the go client interacts with the librdkafka api.

How to reproduce

    var cfgEntry = kafka.ConfigEntry{Name: "background.threads", Value: "11", Operation: kafka.AlterOperationSet}

        var resourceType, _ = kafka.ResourceTypeFromString("BROKER")
        cfg[0] = cfgEntry
        configResource := kafka.ConfigResource{Type: resourceType, Name: "<default>", Config: cfg}
        configResources[0] = configResource
        if result, e := c.AlterConfigs(ctx, configResources); e == nil {
            log.Info(fmt.Sprintf("Successfully applied %v changes.", len(result)))
        } 

Checklist

Please provide the following information:

edenhill commented 4 years ago

Good find, seems like we need to add support for default entity names. In the case of BROKER the default name is empty, which I believe the librdkafka API disallows at this point.