Fix cascading deletion race condition in some tests
@@ -255,17 +255,25 @@ var _ = Describe("DataVolume Integration", func() {
vmi, err := virtClient.VirtualMachineInstance(namespace).Get(name, &metav1.GetOptions{})
if err == nil && vmi.DeletionTimestamp == nil {
err := virtClient.VirtualMachineInstance(namespace).Delete(name, &metav1.DeleteOptions{})
+ // In some tests, OwnerReferences in k8s can cause this to be deleted already
+ // just ignore 404's to avoid that race.
+ if err != nil && !errors.IsNotFound(err) {
Expect(err).ToNot(HaveOccurred())
}
}
+ }
deleteIfExistsDataVolume := func(name string, namespace string) {
dataVolume, err := virtClient.CdiClient().CdiV1alpha1().DataVolumes(namespace).Get(name, metav1.GetOptions{})
if err == nil && dataVolume.DeletionTimestamp == nil {
err = virtClient.CdiClient().CdiV1alpha1().DataVolumes(namespace).Delete(name, &metav1.DeleteOptions{})
+ // In some tests, OwnerReferences in k8s can cause this to be deleted already
+ // just ignore 404's to avoid that race.
+ if err != nil && !errors.IsNotFound(err) {
Expect(err).ToNot(HaveOccurred())
}
}
+ }
vmiIsRunningAndOwned := func(name, namespace string) {
Eventually(func() error {
@@ -594,8 +602,10 @@ var _ = Describe("DataVolume Integration", func() {
if dataVolume != nil {
err := virtClient.CdiClient().CdiV1alpha1().DataVolumes(dataVolume.Namespace).Delete(dataVolume.Name, &metav1.DeleteOptions{})
+ if err != nil && !errors.IsNotFound(err) {
Expect(err).ToNot(HaveOccurred())
}
+ }
})
table.DescribeTable("deny then allow clone request", func(role *rbacv1.Role) {
