Skip to content

Commit

Permalink
Throw exception if replication is not enabled on the remote domain (#86)
Browse files Browse the repository at this point in the history
Surfacing the ActionNotFound exception as UnsupportedOperation if the remote cluster doesn't have replication artefacts.
  • Loading branch information
varunsrivathsav authored Aug 4, 2021
1 parent e60bcc2 commit c6b292f
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import org.elasticsearch.common.util.concurrent.ThreadContext
import org.elasticsearch.rest.RestStatus
import org.elasticsearch.tasks.Task
import org.elasticsearch.threadpool.ThreadPool
import org.elasticsearch.transport.ActionNotFoundTransportException
import org.elasticsearch.transport.RemoteTransportException
import org.elasticsearch.transport.TransportService
import java.util.function.Consumer
import java.util.function.Predicate
Expand Down Expand Up @@ -82,9 +84,13 @@ class TransportSetupChecksAction @Inject constructor(transportService: Transport
listener.onResponse(r)
},
{ e ->
var exceptionToThrow = e
if ((e is RemoteTransportException) && (e.cause is ActionNotFoundTransportException)) {
exceptionToThrow = UnsupportedOperationException("Replication is not enabled on the remote domain")
}
log.error("Permissions validation failed for role [connection:${request.connectionName}, " +
"resource:${request.leaderContext.resource}] with $e")
listener.onFailure(unwrapSecurityExceptionIfPresent(e))
"resource:${request.leaderContext.resource}] with $exceptionToThrow")
listener.onFailure(unwrapSecurityExceptionIfPresent(exceptionToThrow))
}
)

Expand All @@ -108,9 +114,13 @@ class TransportSetupChecksAction @Inject constructor(transportService: Transport
triggerPermissionsValidation(client, localClusterName, request.followerContext, true, rolePermissionsValidationAtLocal)
},
{ e ->
var exceptionToThrow = e
if ((e is RemoteTransportException) && (e.cause is ActionNotFoundTransportException)) {
exceptionToThrow = UnsupportedOperationException("Replication is not enabled on the remote domain")
}
log.error("Permissions validation failed for User [connection:${request.connectionName}, " +
"resource:${request.leaderContext.resource}] with $e")
listener.onFailure(unwrapSecurityExceptionIfPresent(e))
"resource:${request.leaderContext.resource}] with $exceptionToThrow")
listener.onFailure(unwrapSecurityExceptionIfPresent(exceptionToThrow))
}
)

Expand Down

0 comments on commit c6b292f

Please sign in to comment.