Skip to content

Commit e7716fb

Browse files
authored
Merge pull request #2136 from zhanggbj/refine_notfounderr
⚠️ Treating VSphereVM wasNotFoundByBIOSUUID as transient error
2 parents 7b26b7a + 43cf6d0 commit e7716fb

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

apis/v1beta1/condition_consts.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ const (
8383
// are automatically re-tried by the controller.
8484
PoweringOnFailedReason = "PoweringOnFailed"
8585

86+
// NotFoundByBIOSUUIDReason (Severity=Warning) documents a VSphereVM which can't be found by BIOS UUID.
87+
// Those kind of errors could be transient sometimes and failed VSphereVM are automatically
88+
// reconciled by the controller.
89+
NotFoundByBIOSUUIDReason = "NotFoundByBIOSUUID"
90+
8691
// TaskFailure (Severity=Warning) documents a VSphereMachine/VSphere task failure; the reconcile look will automatically
8792
// retry the operation, but a user intervention might be required to fix the problem.
8893
TaskFailure = "TaskFailure"

pkg/services/govmomi/service.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ import (
3030
"github.com/vmware/govmomi/vim25/types"
3131
corev1 "k8s.io/api/core/v1"
3232
apitypes "k8s.io/apimachinery/pkg/types"
33-
"k8s.io/utils/pointer"
3433
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
3534
bootstrapv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1"
36-
capierrors "sigs.k8s.io/cluster-api/errors"
3735
"sigs.k8s.io/cluster-api/util/conditions"
3836
"sigs.k8s.io/controller-runtime/pkg/reconcile"
3937

@@ -83,10 +81,12 @@ func (vms *VMService) ReconcileVM(ctx *context.VMContext) (vm infrav1.VirtualMac
8381
return vm, err
8482
}
8583

86-
// If the machine was not found by BIOS UUID it means that it got deleted from vcenter directly
84+
// If the machine was not found by BIOS UUID, it could mean that the machine got deleted from vcenter directly,
85+
// but sometimes this error is transient, for instance, if the storage was temporarily disconnected but
86+
// later recovered, the machine will recover from this error.
8787
if wasNotFoundByBIOSUUID(err) {
88-
ctx.VSphereVM.Status.FailureReason = capierrors.MachineStatusErrorPtr(capierrors.UpdateMachineError)
89-
ctx.VSphereVM.Status.FailureMessage = pointer.String(fmt.Sprintf("Unable to find VM by BIOS UUID %s. The vm was removed from infra", ctx.VSphereVM.Spec.BiosUUID))
88+
conditions.MarkFalse(ctx.VSphereVM, infrav1.VMProvisionedCondition, infrav1.NotFoundByBIOSUUIDReason, clusterv1.ConditionSeverityWarning, err.Error())
89+
vm.State = infrav1.VirtualMachineStateNotFound
9090
return vm, err
9191
}
9292

0 commit comments

Comments
 (0)