Skip to content

Commit

Permalink
Fix cluster_id allocation not on tmpabuf
Browse files Browse the repository at this point in the history
  • Loading branch information
milindl committed Jun 26, 2023
1 parent 4a4d9df commit 8c2b4d4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/rdkafka_admin.c
Original file line number Diff line number Diff line change
Expand Up @@ -7445,7 +7445,6 @@ rd_kafka_DescribeClusterResponse_parse(rd_kafka_op_t *rko_req,
cluster_id, controller_id, authorized_operations, &mdi->metadata);
if (authorized_operations)
rd_list_destroy(authorized_operations);
rd_free(cluster_id);

rd_list_add(&rko_result->rko_u.admin_result.results, clusterdesc);
*rko_resultp = rko_result;
Expand Down
13 changes: 6 additions & 7 deletions src/rdkafka_metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,19 +568,18 @@ rd_kafka_resp_err_t rd_kafka_parse_Metadata(rd_kafka_broker_t *rkb,
rd_kafka_buf_skip_tags(rkbuf);
}

if (ApiVersion >= 2)
rd_kafka_buf_read_str_tmpabuf(rkbuf, &tbuf, mdi->cluster_id);
else
mdi->cluster_id = NULL;

if (ApiVersion >= 2) {
rd_kafka_buf_read_str(rkbuf, &cluster_id);
mdi->cluster_id = rd_tmpabuf_write_str(&tbuf, cluster_id.str);
}


if (ApiVersion >= 1) {
rd_kafka_buf_read_i32(rkbuf, &controller_id);
mdi->controller_id = controller_id;
rd_rkb_dbg(rkb, METADATA, "METADATA",
"ClusterId: %s, ControllerId: %" PRId32,
mdi->cluster_id, controller_id);
"ClusterId: %.*s, ControllerId: %" PRId32,
RD_KAFKAP_STR_PR(&cluster_id), controller_id);
}

qsort(mdi->brokers, md->broker_cnt, sizeof(mdi->brokers[i]),
Expand Down
3 changes: 3 additions & 0 deletions tests/0081-admin.c
Original file line number Diff line number Diff line change
Expand Up @@ -3218,6 +3218,9 @@ static void do_test_DescribeCluster(const char *what,
/* Sanity checks on fields inside the result. There's not much we can
* say here deterministically, since it depends on the test environment.
*/
TEST_ASSERT(
strlen(rd_kafka_ClusterDescription_cluster_id(result_cluster)),
"Length of cluster id should be non-null.");
TEST_ASSERT(rd_kafka_ClusterDescription_node_count(result_cluster),
"Expected non-zero node count in cluster.");
node = rd_kafka_ClusterDescription_node(result_cluster, 0);
Expand Down

0 comments on commit 8c2b4d4

Please sign in to comment.