fix: scalafix violations in metrics check and health monitor
Build & Test (NowChessSystems) TeamCity build finished
Build & Test (NowChessSystems) TeamCity build finished
- Wrap asInstanceOf casts with scalafix:off/on in isResourceConstrained - Replace var with immutable List in HealthMonitor.checkInstanceHealth Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -72,6 +72,7 @@ class AutoScaler:
|
||||
}
|
||||
// scalafix:on DisableSyntax.asInstanceOf
|
||||
|
||||
// scalafix:off DisableSyntax.asInstanceOf
|
||||
private def isResourceConstrained(instanceId: String): Boolean =
|
||||
kubeClientOpt.fold(false) { kube =>
|
||||
try
|
||||
@@ -106,6 +107,7 @@ class AutoScaler:
|
||||
log.debugf(ex, "Failed to check resource metrics for %s", instanceId)
|
||||
false
|
||||
}
|
||||
// scalafix:on DisableSyntax.asInstanceOf
|
||||
|
||||
def checkAndScale: Unit =
|
||||
if config.autoScaleEnabled then
|
||||
|
||||
+6
-6
@@ -89,17 +89,17 @@ class HealthMonitor:
|
||||
log.warnf("Evicted %d stale instances: %s", evicted.size, evicted.mkString(", "))
|
||||
evicted.foreach(deleteK8sPod)
|
||||
autoScaler.scaleUp()
|
||||
val instances = instanceRegistry.getAllInstances
|
||||
var instanceFailed = false
|
||||
instances.foreach { inst =>
|
||||
val instances = instanceRegistry.getAllInstances
|
||||
val failed = instances.collect { inst =>
|
||||
val isHealthy = checkHealth(inst.instanceId)
|
||||
if !isHealthy && inst.state == "HEALTHY" then
|
||||
log.warnf("Instance %s marked unhealthy", inst.instanceId)
|
||||
instanceRegistry.markInstanceDead(inst.instanceId)
|
||||
deleteK8sPod(inst.instanceId)
|
||||
instanceFailed = true
|
||||
}
|
||||
if instanceFailed then autoScaler.scaleUp()
|
||||
Some(inst.instanceId)
|
||||
else None
|
||||
}.flatten
|
||||
if failed.nonEmpty then autoScaler.scaleUp()
|
||||
|
||||
private def checkHealth(instanceId: String): Boolean =
|
||||
val redisHealthy = checkRedisHeartbeat(instanceId)
|
||||
|
||||
Reference in New Issue
Block a user