Skip to content

Add Ns4Kafka validation before connector offsets reset#858

Draft
AfrinKhan02 wants to merge 3 commits into
masterfrom
feat/explicit-ns4kafka-stop-connector
Draft

Add Ns4Kafka validation before connector offsets reset#858
AfrinKhan02 wants to merge 3 commits into
masterfrom
feat/explicit-ns4kafka-stop-connector

Conversation

@AfrinKhan02

Copy link
Copy Markdown
Collaborator

Context

This PR adds the follow-up validation that was discussed during the review of #821.

Today, when a user tries to reset offsets for a connector that is not stopped, Ns4Kafka delegates the call to Kafka Connect and surfaces the downstream failure. In practice, that ends up returning a Kafka Connect error instead of an Ns4Kafka-owned validation message.

Proposed solution

Add an explicit validation in Ns4Kafka before sending the reset request to Kafka Connect.

If the connector is not in the STOPPED state, Ns4Kafka now fails earlier with its own ResourceValidationException and a dedicated message that tells the user to stop the connector first before retrying the reset.

Implementation

I kept the change intentionally small and aligned with the existing code structure introduced by #821.

The implementation adds a connector status check in the reset-offsets service path before calling Kafka Connect reset.

On the service side, the reset flow now:

  • queries the current connector status from Kafka Connect
  • validates that the connector is in the STOPPED state
  • throws a ResourceValidationException with an Ns4Kafka-specific message when the connector is not stopped
  • delegates to Kafka Connect reset only when the validation succeeds

Tests

The test scope covers:

  • successful connector offsets reset when the connector is already STOPPED
  • validation failure when the connector is not stopped
  • verification that Kafka Connect reset is not called when the precondition is not met

Remark

This PR is specifically meant to cater the remaining review requirement from #821.

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant