Skip to content

Commit

Permalink
Merge pull request #707 from gao12312/develop
Browse files Browse the repository at this point in the history
update ETCDUnitSize  for VirtualCluster
  • Loading branch information
duanmengkk authored Sep 13, 2024
2 parents 978e257 + e964775 commit 55df6d7
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions pkg/kubenest/controlplane/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,30 @@ func DeleteVirtualClusterEtcd(client clientset.Interface, name, namespace string
func installEtcd(client clientset.Interface, name, namespace string, kubeNestConfiguration *v1alpha1.KubeNestConfiguration, vc *v1alpha1.VirtualCluster) error {
imageRepository, imageVersion := util.GetImageMessage()

nodeCount := getNodeCountFromPromotePolicy(vc)
resourceQuantity, err := resource.ParseQuantity(kubeNestConfiguration.KubeInKubeConfig.ETCDUnitSize)
if err != nil {
klog.Errorf("Failed to parse quantity %s: %v", kubeNestConfiguration.KubeInKubeConfig.ETCDUnitSize, err)
return err
var resourceQuantity resource.Quantity
var err error

if vc.Spec.KubeInKubeConfig.ETCDUnitSize != "" {
resourceQuantity, err = resource.ParseQuantity(vc.Spec.KubeInKubeConfig.ETCDUnitSize)
if err != nil {
klog.Errorf("Failed to parse etcdSize %s: %v", vc.Spec.KubeInKubeConfig.ETCDUnitSize, err)
return err
}
if resourceQuantity.Value() <= 0 {
klog.Errorf("Invalid vc.Spec.KubeInKubeConfig.ETCDUnitSize: must be greater than zero")
return err
}
resourceQuantity.Set(resourceQuantity.Value())
} else {
nodeCount := getNodeCountFromPromotePolicy(vc)
resourceQuantity, err = resource.ParseQuantity(kubeNestConfiguration.KubeInKubeConfig.ETCDUnitSize)
if err != nil {
klog.Errorf("Failed to parse quantity %s: %v", kubeNestConfiguration.KubeInKubeConfig.ETCDUnitSize, err)
return err
}
resourceQuantity.Set(resourceQuantity.Value() * int64(nodeCount))

}
resourceQuantity.Set(resourceQuantity.Value() * int64(nodeCount))

initialClusters := make([]string, constants.EtcdReplicas)
for index := range initialClusters {
Expand Down

0 comments on commit 55df6d7

Please sign in to comment.