Skip to content

Commit

Permalink
update ETCDUnitSize for VirtualCluster
Browse files Browse the repository at this point in the history
Signed-off-by: gaoyuan <[email protected]>
  • Loading branch information
gao12312 committed Sep 13, 2024
1 parent 978e257 commit e964775
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 e964775

Please sign in to comment.