@@ -53,7 +53,6 @@ type CloudStackMachineReconciliationRunner struct {
53
53
ReconciliationSubject * infrav1.CloudStackMachine
54
54
CAPIMachine * capiv1.Machine
55
55
StateChecker * infrav1.CloudStackMachineStateChecker
56
- CSUser cloud.Client
57
56
Zones * infrav1.CloudStackZoneList
58
57
FailureDomain * infrav1.CloudStackZone
59
58
IsoNet * infrav1.CloudStackIsolatedNetwork
@@ -122,7 +121,7 @@ func (r *CloudStackMachineReconciliationRunner) ConsiderAffinity() (ctrl.Result,
122
121
return res , err
123
122
}
124
123
if ! r .AffinityGroup .Status .Ready {
125
- return r .RequeueWithMessage ("Required afinity group not ready." )
124
+ return r .RequeueWithMessage ("Required affinity group not ready." )
126
125
}
127
126
return ctrl.Result {}, nil
128
127
}
@@ -191,7 +190,7 @@ func (r *CloudStackMachineReconciliationRunner) GetOrCreateVMInstance() (retRes
191
190
return ctrl.Result {}, errors .New ("bootstrap secret data not yet set" )
192
191
}
193
192
194
- err := r .CSClient .GetOrCreateVMInstance (r .ReconciliationSubject , r .CAPIMachine , r .CSCluster , & machineZone , r .AffinityGroup , string (data ))
193
+ err := r .CSUser .GetOrCreateVMInstance (r .ReconciliationSubject , r .CAPIMachine , r .CSCluster , & machineZone , r .AffinityGroup , string (data ))
195
194
196
195
if err == nil && ! controllerutil .ContainsFinalizer (r .ReconciliationSubject , infrav1 .MachineFinalizer ) { // Fetched or Created?
197
196
r .Log .Info ("CloudStack instance Created" , "instanceStatus" , r .ReconciliationSubject .Status )
@@ -225,7 +224,7 @@ func (r *CloudStackMachineReconciliationRunner) AddToLBIfNeeded() (retRes ctrl.R
225
224
if r .IsoNet .Spec .Name == "" {
226
225
return r .RequeueWithMessage ("Could not get required Isolated Network for VM, requeueing." )
227
226
}
228
- err := r .CSClient .AssignVMToLoadBalancerRule (r .IsoNet , * r .ReconciliationSubject .Spec .InstanceID )
227
+ err := r .CSUser .AssignVMToLoadBalancerRule (r .IsoNet , * r .ReconciliationSubject .Spec .InstanceID )
229
228
if err != nil {
230
229
return ctrl.Result {}, err
231
230
}
@@ -251,6 +250,9 @@ func (r *CloudStackMachineReconciliationRunner) GetOrCreateMachineStateChecker()
251
250
252
251
func (r * CloudStackMachineReconciliationRunner ) ReconcileDelete () (retRes ctrl.Result , reterr error ) {
253
252
r .Log .Info ("Deleting instance" , "instance-id" , r .ReconciliationSubject .Spec .InstanceID )
253
+ // Use CSClient instead of CSUser here to expunge as admin.
254
+ // The CloudStack-Go API does not return an error, but the VM won't delete with Expunge set if requested by
255
+ // non-domain admin user.
254
256
if err := r .CSClient .DestroyVMInstance (r .ReconciliationSubject ); err != nil {
255
257
if err .Error () == "VM deletion in progress" {
256
258
r .Log .Info (err .Error ())
0 commit comments