Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] Fix to handle the exception for deletion of non-existing autofollow replication rule #1372

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class TransportAutoFollowClusterManagerNodeAction @Inject constructor(transportS
} catch(e: ResourceNotFoundException) {
// Log warn as the task is already removed
log.warn("Task already stopped for '$clusterAlias:$patternName'", e)
throw OpenSearchException("Autofollow replication rule $clusterAlias:$patternName does not exist")
} catch (e: Exception) {
log.error("Failed to stop auto follow task for cluster '$clusterAlias:$patternName'", e)
throw OpenSearchException(AUTOFOLLOW_EXCEPTION_GENERIC_STRING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,22 @@ class UpdateAutoFollowPatternIT: MultiClusterRestTestCase() {
.hasMessageContaining(errorMsg)
}

fun `test deletion of auto follow pattern`() {
val followerClient = getClientForCluster(FOLLOWER)
createConnectionBetweenClusters(FOLLOWER, LEADER, connectionAlias)
followerClient.updateAutoFollowPattern(connectionAlias, indexPatternName, indexPattern)
//Delete a replication rule which does not exist
Assertions.assertThatThrownBy {
followerClient.deleteAutoFollowPattern(connectionAlias, "dummy_conn")
}.isInstanceOf(ResponseException::class.java)
.hasMessageContaining("does not exist")
//Delete a replication rule which exists
Assertions.assertThatCode {
followerClient.deleteAutoFollowPattern(connectionAlias, indexPatternName)
}.doesNotThrowAnyException()

}

fun `test removing autofollow pattern stop autofollow task`() {
val followerClient = getClientForCluster(FOLLOWER)
val leaderClient = getClientForCluster(LEADER)
Expand Down
Loading