in app/housekeeping/MarkOrphanedBakesForDeletion.scala [31:58]
override def housekeep(): Unit = {
implicit val implicitPrismAgents: PrismData = prismAgents
implicit val implicitDynamo: Dynamo = dynamo
val (errors, recipes) = Recipes.recipesWithErrors()
errors match {
case _ if errors.length > MarkOrphanedBakesForDeletion.FAULT_TOLERANCE =>
log.info(
s"Housekeeping found ${errors.length} database errors while searching for orphaned bakes"
)
log.warn(
s"${errors.length} errors exceeds the limit so orphaned bake deletion will not continue"
)
case _ =>
val bakes = Bakes.scanForAll()
val orphanedBakeIds = MarkOrphanedBakesForDeletion.findOrphanedBakeIds(
recipes.map(_.id).toSet,
bakes
)
if (orphanedBakeIds.nonEmpty)
log.info(
s"Marking ${orphanedBakeIds.size} orphaned bakes for deletion"
)
orphanedBakeIds.foreach { bakeId =>
Bakes.markToDelete(bakeId)
log.info(s"Marked ${bakeId.toString} for deletion")
}
}
}