@@ -21,6 +21,7 @@ import (
2121 "fmt"
2222
2323 . "github.com/onsi/ginkgo/v2"
24+ k8serrors "k8s.io/apimachinery/pkg/api/errors"
2425 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2526
2627 "github.com/deckhouse/virtualization/test/e2e/internal/framework"
@@ -49,7 +50,7 @@ func checkDummyHCDConfigured(ctx context.Context, f *framework.Framework) bool {
4950
5051 nodeUSBList , err := virtClient .NodeUSBDevices ().List (ctx , metav1.ListOptions {})
5152 if err != nil {
52- _ , _ = fmt . Fprintf ( GinkgoWriter , "failed to list NodeUSBDevices: %v\n " , err )
53+ GinkgoWriter . Printf ( "failed to list NodeUSBDevices: %v\n " , err )
5354 return false
5455 }
5556
@@ -62,6 +63,18 @@ func checkDummyHCDConfigured(ctx context.Context, f *framework.Framework) bool {
6263 return false
6364}
6465
66+ func (u * usbPrecheck ) checkVirtualizationDraRunning (ctx context.Context , f * framework.Framework ) bool {
67+ _ , err := f .KubeClient ().AppsV1 ().DaemonSets (metav1 .NamespaceSystem ).Get (ctx , "virtualization-dra" , metav1.GetOptions {})
68+ if err != nil {
69+ if k8serrors .IsNotFound (err ) {
70+ return false
71+ }
72+ GinkgoWriter .Printf ("failed to get virtualization-dra DaemonSet: %v\n " , err )
73+ return false
74+ }
75+ return true
76+ }
77+
6578func (u * usbPrecheck ) Run (ctx context.Context , f * framework.Framework ) error {
6679 if ! isCheckEnabled (usbPrecheckEnvName ) {
6780 _ , _ = GinkgoWriter .Write ([]byte ("USB precheck is disabled.\n " ))
@@ -73,6 +86,11 @@ func (u *usbPrecheck) Run(ctx context.Context, f *framework.Framework) error {
7386 "Run generate_dummy_hcd_ngc.sh to configure dummy_hcd USB device" , usbPrecheckEnvName )
7487 }
7588
89+ if ! u .checkVirtualizationDraRunning (ctx , f ) {
90+ return fmt .Errorf ("%s=no to disable this precheck: virtualization-dra DaemonSet is not running. " +
91+ "Configure virtualization with dra support" , usbPrecheckEnvName )
92+ }
93+
7694 return nil
7795}
7896
0 commit comments