Skip to content

Commit

Permalink
Get previous disk usage only from existing machine configs (#6699)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhay-krishna authored Sep 19, 2023
1 parent 8382d1a commit 8f307c9
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pkg/providers/vsphere/vsphere.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 8f307c9

Please sign in to comment.