yrenat commented on code in PR #6046:
URL: https://github.com/apache/texera/pull/6046#discussion_r3868249208


##########
computing-unit-managing-service/src/main/scala/org/apache/texera/service/ComputingUnitManagingService.scala:
##########
@@ -32,9 +32,55 @@ import org.apache.texera.service.resource.{
   ComputingUnitManagingResource,
   HealthCheckResource
 }
+import 
org.apache.texera.service.resource.ComputingUnitManagingResource.TerminatedComputingUnitInfo
+import org.slf4j.LoggerFactory
 import java.nio.file.Path
+import java.util.concurrent.TimeUnit
 
 class ComputingUnitManagingService extends 
Application[ComputingUnitManagingServiceConfiguration] {
+  private val logger = 
LoggerFactory.getLogger(classOf[ComputingUnitManagingService])
+
+  private[service] def initSqlServer(
+      connect: (String, String, String) => Unit = SqlServer.initConnection
+  ): Unit =
+    connect(
+      StorageConfig.jdbcUrl,
+      StorageConfig.jdbcUsername,
+      StorageConfig.jdbcPassword
+    )
+
+  private[service] def registerIdleComputingUnitCleanup(
+      environment: Environment,
+      kubernetesComputingUnitEnabled: Boolean = 
KubernetesConfig.kubernetesComputingUnitEnabled,
+      idleTimeoutMinutes: Long = 
KubernetesConfig.computingUnitIdleTimeoutMinutes,
+      idleCheckIntervalMinutes: Long = 
KubernetesConfig.computingUnitIdleCheckIntervalMinutes,
+      terminateIdleComputingUnits: () => List[TerminatedComputingUnitInfo] = 
() =>
+        ComputingUnitManagingResource.terminateIdleKubernetesComputingUnits(),
+      logTerminatedUnits: String => Unit = message => logger.info(message),
+      logCleanupFailure: Throwable => Unit = throwable =>
+        logger.warn("Failed to terminate idle Kubernetes computing units", 
throwable),
+      scheduleWithFixedDelay: Option[(Runnable, Long, Long, TimeUnit) => Unit] 
= None
+  ): Unit =
+    if (kubernetesComputingUnitEnabled && idleTimeoutMinutes > 0) {
+      val scheduler = scheduleWithFixedDelay.getOrElse((command, initialDelay, 
delay, unit) =>

Review Comment:
   Addressed. It now logs a warning and skips scheduling instead of aborting 
startup.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to