Skip to content

Commit

Permalink
Fix default storage class checks
Browse files Browse the repository at this point in the history
Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
  • Loading branch information
arnongilboa committed Dec 25, 2024
1 parent 7ab5c69 commit 2fd2089
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions pkg/internal/checkup/checkup.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ const (
VMIUnderTestNamePrefix = "vmi-under-test"
hotplugVolumeName = "hotplug-volume"
pvcName = "checkup-pvc"
strTrue = "true"
StrTrue = "true"
StrFalse = "false"

AnnDefaultVirtStorageClass = "storageclass.kubevirt.io/is-default-virt-class"
AnnDefaultStorageClass = "storageclass.kubernetes.io/is-default-class"
Expand Down Expand Up @@ -409,15 +410,15 @@ func (c *Checkup) checkDefaultStorageClass(scs *storagev1.StorageClassList, errS
var multipleDefaultStorageClasses, hasDefaultVirtStorageClass, hasDefaultStorageClass bool
for i := range scs.Items {
sc := scs.Items[i]
if sc.Annotations[AnnDefaultVirtStorageClass] == strTrue {
if sc.Annotations[AnnDefaultVirtStorageClass] == StrTrue {
if !hasDefaultVirtStorageClass {
hasDefaultVirtStorageClass = true
c.defaultStorageClass = sc.Name
} else {
multipleDefaultStorageClasses = true
}
}
if sc.Annotations[AnnDefaultStorageClass] == strTrue {
if sc.Annotations[AnnDefaultStorageClass] == StrTrue {
if !hasDefaultStorageClass {
hasDefaultStorageClass = true
if !hasDefaultVirtStorageClass {
Expand Down Expand Up @@ -459,7 +460,7 @@ func (c *Checkup) checkPVCCreationAndBinding(ctx context.Context, errStr *string
UID: types.UID(c.checkupConfig.PodUID),
}},
Annotations: map[string]string{
"cdi.kubevirt.io/storage.bind.immediate.requested": strTrue,
"cdi.kubevirt.io/storage.bind.immediate.requested": StrTrue,
},
},
Spec: cdiv1.DataVolumeSpec{
Expand Down Expand Up @@ -824,7 +825,7 @@ func (c *Checkup) Config() config.Config {
func (c *Checkup) checkVMIBoot(ctx context.Context, errStr *string) error {
log.Print("checkVMIBoot")

if c.defaultStorageClass == "" {
if c.defaultStorageClass == "" && c.checkupConfig.StorageClass == "" {
log.Print(MessageSkipNoDefaultStorageClass)
c.results.VMBootFromGoldenImage = MessageSkipNoDefaultStorageClass
return nil
Expand Down Expand Up @@ -1029,7 +1030,7 @@ func (c *Checkup) checkConcurrentVMIBoot(ctx context.Context, errStr *string) er
numOfVMs := c.checkupConfig.NumOfVMs
log.Printf("checkConcurrentVMIBoot numOfVMs:%d", numOfVMs)

if c.defaultStorageClass == "" {
if c.defaultStorageClass == "" && c.checkupConfig.StorageClass == "" {
log.Print(MessageSkipNoDefaultStorageClass)
c.results.ConcurrentVMBoot = MessageSkipNoDefaultStorageClass
return nil
Expand Down

0 comments on commit 2fd2089

Please sign in to comment.