From b07acd00d62f8fb178aa83b63eed6c2019045a9f Mon Sep 17 00:00:00 2001 From: EKS Distro PR Bot <75336432+eks-distro-pr-bot@users.noreply.github.com> Date: Tue, 19 Sep 2023 11:49:37 -0500 Subject: [PATCH] Get previous disk usage only from existing machine configs (#6700) Co-authored-by: Abhay Krishna Arunachalam --- pkg/providers/vsphere/vsphere.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/providers/vsphere/vsphere.go b/pkg/providers/vsphere/vsphere.go index 81b0402037a6..44abf1b7eeb9 100644 --- a/pkg/providers/vsphere/vsphere.go +++ b/pkg/providers/vsphere/vsphere.go @@ -471,12 +471,14 @@ type datastoreUsage struct { } func (p *vsphereProvider) getPrevMachineConfigDatastoreUsage(ctx context.Context, machineConfig *v1alpha1.VSphereMachineConfig, cluster *types.Cluster, count int) (diskGiB float64, err error) { - em, err := p.providerKubectlClient.GetEksaVSphereMachineConfig(ctx, machineConfig.Name, cluster.KubeconfigFile, machineConfig.GetNamespace()) - if err != nil { - return 0, err - } - if em != nil { - return float64(em.Spec.DiskGiB * count), nil + if count > 0 { + em, err := p.providerKubectlClient.GetEksaVSphereMachineConfig(ctx, machineConfig.Name, cluster.KubeconfigFile, machineConfig.GetNamespace()) + if err != nil { + return 0, err + } + if em != nil { + return float64(em.Spec.DiskGiB * count), nil + } } return 0, nil }