Skip to content

Commit 003bb19

Browse files
committed
Add more condition logic for failed VMs
Signed-off-by: David Vossel <[email protected]>
1 parent c2cd191 commit 003bb19

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

api/v1alpha1/condition_consts.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ const (
3333
// WaitingForBootstrapDataReason (Severity=Info) documents a KubevirtMachine waiting for the bootstrap
3434
// script to be ready before starting to create the VM that provides the KubevirtMachine infrastructure.
3535
WaitingForBootstrapDataReason = "WaitingForBootstrapData"
36+
37+
// VMCreateFailed (Severity=Error) documents a KubevirtMachine that is unable to create the
38+
// corresponding VM object.
39+
VMCreateFailedReason = "VMCreateFailed"
3640
)
3741

3842
const (

controllers/kubevirtmachine_controller.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ import (
2020
gocontext "context"
2121
"fmt"
2222
"regexp"
23-
"sigs.k8s.io/controller-runtime/pkg/builder"
2423
"time"
2524

25+
"sigs.k8s.io/controller-runtime/pkg/builder"
26+
2627
"github.com/pkg/errors"
2728
"gopkg.in/yaml.v3"
2829
corev1 "k8s.io/api/core/v1"
@@ -264,6 +265,7 @@ func (r *KubevirtMachineReconciler) reconcileNormal(ctx *context.MachineContext)
264265
if !isTerminal && !externalMachine.Exists() {
265266
ctx.KubevirtMachine.Status.Ready = false
266267
if err := externalMachine.Create(ctx.Context); err != nil {
268+
conditions.MarkFalse(ctx.KubevirtMachine, infrav1.VMProvisionedCondition, infrav1.VMCreateFailedReason, clusterv1.ConditionSeverityError, fmt.Sprintf("Failed vm creation: %v", err))
267269
return ctrl.Result{}, errors.Wrap(err, "failed to create VM instance")
268270
}
269271
ctx.Logger.Info("VM Created, waiting on vm to be provisioned.")

0 commit comments

Comments
 (0)