Skip to content

Add a functionality to fully reset connector offsets#821

Open
AfrinKhan02 wants to merge 9 commits into
masterfrom
feat/connector-full-reset-offsets
Open

Add a functionality to fully reset connector offsets#821
AfrinKhan02 wants to merge 9 commits into
masterfrom
feat/connector-full-reset-offsets

Conversation

@AfrinKhan02
Copy link
Copy Markdown
Collaborator

Context

Kafka Connect exposes dedicated offsets endpoints that allow administrators to inspect, alter, and reset connector offsets.

This PR adds support in Ns4Kafka for resetting connector offsets through the Kafka Connect REST API so Kafka admins can trigger the operation directly from the Ns4Kafka controller layer.

Referred API: https://docs.confluent.io/platform/current/connect/references/restapi.html#offsets

Proposed Solution

Add a dedicated Ns4Kafka endpoint for connector offset reset:

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

The endpoint delegates the reset operation to Kafka Connect and returns the exact success message coming back from Kafka Connect so the caller can see the result directly.

Implementation

I added a dedicated controller endpoint to reset offsets for a connector owned by a namespace.

I then wired that endpoint through the connector service down to the Kafka Connect client using Kafka Connect's offsets reset endpoint:

DELETE /connectors/{connector}/offsets

On the Kafka Connect client side, I added a small response model to deserialize the message returned by Kafka Connect and forward it back through Ns4Kafka instead of returning an empty body.

The implementation keeps the change focused on the Full reset-offsets use case and aligned with the current controller and service patterns already used in Ns4Kafka.

Tests

I added focused coverage for the new reset-offsets flow:

  • controller tests for namespace ownership, connector not found, and successful reset through the dedicated endpoint
  • service tests for delegation to Kafka Connect and propagation of the success response

The existing connector-focused tests were updated to validate the returned Kafka Connect message as part of the reset-offsets flow.

Remark

This PR intentionally keeps reset-offsets as a dedicated controller endpoint and does not expose it through the generic connector change-state API.

Kafka Connect requires connectors to be stopped before offsets can be reset. Also this Pr is dedicated for Full Reset offset and not Partial /Alter offsets

@AfrinKhan02 AfrinKhan02 marked this pull request as ready for review June 2, 2026 18:27
@AfrinKhan02 AfrinKhan02 self-assigned this Jun 2, 2026
@AfrinKhan02 AfrinKhan02 added the feature This issue or pull request contains a new feature label Jun 2, 2026
@AfrinKhan02 AfrinKhan02 requested a review from ThomasCAI-mlv June 2, 2026 18:27
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 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