Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/core/v1alpha2/vmcondition/condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ func (r RunningReason) String() string {
const (
ReasonVirtualMachineNotRunning RunningReason = "NotRunning"
ReasonVirtualMachineRunning RunningReason = "Running"
ReasonNoBootableDeviceFound RunningReason = "NoBootableDevice"
ReasonInternalVirtualMachineError RunningReason = "InternalVirtualMachineError"
ReasonPodNotStarted RunningReason = "PodNotStarted"
ReasonPodTerminating RunningReason = "PodTerminating"
Expand Down
2 changes: 1 addition & 1 deletion build/components/versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ firmware:
libvirt: v10.9.0
edk2: stable202411
core:
3p-kubevirt: v1.6.2-v12n.35
3p-kubevirt: feat/vmi/no-bootable-provide
3p-containerized-data-importer: v1.60.3-v12n.19
distribution: 2.8.3
package:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,17 @@ func (h *LifeCycleHandler) syncRunning(ctx context.Context, vm *v1alpha2.Virtual

if vm.Status.Phase == v1alpha2.MachineRunning {
cb.Reason(vmcondition.ReasonVirtualMachineRunning).Status(metav1.ConditionTrue)

for _, c := range kvvmi.Status.Conditions {
if c.Type == "BootFailed" {
cb.Status(conditionStatus(string(c.Status))).
Reason(vmcondition.ReasonNoBootableDeviceFound).
Message("Among all the virtual machine’s block devices, there is no device from which it can boot.")
conditions.SetCondition(cb, &vm.Status.Conditions)
return nil
}
}

conditions.SetCondition(cb, &vm.Status.Conditions)
return nil
}
Expand Down
81 changes: 81 additions & 0 deletions test/e2e/vm/no_bootable_device.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
Copyright 2026 Flant JSC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package vm

import (
"context"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
crclient "sigs.k8s.io/controller-runtime/pkg/client"

vmbuilder "github.com/deckhouse/virtualization-controller/pkg/builder/vm"
"github.com/deckhouse/virtualization-controller/pkg/controller/conditions"
"github.com/deckhouse/virtualization/api/core/v1alpha2"
"github.com/deckhouse/virtualization/api/core/v1alpha2/vmcondition"
"github.com/deckhouse/virtualization/test/e2e/internal/framework"
"github.com/deckhouse/virtualization/test/e2e/internal/object"
"github.com/deckhouse/virtualization/test/e2e/internal/precheck"
"github.com/deckhouse/virtualization/test/e2e/internal/util"
)

var _ = Describe("VirtualMachineNoBootableDevice", Label(precheck.NoPrecheck), func() {
var (
f *framework.Framework
ctx context.Context
)

BeforeEach(func() {
ctx = context.Background()
f = framework.NewFramework("vm-no-bootable-device")
DeferCleanup(f.After)
f.Before()
})

It("sets Running condition reason to NoBootableDevice", func() {
By("Generating a blank disk and virtual machine with no bootable devices")
vdBlank := object.NewBlankVD("vd-blank", f.Namespace().Name, nil, ptr.To(resource.MustParse("100Mi")))

vm := object.NewMinimalVM("vm-", f.Namespace().Name,
vmbuilder.WithBlockDeviceRefs(v1alpha2.BlockDeviceSpecRef{
Kind: v1alpha2.DiskDevice,
Name: vdBlank.Name,
}),
)

By("Creating resources")
err := f.CreateWithDeferredDeletion(ctx, vdBlank, vm)
Expect(err).NotTo(HaveOccurred())

By("Waiting for virtual machine to be Running")
util.UntilObjectPhase(ctx, string(v1alpha2.MachineRunning), framework.LongTimeout, vm)

By("Checking Running condition reason indicates no bootable device")
Eventually(func(g Gomega) {
err = f.GenericClient().Get(ctx, crclient.ObjectKeyFromObject(vm), vm)
g.Expect(err).NotTo(HaveOccurred())

runningCondition, found := conditions.GetCondition(vmcondition.TypeRunning, vm.Status.Conditions)
g.Expect(found).To(BeTrue())
g.Expect(runningCondition.Reason).To(Equal(vmcondition.ReasonNoBootableDeviceFound.String()))
g.Expect(runningCondition.Status).To(Equal(metav1.ConditionTrue))
}).WithTimeout(framework.LongTimeout).WithPolling(framework.PollingInterval).Should(Succeed())
})
})
Loading