Skip to content

Commit 75b173d

Browse files
authored
Merge pull request #97 from aws/fix-issues-found-by-e2e
Fixup E2E Findings
2 parents 836ccea + 3666f2d commit 75b173d

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

controllers/cloudstackmachine_controller.go

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -249,20 +249,18 @@ func (r *CloudStackMachineReconciliationRunner) GetOrCreateMachineStateChecker()
249249
}
250250

251251
func (r *CloudStackMachineReconciliationRunner) ReconcileDelete() (retRes ctrl.Result, reterr error) {
252-
if r.ReconciliationSubject.Spec.InstanceID == nil {
253-
r.Log.Info("VM Instance ID is nil")
254-
return ctrl.Result{}, nil
255-
}
256-
r.Log.Info("Deleting instance", "instance-id", r.ReconciliationSubject.Spec.InstanceID)
257-
// Use CSClient instead of CSUser here to expunge as admin.
258-
// The CloudStack-Go API does not return an error, but the VM won't delete with Expunge set if requested by
259-
// non-domain admin user.
260-
if err := r.CSClient.DestroyVMInstance(r.ReconciliationSubject); err != nil {
261-
if err.Error() == "VM deletion in progress" {
262-
r.Log.Info(err.Error())
263-
return ctrl.Result{RequeueAfter: utils.DestoryVMRequeueInterval}, nil
252+
if r.ReconciliationSubject.Spec.InstanceID != nil {
253+
r.Log.Info("Deleting instance", "instance-id", r.ReconciliationSubject.Spec.InstanceID)
254+
// Use CSClient instead of CSUser here to expunge as admin.
255+
// The CloudStack-Go API does not return an error, but the VM won't delete with Expunge set if requested by
256+
// non-domain admin user.
257+
if err := r.CSClient.DestroyVMInstance(r.ReconciliationSubject); err != nil {
258+
if err.Error() == "VM deletion in progress" {
259+
r.Log.Info(err.Error())
260+
return ctrl.Result{RequeueAfter: utils.DestoryVMRequeueInterval}, nil
261+
}
262+
return ctrl.Result{}, err
264263
}
265-
return ctrl.Result{}, err
266264
}
267265
r.Log.Info("VM Deleted")
268266
controllerutil.RemoveFinalizer(r.ReconciliationSubject, infrav1.MachineFinalizer)

controllers/cloudstackmachinestatechecker_controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package controllers
1818

1919
import (
2020
"context"
21+
"strings"
2122
"time"
2223

2324
ctrl "sigs.k8s.io/controller-runtime"
@@ -73,7 +74,7 @@ func (r *CloudStackMachineStateCheckerReconciliationRunner) Reconcile() (ctrl.Re
7374
return res, err
7475
}
7576

76-
if err := r.CSClient.ResolveVMInstanceDetails(r.CSMachine); err != nil {
77+
if err := r.CSClient.ResolveVMInstanceDetails(r.CSMachine); err != nil && !strings.Contains(strings.ToLower(err.Error()), "no match found") {
7778
return r.ReturnWrappedError(err, "failed to resolve VM instance details")
7879
}
7980
if r.CSMachine.Status.InstanceState == "Running" {

pkg/cloud/user_credentials.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ func (c *client) ResolveDomain(domain *Domain) error {
7474
tokens = append([]string{rootDomain}, tokens...)
7575
} else {
7676
tokens[0] = rootDomain
77-
domain.Path = strings.Join(tokens, domainDelimiter)
7877
}
78+
domain.Path = strings.Join(tokens, domainDelimiter)
7979
}
8080

8181
// Set present search/list parameters.

0 commit comments

Comments
 (0)