File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -452,15 +452,22 @@ func findVirtualMachine(
452
452
453
453
// DestroyVMInstance Destroys a VM instance. Assumes machine has been fetched prior and has an instance ID.
454
454
func (c * client ) DestroyVMInstance (csMachine * infrav1.CloudStackMachine ) error {
455
+ p := c .cs .Configuration .NewListCapabilitiesParams ()
456
+ capabilities , err := c .cs .Configuration .ListCapabilities (p )
457
+ expunge := true
458
+ if err == nil {
459
+ expunge = capabilities .Capabilities .Allowuserexpungerecovervm
460
+ }
461
+
455
462
// Attempt deletion regardless of machine state.
456
- p := c .csAsync .VirtualMachine .NewDestroyVirtualMachineParams (* csMachine .Spec .InstanceID )
463
+ p2 := c .csAsync .VirtualMachine .NewDestroyVirtualMachineParams (* csMachine .Spec .InstanceID )
457
464
volIDs , err := c .listVMInstanceDatadiskVolumeIDs (* csMachine .Spec .InstanceID )
458
465
if err != nil {
459
466
return err
460
467
}
461
- p .SetExpunge (true )
462
- setArrayIfNotEmpty (volIDs , p .SetVolumeids )
463
- if _ , err := c .csAsync .VirtualMachine .DestroyVirtualMachine (p ); err != nil &&
468
+ p2 .SetExpunge (expunge )
469
+ setArrayIfNotEmpty (volIDs , p2 .SetVolumeids )
470
+ if _ , err := c .csAsync .VirtualMachine .DestroyVirtualMachine (p2 ); err != nil &&
464
471
strings .Contains (strings .ToLower (err .Error ()), "unable to find uuid for id" ) {
465
472
// VM doesn't exist. Success...
466
473
return nil
Original file line number Diff line number Diff line change @@ -152,7 +152,8 @@ func (c *client) ResolveDomain(domain *Domain) error {
152
152
// ResolveAccount resolves an account's information.
153
153
func (c * client ) ResolveAccount (account * Account ) error {
154
154
// Resolve domain prior to any account resolution activity.
155
- if err := c .ResolveDomain (& account .Domain ); err != nil {
155
+ if err := c .ResolveDomain (& account .Domain ); err != nil &&
156
+ ! strings .Contains (err .Error (), "The API [listDomains] does not exist or is not available for the account Account" ) {
156
157
return errors .Wrapf (err , "resolving domain %s details" , account .Domain .Name )
157
158
}
158
159
You can’t perform that action at this time.
0 commit comments