Skip to content

Commit

Permalink
Fix kubernetes rebalance
Browse files Browse the repository at this point in the history
- Fix formula so it deploys pods with less than SHARDS_PER_POD shards
  • Loading branch information
DRSchlaubi committed Sep 14, 2024
1 parent f354332 commit 4e4d3fa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import kotlinx.serialization.json.buildJsonObject
import kotlinx.serialization.json.put
import kotlinx.serialization.json.putJsonArray
import kotlinx.serialization.json.putJsonObject
import kotlin.math.ceil
import kotlin.time.Duration.Companion.minutes
import kotlin.time.TimeSource
import io.kubernetes.client.util.Config as KubeConfig
Expand Down Expand Up @@ -110,7 +111,7 @@ class RebalancerExtension(context: PluginContext) : MikBotModule(context) {

private suspend fun reBalance(newTotalShards: Int) {
val json =
generateStatefulSetSpec(replicas = newTotalShards / Config.SHARDS_PER_POD, totalShards = newTotalShards)
generateStatefulSetSpec(replicas = ceil(newTotalShards.toDouble() / Config.SHARDS_PER_POD.toDouble()).toInt(), totalShards = newTotalShards)

val jsonPatch = generateStatefulSetSpec().generatePatch(json)

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ coroutines = "1.8.1"
serialization = "1.7.1"
ktor = "2.3.11"
kord = "feature-user-apps-20240825.234248-3"
api = "3.36.0"
api = "3.36.1"
ksp = "2.0.0-1.0.22"
lavakord = "7.1.0"

Expand Down

0 comments on commit 4e4d3fa

Please sign in to comment.