Skip to content

Commit

Permalink
fix: infer correct shard in statefulset setup
Browse files Browse the repository at this point in the history
  • Loading branch information
woehrl01 committed Feb 10, 2024
1 parent bb1c1ed commit e80b403
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func NewCommand() *cobra.Command {
func getClusterSharding(kubeClient *kubernetes.Clientset, settingsMgr *settings.SettingsManager, shardingAlgorithm string, enableDynamicClusterDistribution bool) sharding.ClusterShardingCache {
var replicasCount int
// StatefulSet mode and Deployment mode uses different default values for shard number.
defaultShardNumberValue := 0
defaultShardNumberValue := -1
applicationControllerName := env.StringFromEnv(common.EnvAppControllerName, common.DefaultApplicationControllerName)
appControllerDeployment, err := kubeClient.AppsV1().Deployments(settingsMgr.GetNamespace()).Get(context.Background(), applicationControllerName, metav1.GetOptions{})

Expand All @@ -252,7 +252,6 @@ func getClusterSharding(kubeClient *kubernetes.Clientset, settingsMgr *settings.

if enableDynamicClusterDistribution && appControllerDeployment != nil && appControllerDeployment.Spec.Replicas != nil {
replicasCount = int(*appControllerDeployment.Spec.Replicas)
defaultShardNumberValue = -1
} else {
replicasCount = env.ParseNumFromEnv(common.EnvControllerReplicas, 0, 0, math.MaxInt32)
}
Expand Down Expand Up @@ -285,6 +284,7 @@ func getClusterSharding(kubeClient *kubernetes.Clientset, settingsMgr *settings.
}
}
} else {
defaultShardNumberValue = 0
log.Info("Processing all cluster shards")
}
db := db.NewDB(settingsMgr.GetNamespace(), settingsMgr, kubeClient)
Expand Down

0 comments on commit e80b403

Please sign in to comment.