From ffabd8692767fb39cb3fd5bd3e4d7d74b62d51af Mon Sep 17 00:00:00 2001 From: Oleg Kravchuk Date: Thu, 2 May 2024 21:49:34 +0300 Subject: [PATCH] start_time npe fix for Rollup and Transform jobs (#1164) --- .../org/opensearch/indexmanagement/rollup/model/Rollup.kt | 3 ++- .../opensearch/indexmanagement/transform/model/Transform.kt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/org/opensearch/indexmanagement/rollup/model/Rollup.kt b/src/main/kotlin/org/opensearch/indexmanagement/rollup/model/Rollup.kt index b15145040..19da98e8b 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/rollup/model/Rollup.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/rollup/model/Rollup.kt @@ -340,9 +340,10 @@ data class Rollup( // TODO: Make startTime public in Job Scheduler so we can just directly check the value if (seqNo == SequenceNumbers.UNASSIGNED_SEQ_NO || primaryTerm == SequenceNumbers.UNASSIGNED_PRIMARY_TERM) { if (schedule is IntervalSchedule) { - schedule = IntervalSchedule(schedule.startTime, schedule.interval, schedule.unit, schedule.delay ?: 0) + schedule = IntervalSchedule(schedule.startTime ?: Instant.now(), schedule.interval, schedule.unit, schedule.delay ?: 0) } } + return Rollup( id = id, seqNo = seqNo, diff --git a/src/main/kotlin/org/opensearch/indexmanagement/transform/model/Transform.kt b/src/main/kotlin/org/opensearch/indexmanagement/transform/model/Transform.kt index 14dd49ac0..fb017d21f 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/transform/model/Transform.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/transform/model/Transform.kt @@ -397,7 +397,7 @@ data class Transform( if (seqNo == SequenceNumbers.UNASSIGNED_SEQ_NO || primaryTerm == SequenceNumbers.UNASSIGNED_PRIMARY_TERM) { // we instantiate the start time if (schedule is IntervalSchedule) { - schedule = IntervalSchedule(schedule.startTime, schedule.interval, schedule.unit) + schedule = IntervalSchedule(schedule.startTime ?: Instant.now(), schedule.interval, schedule.unit) } // we clear out metadata if its a new job