@@ -286,9 +286,11 @@ func (p *provider) getConfig(provSpec clusterv1alpha1.ProviderSpec) (*Config, *p
286
286
return nil , nil , fmt .Errorf (`failed to get value of "memory" field: %w` , err )
287
287
}
288
288
289
- config .Resources , config .VCPUs , err = parseResources (cpus , memory , rawConfig .VirtualMachine .Template .VCPUs )
290
- if err != nil {
291
- return nil , nil , fmt .Errorf (`failed to configure resource requests and limits and vcpus: %w` , err )
289
+ if rawConfig .VirtualMachine .Instancetype == nil {
290
+ config .Resources , config .VCPUs , err = parseResources (cpus , memory , rawConfig .VirtualMachine .Template .VCPUs )
291
+ if err != nil {
292
+ return nil , nil , fmt .Errorf (`failed to configure resource requests and limits and vcpus: %w` , err )
293
+ }
292
294
}
293
295
294
296
config .Namespace = getNamespace ()
@@ -630,11 +632,11 @@ func (p *provider) Validate(ctx context.Context, _ *zap.SugaredLogger, spec clus
630
632
return fmt .Errorf ("no resource requests set for the virtual machine" )
631
633
}
632
634
633
- if c .VCPUs == nil && c .Resources .Cpu () == nil {
635
+ if c .VCPUs == nil && c .Resources .Cpu (). IsZero () {
634
636
return fmt .Errorf ("no CPUs configured. Either vCPUs or CPUs have to be set" )
635
637
}
636
638
637
- if c .VCPUs != nil && c .Resources .Cpu () != nil {
639
+ if c .VCPUs != nil && ! c .Resources .Cpu (). IsZero () {
638
640
return fmt .Errorf ("vCPUs and CPUs cannot be configured at the same time" )
639
641
}
640
642
}
0 commit comments