Skip to content

Commit

Permalink
Fixes #22879: Too many \"Policy Update Started\" in event logs
Browse files Browse the repository at this point in the history
  • Loading branch information
fanf committed Jun 22, 2023
1 parent 44597b6 commit 27b985a
Showing 1 changed file with 19 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ final class AsyncDeploymentActor(
currentDeploymentId += 1
val newState = Processing(currentDeploymentId, DateTime.now)
currentDeployerState = newState
PolicyGenerationLogger.manager.trace("Policy updater: ask to start updating policies")
PolicyGenerationLogger.manager.debug("Automatic policy generation request: start policy generation (none running)")
val event = eventLogger.repository
.saveEventLog(
modId,
Expand All @@ -262,42 +262,22 @@ final class AsyncDeploymentActor(
.toOption
DeployerAgent ! NewDeployment(newState.id, modId, newState.started, actor, event.flatMap(_.id).getOrElse(0))

// we don't generate eventlogs when queuing/dropping an automatic start, see https://issues.rudder.io/issues/22879

case p @ Processing(id, startTime) => // ok, add a pending deployment
PolicyGenerationLogger.manager.trace("Policy updater: currently updating policies, add a pending update request")
val event = eventLogger.repository
.saveEventLog(
modId,
AutomaticStartDeployement(WithDetails(<addPending alreadyPending="false"/>))
)
.either
.runNow
.toOption
currentDeployerState = ProcessingAndPendingAuto(DateTime.now, p, actor, event.flatMap(_.id).getOrElse(0))
PolicyGenerationLogger.manager.debug(
"Automatic policy generation request: queued - one policy " +
"generation already running"
)

case p: ProcessingAndPendingAuto => // drop message, one is already pending
eventLogger.repository
.saveEventLog(
modId,
AutomaticStartDeployement(WithDetails(<addPending alreadyPending="true"/>))
)
.runNowLogError(err =>
PolicyGenerationLogger.error(s"Error when saving start generation event log: ${err.fullMsg}")
)
PolicyGenerationLogger.manager.info(
"One automatic policy update process is already pending, ignoring new policy update request"
PolicyGenerationLogger.manager.debug(
"Automatic policy generation request: dropped - one policy generation already running"
)

case p: ProcessingAndPendingManual => // drop message, one is already pending
eventLogger.repository
.saveEventLog(
modId,
AutomaticStartDeployement(WithDetails(<addPending alreadyPending="true"/>))
)
.runNowLogError(err =>
PolicyGenerationLogger.error(s"Error when saving start generation event log: ${err.fullMsg}")
)
PolicyGenerationLogger.manager.info(
"One manual policy update process is already pending, ignoring new policy update request"
PolicyGenerationLogger.manager.debug(
"Automatic policy generation request: dropped - one policy generation already running"
)
}
}
Expand All @@ -324,7 +304,7 @@ final class AsyncDeploymentActor(
currentDeploymentId += 1
val newState = Processing(currentDeploymentId, DateTime.now)
currentDeployerState = newState
PolicyGenerationLogger.manager.trace("Policy updater: ask to start updating policies")
PolicyGenerationLogger.manager.debug("Manual policy generation request: start policy generation (none running)")
val event = eventLogger.repository
.saveEventLog(
modId,
Expand All @@ -336,7 +316,9 @@ final class AsyncDeploymentActor(
DeployerAgent ! NewDeployment(newState.id, modId, newState.started, actor, event.flatMap(_.id).getOrElse(0))

case p @ Processing(id, startTime) => // ok, add a pending deployment
PolicyGenerationLogger.manager.trace("Policy updater: currently updating policies, add a pending update request")
PolicyGenerationLogger.manager.debug(
"Manual policy generation request: queued - one policy generation already running"
)
val event = eventLogger.repository
.saveEventLog(
modId,
Expand All @@ -356,8 +338,8 @@ final class AsyncDeploymentActor(
.runNowLogError(err =>
PolicyGenerationLogger.error(s"Error when saving start generation event log: ${err.fullMsg}")
)
PolicyGenerationLogger.manager.info(
"One policy update process is already pending, ignoring new policy update request"
PolicyGenerationLogger.manager.debug(
"Manual policy generation request: dropped - one policy generation already running"
)

case p: ProcessingAndPendingAuto => // replace with manual
Expand All @@ -371,8 +353,8 @@ final class AsyncDeploymentActor(
.toOption
currentDeployerState =
ProcessingAndPendingManual(DateTime.now, p.current, actor, event.flatMap(_.id).getOrElse(0), reason)
PolicyGenerationLogger.manager.info(
"One automatic policy update process is already pending, replacing by a manual request"
PolicyGenerationLogger.manager.debug(
"Manual policy generation request: dropped - one policy generation already running"
)
}
}
Expand Down

0 comments on commit 27b985a

Please sign in to comment.