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:on DisableSyntax.asInstanceOf
|
||||||
|
|
||||||
|
// scalafix:off DisableSyntax.asInstanceOf
|
||||||
private def isResourceConstrained(instanceId: String): Boolean =
|
private def isResourceConstrained(instanceId: String): Boolean =
|
||||||
kubeClientOpt.fold(false) { kube =>
|
kubeClientOpt.fold(false) { kube =>
|
||||||
try
|
try
|
||||||
@@ -106,6 +107,7 @@ class AutoScaler:
|
|||||||
log.debugf(ex, "Failed to check resource metrics for %s", instanceId)
|
log.debugf(ex, "Failed to check resource metrics for %s", instanceId)
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
// scalafix:on DisableSyntax.asInstanceOf
|
||||||
|
|
||||||
def checkAndScale: Unit =
|
def checkAndScale: Unit =
|
||||||
if config.autoScaleEnabled then
|
if config.autoScaleEnabled then
|
||||||
|
|||||||
+6
-6
@@ -89,17 +89,17 @@ class HealthMonitor:
|
|||||||
log.warnf("Evicted %d stale instances: %s", evicted.size, evicted.mkString(", "))
|
log.warnf("Evicted %d stale instances: %s", evicted.size, evicted.mkString(", "))
|
||||||
evicted.foreach(deleteK8sPod)
|
evicted.foreach(deleteK8sPod)
|
||||||
autoScaler.scaleUp()
|
autoScaler.scaleUp()
|
||||||
val instances = instanceRegistry.getAllInstances
|
val instances = instanceRegistry.getAllInstances
|
||||||
var instanceFailed = false
|
val failed = instances.collect { inst =>
|
||||||
instances.foreach { inst =>
|
|
||||||
val isHealthy = checkHealth(inst.instanceId)
|
val isHealthy = checkHealth(inst.instanceId)
|
||||||
if !isHealthy && inst.state == "HEALTHY" then
|
if !isHealthy && inst.state == "HEALTHY" then
|
||||||
log.warnf("Instance %s marked unhealthy", inst.instanceId)
|
log.warnf("Instance %s marked unhealthy", inst.instanceId)
|
||||||
instanceRegistry.markInstanceDead(inst.instanceId)
|
instanceRegistry.markInstanceDead(inst.instanceId)
|
||||||
deleteK8sPod(inst.instanceId)
|
deleteK8sPod(inst.instanceId)
|
||||||
instanceFailed = true
|
Some(inst.instanceId)
|
||||||
}
|
else None
|
||||||
if instanceFailed then autoScaler.scaleUp()
|
}.flatten
|
||||||
|
if failed.nonEmpty then autoScaler.scaleUp()
|
||||||
|
|
||||||
private def checkHealth(instanceId: String): Boolean =
|
private def checkHealth(instanceId: String): Boolean =
|
||||||
val redisHealthy = checkRedisHeartbeat(instanceId)
|
val redisHealthy = checkRedisHeartbeat(instanceId)
|
||||||
|
|||||||
Reference in New Issue
Block a user