Skip to content

Commit

Permalink
Fix some more tests, but break 1 restart strategy test
Browse files Browse the repository at this point in the history
RestartStrategy needs to be reworked and seems fragile for now
  • Loading branch information
Lqp1 authored and komuta committed Aug 14, 2020
1 parent 6250f37 commit e50108e
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 163 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ object TaskReplaceActor extends StrictLogging {

val minHealthy = (runSpec.instances * runSpec.upgradeStrategy.minimumHealthCapacity).ceil.toInt
var maxCapacity = (runSpec.instances * (1 + runSpec.upgradeStrategy.maximumOverCapacity)).toInt
var nrToKillImmediately = math.min(math.max(0, consideredHealthyInstancesCount - minHealthy), runSpec.instances - state.newInstances)
var nrToKillImmediately = math.max(0, consideredHealthyInstancesCount - minHealthy)

if (minHealthy == maxCapacity && maxCapacity <= consideredHealthyInstancesCount) {
if (runSpec.isResident) {
Expand Down Expand Up @@ -244,9 +244,10 @@ object TaskReplaceActor extends StrictLogging {
def canStartNewInstances: Boolean = minHealthy < maxCapacity || consideredHealthyInstancesCount - nrToKillImmediately < maxCapacity
assume(canStartNewInstances, "must be able to start new instances")

val leftCapacity = math.max(0, maxCapacity - totalInstancesRunning)
val leftCapacity = math.max(0, maxCapacity - totalInstancesRunning + nrToKillImmediately)
val instancesNotStartedYet = math.max(0, runSpec.instances - state.newInstances)
val nrToStartImmediately = math.min(instancesNotStartedYet, leftCapacity)
logger.info(s"For maxCapacity ${maxCapacity}, leftCapacity ${leftCapacity} and still not started ${instancesNotStartedYet}, will start ${nrToStartImmediately} now!")
RestartStrategy(nrToKillImmediately = nrToKillImmediately, nrToStartImmediately = nrToStartImmediately, maxCapacity = maxCapacity)
}
}
Expand Down
Loading

0 comments on commit e50108e

Please sign in to comment.