Skip to content

Commit f983ef1

Browse files
committed
[ITB-2097, ITB-2098] Idle sessions and inactive user accounts not getting cleaned up automatically (when configured)
1 parent 6247c7b commit f983ef1

1 file changed

Lines changed: 15 additions & 17 deletions

File tree

gitb-ui/app/hooks/PostStartHook.scala

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -413,16 +413,12 @@ class PostStartHook @Inject() (authenticationManager: AuthenticationManager,
413413
Future.successful {
414414
actorSystem.scheduler.scheduleWithFixedDelay(5.minutes, 30.minutes) {
415415
() => {
416-
systemConfigurationManager.getSystemConfiguration(Constants.SessionAliveTime).map { config =>
417-
if (config.isDefined && config.get.parameter.isDefined) {
418-
val threshold = config.get.parameter.get.toLong
419-
testExecutionManager.endIdleRunningSessions(threshold).map(_ => ()).recover {
420-
case e: Exception =>
421-
logger.warn("Failure while terminating idle sessions", e)
422-
throw e
423-
}
424-
}
425-
}
416+
Await.result(
417+
systemConfigurationManager.terminateIdleSessions().recover {
418+
case e: Exception =>
419+
logger.warn("Failure while terminating idle sessions", e)
420+
}, Duration.Inf
421+
)
426422
}
427423
}
428424
}
@@ -435,13 +431,15 @@ class PostStartHook @Inject() (authenticationManager: AuthenticationManager,
435431
Future.successful {
436432
actorSystem.scheduler.scheduleWithFixedDelay(5.minutes, 1.day) {
437433
() => {
438-
systemConfigurationManager.deleteInactiveUserAccounts().map { deletedAccounts =>
439-
if (deletedAccounts.isDefined) {
440-
logger.info("Deleted {} inactive user account(s)", deletedAccounts.get)
441-
} else {
442-
logger.debug("Skipped the deletion of inactive user accounts")
443-
}
444-
}
434+
Await.result(
435+
systemConfigurationManager.deleteInactiveUserAccounts().map { deletedAccounts =>
436+
if (deletedAccounts.isDefined) {
437+
logger.info("Deleted {} inactive user account(s)", deletedAccounts.get)
438+
} else {
439+
logger.debug("Skipped the deletion of inactive user accounts")
440+
}
441+
}, Duration.Inf
442+
)
445443
}
446444
}
447445
}

0 commit comments

Comments
 (0)