@@ -24,6 +24,7 @@ import com.amazon.opendistroforelasticsearch.indexstatemanagement.model.managedi
2424import com.amazon.opendistroforelasticsearch.indexstatemanagement.step.Step
2525import com.amazon.opendistroforelasticsearch.indexstatemanagement.util.evaluateConditions
2626import org.apache.logging.log4j.LogManager
27+ import org.elasticsearch.ExceptionsHelper
2728import org.elasticsearch.action.admin.indices.rollover.RolloverRequest
2829import org.elasticsearch.action.admin.indices.rollover.RolloverResponse
2930import org.elasticsearch.action.admin.indices.stats.IndicesStatsRequest
@@ -33,6 +34,7 @@ import org.elasticsearch.cluster.service.ClusterService
3334import org.elasticsearch.common.unit.ByteSizeValue
3435import org.elasticsearch.common.unit.TimeValue
3536import org.elasticsearch.rest.RestStatus
37+ import org.elasticsearch.transport.RemoteTransportException
3638import java.time.Instant
3739
3840@Suppress(" ReturnCount" , " TooGenericExceptionCaught" )
@@ -138,6 +140,8 @@ class AttemptRolloverStep(
138140 if (conditions.isEmpty()) null else " conditions" to conditions // don't show empty conditions object if no conditions specified
139141 ).toMap()
140142 }
143+ } catch (e: RemoteTransportException ) {
144+ handleException(ExceptionsHelper .unwrapCause(e) as Exception )
141145 } catch (e: Exception ) {
142146 handleException(e)
143147 }
@@ -173,21 +177,16 @@ class AttemptRolloverStep(
173177 " message" to message,
174178 " shard_failures" to statsResponse.shardFailures.map { it.getUsefulCauseString() }
175179 )
180+ } catch (e: RemoteTransportException ) {
181+ handleException(ExceptionsHelper .unwrapCause(e) as Exception )
176182 } catch (e: Exception ) {
177- val message = getFailedEvaluateMessage(indexName)
178- logger.error(message, e)
179- stepStatus = StepStatus .FAILED
180- val mutableInfo = mutableMapOf (" message" to message)
181- val errorMessage = e.message
182- if (errorMessage != null ) mutableInfo[" cause" ] = errorMessage
183- info = mutableInfo.toMap()
183+ handleException(e, getFailedEvaluateMessage(indexName))
184184 }
185185
186186 return null
187187 }
188188
189- private fun handleException (e : Exception ) {
190- val message = getFailedMessage(indexName)
189+ private fun handleException (e : Exception , message : String = getFailedMessage(indexName)) {
191190 logger.error(message, e)
192191 stepStatus = StepStatus .FAILED
193192 val mutableInfo = mutableMapOf (" message" to message)
0 commit comments