-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix checkup inconsistencies #42
Changes from 1 commit
930250b
f49001b
1d3ffbd
29fe754
1f7eff0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,8 +79,10 @@ const ( | |
VMIUnderTestNamePrefix = "vmi-under-test" | ||
hotplugVolumeName = "hotplug-volume" | ||
pvcName = "checkup-pvc" | ||
strTrue = "true" | ||
|
||
AnnDefaultStorageClass = "storageclass.kubernetes.io/is-default-class" | ||
AnnDefaultVirtStorageClass = "storageclass.kubevirt.io/is-default-virt-class" | ||
AnnDefaultStorageClass = "storageclass.kubernetes.io/is-default-class" | ||
|
||
ErrNoDefaultStorageClass = "no default storage class" | ||
ErrPvcNotBound = "pvc failed to bound" | ||
|
@@ -89,14 +91,15 @@ const ( | |
// FIXME: need to decide of we want to return errors in this cases | ||
// errMissingVolumeSnapshotClass = "there are StorageProfiles missing VolumeSnapshotClass" | ||
// errVMsWithNonVirtRbdStorageClass = "there are VMs using the plain RBD storageclass when the virtualization storageclass exists" | ||
ErrVMsWithUnsetEfsStorageClass = "there are VMs using an EFS storageclass where the gid and uid are not set in the storageclass" | ||
ErrGoldenImagesNotUpToDate = "there are golden images whose DataImportCron is not up to date or DataSource is not ready" | ||
ErrGoldenImageNoDataSource = "dataSource has no PVC or Snapshot source" | ||
ErrBootFailedOnSomeVMs = "some of the VMs failed to complete boot on time" | ||
MessageBootCompletedOnAllVMs = "Boot completed on all VMs on time" | ||
MessageSkipNoGoldenImage = "Skip check - no golden image PVC or Snapshot" | ||
MessageSkipNoVMI = "Skip check - no VMI" | ||
MessageSkipSingleNode = "Skip check - single node" | ||
ErrVMsWithUnsetEfsStorageClass = "there are VMs using an EFS storageclass where the gid and uid are not set in the storageclass" | ||
ErrGoldenImagesNotUpToDate = "there are golden images whose DataImportCron is not up to date or DataSource is not ready" | ||
ErrGoldenImageNoDataSource = "dataSource has no PVC or Snapshot source" | ||
ErrBootFailedOnSomeVMs = "some of the VMs failed to complete boot on time" | ||
MessageBootCompletedOnAllVMs = "Boot completed on all VMs on time" | ||
MessageSkipNoDefaultStorageClass = "Skip check - no default storage class" | ||
MessageSkipNoGoldenImage = "Skip check - no golden image PVC or Snapshot" | ||
MessageSkipNoVMI = "Skip check - no VMI" | ||
MessageSkipSingleNode = "Skip check - single node" | ||
|
||
pollInterval = 5 * time.Second | ||
) | ||
|
@@ -111,14 +114,15 @@ var UnsupportedProvisioners = map[string]struct{}{ | |
} | ||
|
||
type Checkup struct { | ||
client kubeVirtStorageClient | ||
namespace string | ||
checkupConfig config.Config | ||
goldenImageScs []string | ||
goldenImagePvc *corev1.PersistentVolumeClaim | ||
goldenImageSnap *snapshotv1.VolumeSnapshot | ||
vmUnderTest *kvcorev1.VirtualMachine | ||
results status.Results | ||
client kubeVirtStorageClient | ||
namespace string | ||
checkupConfig config.Config | ||
defaultStorageClass string | ||
goldenImageScs []string | ||
goldenImagePvc *corev1.PersistentVolumeClaim | ||
goldenImageSnap *snapshotv1.VolumeSnapshot | ||
vmUnderTest *kvcorev1.VirtualMachine | ||
results status.Results | ||
} | ||
|
||
type goldenImagesCheckState struct { | ||
|
@@ -392,18 +396,35 @@ func (c *Checkup) updateGoldenImageSnapshot(snap *snapshotv1.VolumeSnapshot) { | |
func (c *Checkup) checkDefaultStorageClass(scs *storagev1.StorageClassList, errStr *string) { | ||
log.Print("checkDefaultStorageClass") | ||
|
||
var multipleDefaultStorageClasses, hasDefaultVirtStorageClass, hasDefaultStorageClass bool | ||
for i := range scs.Items { | ||
sc := scs.Items[i] | ||
if sc.Annotations[AnnDefaultStorageClass] == "true" { | ||
if c.results.DefaultStorageClass != "" { | ||
c.results.DefaultStorageClass = ErrMultipleDefaultStorageClasses | ||
appendSep(errStr, ErrMultipleDefaultStorageClasses) | ||
break | ||
if sc.Annotations[AnnDefaultVirtStorageClass] == strTrue { | ||
if !hasDefaultVirtStorageClass { | ||
hasDefaultVirtStorageClass = true | ||
c.defaultStorageClass = sc.Name | ||
} else { | ||
multipleDefaultStorageClasses = true | ||
} | ||
} | ||
if sc.Annotations[AnnDefaultStorageClass] == strTrue { | ||
if !hasDefaultStorageClass { | ||
hasDefaultStorageClass = true | ||
if !hasDefaultVirtStorageClass { | ||
c.defaultStorageClass = sc.Name | ||
} | ||
} else { | ||
multipleDefaultStorageClasses = true | ||
} | ||
c.results.DefaultStorageClass = sc.Name | ||
} | ||
} | ||
if c.results.DefaultStorageClass == "" { | ||
|
||
if multipleDefaultStorageClasses { | ||
c.results.DefaultStorageClass = ErrMultipleDefaultStorageClasses | ||
appendSep(errStr, ErrMultipleDefaultStorageClasses) | ||
} else if c.defaultStorageClass != "" { | ||
c.results.DefaultStorageClass = c.defaultStorageClass | ||
} else { | ||
c.results.DefaultStorageClass = ErrNoDefaultStorageClass | ||
appendSep(errStr, ErrNoDefaultStorageClass) | ||
} | ||
|
@@ -412,6 +433,12 @@ func (c *Checkup) checkDefaultStorageClass(scs *storagev1.StorageClassList, errS | |
func (c *Checkup) checkPVCCreationAndBinding(ctx context.Context, errStr *string) error { | ||
log.Print("checkPVCCreationAndBinding") | ||
|
||
if c.defaultStorageClass == "" && c.checkupConfig.StorageClass == "" { | ||
log.Print(MessageSkipNoDefaultStorageClass) | ||
c.results.PVCBound = MessageSkipNoDefaultStorageClass | ||
return nil | ||
} | ||
|
||
dv := &cdiv1.DataVolume{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: pvcName, | ||
|
@@ -422,7 +449,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": "true", | ||
"cdi.kubevirt.io/storage.bind.immediate.requested": strTrue, | ||
}, | ||
}, | ||
Spec: cdiv1.DataVolumeSpec{ | ||
|
@@ -786,6 +813,13 @@ func (c *Checkup) Config() config.Config { | |
|
||
func (c *Checkup) checkVMIBoot(ctx context.Context, errStr *string) error { | ||
log.Print("checkVMIBoot") | ||
|
||
if c.defaultStorageClass == "" { | ||
log.Print(MessageSkipNoDefaultStorageClass) | ||
c.results.VMBootFromGoldenImage = MessageSkipNoDefaultStorageClass | ||
return nil | ||
} | ||
|
||
if c.goldenImagePvc == nil && c.goldenImageSnap == nil { | ||
log.Print(MessageSkipNoGoldenImage) | ||
c.results.VMBootFromGoldenImage = MessageSkipNoGoldenImage | ||
|
@@ -980,6 +1014,12 @@ func (c *Checkup) checkConcurrentVMIBoot(ctx context.Context, errStr *string) er | |
numOfVMs := c.checkupConfig.NumOfVMs | ||
log.Printf("checkConcurrentVMIBoot numOfVMs:%d", numOfVMs) | ||
|
||
if c.defaultStorageClass == "" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same question There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same answer:) |
||
log.Print(MessageSkipNoDefaultStorageClass) | ||
c.results.ConcurrentVMBoot = MessageSkipNoDefaultStorageClass | ||
return nil | ||
} | ||
|
||
if c.goldenImagePvc == nil && c.goldenImageSnap == nil { | ||
log.Print(MessageSkipNoGoldenImage) | ||
c.results.ConcurrentVMBoot = MessageSkipNoGoldenImage | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,14 +89,24 @@ var tests = map[string]struct { | |
expectedErr string | ||
}{ | ||
"noStorageClasses": { | ||
clientConfig: clientConfig{noStorageClasses: true}, | ||
expectedResults: map[string]string{reporter.DefaultStorageClassKey: checkup.ErrNoDefaultStorageClass}, | ||
expectedErr: checkup.ErrNoDefaultStorageClass, | ||
clientConfig: clientConfig{noStorageClasses: true, expectNoVMI: true}, | ||
expectedResults: map[string]string{ | ||
reporter.DefaultStorageClassKey: checkup.ErrNoDefaultStorageClass, | ||
reporter.PVCBoundKey: checkup.MessageSkipNoDefaultStorageClass, | ||
reporter.VMBootFromGoldenImageKey: checkup.MessageSkipNoDefaultStorageClass, | ||
reporter.ConcurrentVMBootKey: checkup.MessageSkipNoDefaultStorageClass, | ||
}, | ||
expectedErr: checkup.ErrNoDefaultStorageClass, | ||
}, | ||
"noDefaultStorageClass": { | ||
clientConfig: clientConfig{noDefaultStorageClass: true}, | ||
expectedResults: map[string]string{reporter.DefaultStorageClassKey: checkup.ErrNoDefaultStorageClass}, | ||
expectedErr: checkup.ErrNoDefaultStorageClass, | ||
clientConfig: clientConfig{noDefaultStorageClass: true, expectNoVMI: true}, | ||
expectedResults: map[string]string{ | ||
reporter.DefaultStorageClassKey: checkup.ErrNoDefaultStorageClass, | ||
reporter.PVCBoundKey: checkup.MessageSkipNoDefaultStorageClass, | ||
reporter.VMBootFromGoldenImageKey: checkup.MessageSkipNoDefaultStorageClass, | ||
reporter.ConcurrentVMBootKey: checkup.MessageSkipNoDefaultStorageClass, | ||
}, | ||
expectedErr: checkup.ErrNoDefaultStorageClass, | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldnt you add also virt storage class tests? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I should :) |
||
"multipleDefaultStorageClasses": { | ||
clientConfig: clientConfig{multipleDefaultStorageClasses: true}, | ||
|
@@ -527,6 +537,10 @@ func (cs *clientStub) ListVolumeSnapshotClasses(ctx context.Context) (*snapshotv | |
} | ||
|
||
func (cs *clientStub) ListDataImportCrons(ctx context.Context, namespace string) (*cdiv1.DataImportCronList, error) { | ||
if namespace != testNamespace { | ||
return &cdiv1.DataImportCronList{}, nil | ||
} | ||
|
||
dicList := &cdiv1.DataImportCronList{ | ||
Items: []cdiv1.DataImportCron{ | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here you dont need to also check:
&& c.checkupConfig.StorageClass == ""
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right!