diff --git a/build.sbt b/build.sbt index 78cbca6e..0431c9ce 100644 --- a/build.sbt +++ b/build.sbt @@ -143,7 +143,6 @@ lazy val api = (project in file("api")) Dependencies.macWireProxy, Dependencies.yaml, Dependencies.cronUtils, - Dependencies.threeten, Dependencies.jsonValidate, Dependencies.iteratees, Dependencies.playAhcWS, @@ -174,7 +173,6 @@ lazy val jobs = (project in file("jobs")) Dependencies.macWireMacros, Dependencies.macWireUtil, Dependencies.macWireProxy, - Dependencies.threeten, Dependencies.cronUtils, Dependencies.akka, Dependencies.twitterCommons, diff --git a/changelog.md b/changelog.md index 4387b709..089e2d73 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,7 @@ # 0.6.NEXT +* Updated to the latest version of cron-utils `9.0.0` and removed threeten-backport. This fixes a number of cron related issues in the underlying dependencies. * When querying run detail with `embed=history`, `successfulFinishedRuns` and `failedFinishedRuns` contains new field `tasks` which is an array of taskIds of that finished run. This will allow people to query task ids even for finished job runs. * Fixed a bug when task status was not updated after the task turned running (when querying embed=activeRuns). * [DCOS_OSS-5166](https://jira.mesosphere.com/browse/DCOS_OSS-5166) Fixed metronome not using revive operation diff --git a/jobs/src/main/scala/dcos/metronome/model/CronSpec.scala b/jobs/src/main/scala/dcos/metronome/model/CronSpec.scala index c9855279..86ef2cfd 100644 --- a/jobs/src/main/scala/dcos/metronome/model/CronSpec.scala +++ b/jobs/src/main/scala/dcos/metronome/model/CronSpec.scala @@ -1,16 +1,15 @@ package dcos.metronome package model -import java.time.{ Instant, ZoneId, ZonedDateTime } +import java.time.ZonedDateTime -import com.cronutils.model.definition.{ CronConstraint, CronDefinition, CronDefinitionBuilder } -import com.cronutils.model.time.ExecutionTime import com.cronutils.model.Cron +import com.cronutils.model.definition.{ CronConstraint, CronDefinition, CronDefinitionBuilder } import com.cronutils.model.field.expression.{ Between, On } import com.cronutils.model.field.value.IntegerFieldValue import com.cronutils.model.field.{ CronField, CronFieldName } +import com.cronutils.model.time.ExecutionTime import com.cronutils.parser.CronParser -import org.threeten.bp.{ Instant => ThreeTenInstant, ZoneId => ThreeTenZoneId, ZonedDateTime => ThreeTenZonedDateTime } import scala.util.control.NonFatal @@ -19,21 +18,11 @@ class CronSpec(val cron: Cron) { private[this] lazy val executionTime: ExecutionTime = ExecutionTime.forCron(cron) def nextExecution(from: ZonedDateTime): ZonedDateTime = { - val fromDateTime: ThreeTenZonedDateTime = javaTimeToThreetenTime(from) - executionTime.nextExecution(threetenToJavaTime(fromDateTime)).get() + executionTime.nextExecution(from).get() } def lastExecution(from: ZonedDateTime): ZonedDateTime = { - val fromDateTime: ThreeTenZonedDateTime = javaTimeToThreetenTime(from) - executionTime.lastExecution(threetenToJavaTime(fromDateTime)).get() - } - - private def threetenToJavaTime(from: ThreeTenZonedDateTime): ZonedDateTime = { - ZonedDateTime.ofInstant(Instant.ofEpochMilli(from.toInstant.toEpochMilli), ZoneId.of(from.getZone.getId)) - } - - private def javaTimeToThreetenTime(from: ZonedDateTime): ThreeTenZonedDateTime = { - ThreeTenZonedDateTime.ofInstant(ThreeTenInstant.ofEpochMilli(from.toInstant.toEpochMilli), ThreeTenZoneId.of(from.getZone.toString)) + executionTime.lastExecution(from).get() } override def hashCode(): Int = cron.hashCode() diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 386abb65..8ab120f4 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -12,8 +12,7 @@ object Dependencies { val PlayJson = "2.6.10" val ScalaTestPlusPlay = "3.1.2" val PlayIteratees = "2.6.1" - val CronUtils = "7.0.5" - val Threeten = "1.3.3" + val CronUtils = "9.0.0" val WixAccord = "0.7.1" val Akka = "2.5.15" val Mockito = "2.21.0" @@ -36,7 +35,6 @@ object Dependencies { val marathon = "mesosphere.marathon" %% "marathon" % V.Marathon exclude("com.typesafe.play", "*") exclude("mesosphere.marathon", "ui") exclude("mesosphere", "chaos") exclude("org.apache.hadoop", "hadoop-hdfs") exclude("org.apache.hadoop", "hadoop-common") exclude("mesosphere.marathon", "plugin-interface_2.12") val marathonPlugin = "mesosphere.marathon" %% "plugin-interface" % V.MarathonPluginInterface val cronUtils = "com.cronutils" % "cron-utils" % V.CronUtils exclude("org.threeten", "threetenbp") - val threeten = "org.threeten" % "threetenbp" % V.Threeten val wixAccord = "com.wix" %% "accord-core" % V.WixAccord val akka = "com.typesafe.akka" %% "akka-actor" % V.Akka val jsonValidate = "com.eclipsesource" %% "play-json-schema-validator" % V.JsonValidate