Skip to content

Add validate_only and timeout options to admin topic calls - #1092

Merged
mensfeld merged 4 commits into
masterfrom
50838-admin-options-validate-only-timeouts
Nov 3, 2026
Merged

mensfeld merged 4 commits into
masterfrom
50838-admin-options-validate-only-timeouts

Conversation

@coipond-coder

@coipond-coder coipond-coder Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

50838

Binds rd_kafka_AdminOptions_set_validate_only, rd_kafka_AdminOptions_set_operation_timeout and rd_kafka_AdminOptions_set_request_timeout, and exposes them as keyword options:

  • Admin#create_topic(name, partitions, rf, config = {}, validate_only: false, operation_timeout_ms: nil, request_timeout_ms: nil)
  • Admin#create_partitions(name, count, validate_only: false, operation_timeout_ms: nil, request_timeout_ms: nil)
  • Admin#delete_topic(name, operation_timeout_ms: nil, request_timeout_ms: nil) (librdkafka does not accept validate_only for DeleteTopics)

nil keeps librdkafka's defaults. A value librdkafka rejects (out of range) raises RdkafkaError (invalid_arg) synchronously, before anything is enqueued; the handle is unregistered and the options destroyed.

Braceless hash: once create_topic takes keywords, Ruby 3 reads create_topic("t", 1, 1, "retention.ms" => "1000") as keywords and would raise unknown keyword: "retention.ms". create_topic therefore captures other keywords (**braceless_topic_config) and merges them into topic_config, so that call keeps working, also next to the new options. No braceless call exists in Karafka::Admin (karafka passes topic_config as a variable) or in this repo's specs; specs cover the braceless String-key, Symbol-key and braces + braceless cases.

karafka-rdkafka port: karafka#613.

Tests

  • Unit: validate_only (no topic / partition count unchanged; invalid config, existing topic and invalid partition count still reported), both timeouts on all three calls, out of range values, and request_timeout_ms failing a request to an unreachable broker in ~1 s instead of 60 s.
  • Integration: spec/integrations/admin_validate_only_and_timeouts_spec.rb (passes locally on the plain compose broker).
  • Mutation check: ignoring validate_only turns two specs red.
  • spec/fixtures/bindings_signatures.json regenerated.

Performance impact

none (admin calls only; nothing changes when no option is given)

Bind rd_kafka_AdminOptions_set_validate_only, _set_operation_timeout and
_set_request_timeout. create_topic keeps accepting a topic config hash
passed without braces.
@coipond-coder
coipond-coder Bot marked this pull request as ready for review October 31, 2026 15:48
@coipond-coder
coipond-coder Bot requested a review from mensfeld October 31, 2026 15:48
@coipond-coder
coipond-coder Bot marked this pull request as draft November 2, 2026 11:27
…-validate-only-timeouts

# Conflicts:
#	CHANGELOG.md
@coipond-coder
coipond-coder Bot marked this pull request as ready for review November 2, 2026 12:17
@mensfeld
mensfeld merged commit 6f94522 into master Nov 3, 2026
169 checks passed
@mensfeld
mensfeld deleted the 50838-admin-options-validate-only-timeouts branch November 3, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant