Skip to content

Add support for altering and partially resetting connector offsets - #405

Open
AfrinKhan02 wants to merge 5 commits into
mainfrom
feat/alter-partial-reset-offset
Open

Add support for altering and partially resetting connector offsets#405
AfrinKhan02 wants to merge 5 commits into
mainfrom
feat/alter-partial-reset-offset

Conversation

@AfrinKhan02

Copy link
Copy Markdown
Collaborator

Context

The first feature of the connector offset epic introduced support for fully resetting connector offsets in michelin/kafkactl#380.

This change extends that flow so users can alter or partially reset source connector offsets directly from kafkactl. It allows users to target specific source partitions and either assign a connector-specific offset or reset the selected partition by setting its offset to null.

The corresponding Ns4Kafka API support is implemented in michelin/ns4kafka#826.

Proposed solution

I introduced a dedicated CLI flow for connector offset alteration through:

kafkactl connector alter-offsets <connector-name> -f <offsets-file>

The command accepts a YAML payload using the Kafka Connect alter-offsets format. This keeps the operation aligned with the existing connector command structure while supporting both targeted offset alteration and partial reset.

Example payload:

offsets:
  - partition:
      task.id: 0
    offset:
      current.iteration: 100
  - partition:
      task.id: 1
    offset: null

Implementation

I added a connector offsets request model representing the Kafka Connect offsets payload.

I then added client-side support for the Ns4Kafka endpoint:

PATCH /api/namespaces/{namespace}/connectors/{connector}/offsets

The new endpoint is wired through the resource service, including standard response, not-found, and HTTP error handling.

On the CLI side, I added and registered the connector alter-offsets subcommand. The command:

  • accepts one connector name and a required YAML file
  • parses the connector-specific partition and offset payload
  • sends the payload to Ns4Kafka
  • displays the existing ConnectorResetOffsetsResponse result

I also updated the README with command usage and examples for altering or partially resetting connector offsets.

Tests

I added command-level tests covering:

  • YAML payload parsing and forwarding
  • successful offset alteration and response display
  • empty response handling
  • access to the alter-offsets subcommand help without parent parameters

I added service-level tests covering:

  • successful API delegation
  • not-found response handling
  • generic HTTP failure handling

The full test suite and Spotless checks pass.

Remark

This change complements the full connector offset reset introduced in michelin/kafkactl#380. Together, the two commands support both complete reset and targeted alteration or partial reset of connector offsets.

The server-side implementation used by this command is available in michelin/ns4kafka#826.

@sonarqubecloud

Copy link
Copy Markdown

@AfrinKhan02
AfrinKhan02 marked this pull request as ready for review August 4, 2026 09:01
@AfrinKhan02 AfrinKhan02 self-assigned this Aug 4, 2026
@AfrinKhan02 AfrinKhan02 added the feature This issue or pull request contains a new feature label Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature This issue or pull request contains a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant