Skip to content

Commit

Permalink
wrong apiVersion used for VirtualMachineRestore owner references
Browse files Browse the repository at this point in the history
interestengly, only an issue on ocp

Signed-off-by: Michael Henriksen <[email protected]>
  • Loading branch information
mhenriks committed Sep 23, 2020
1 parent d5f338a commit 5778ae4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/virt-controller/watch/snapshot/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ func (t *vmRestoreTarget) Own(obj metav1.Object) {
b := true
obj.SetOwnerReferences([]metav1.OwnerReference{
{
APIVersion: snapshotv1.SchemeGroupVersion.String(),
APIVersion: kubevirtv1.GroupVersion.String(),
Kind: "VirtualMachine",
Name: t.vm.Name,
UID: t.vm.UID,
Expand Down
3 changes: 2 additions & 1 deletion pkg/virt-controller/watch/snapshot/restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
framework "k8s.io/client-go/tools/cache/testing"
"k8s.io/client-go/tools/record"

kubevirtv1 "kubevirt.io/client-go/api/v1"
v1 "kubevirt.io/client-go/api/v1"
snapshotv1 "kubevirt.io/client-go/apis/snapshot/v1alpha1"
cdifake "kubevirt.io/client-go/generated/containerized-data-importer/clientset/versioned/fake"
Expand Down Expand Up @@ -52,7 +53,7 @@ var _ = Describe("Restore controlleer", func() {
UID: uid,
OwnerReferences: []metav1.OwnerReference{
{
APIVersion: snapshotv1.SchemeGroupVersion.String(),
APIVersion: kubevirtv1.GroupVersion.String(),
Kind: "VirtualMachine",
Name: vmName,
UID: vmUID,
Expand Down
6 changes: 6 additions & 0 deletions tests/restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ var _ = Describe("VirtualMachineRestore Tests", func() {
return r.Status != nil && r.Status.Complete != nil && *r.Status.Complete
}, 180*time.Second, time.Second).Should(BeTrue())
Expect(r.OwnerReferences).To(HaveLen(1))
Expect(r.OwnerReferences[0].APIVersion).To(Equal(v1.GroupVersion.String()))
Expect(r.OwnerReferences[0].Kind).To(Equal("VirtualMachine"))
Expect(r.OwnerReferences[0].Name).To(Equal(vm.Name))
Expect(r.OwnerReferences[0].UID).To(Equal(vm.UID))
Expect(r.Status.RestoreTime).ToNot(BeNil())
Expand Down Expand Up @@ -565,6 +567,8 @@ var _ = Describe("VirtualMachineRestore Tests", func() {
Expect(v.PersistentVolumeClaim.ClaimName).ToNot(Equal(originalPVCName))
pvc, err := virtClient.CoreV1().PersistentVolumeClaims(vm.Namespace).Get(v.PersistentVolumeClaim.ClaimName, metav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
Expect(pvc.OwnerReferences[0].APIVersion).To(Equal(v1.GroupVersion.String()))
Expect(pvc.OwnerReferences[0].Kind).To(Equal("VirtualMachine"))
Expect(pvc.OwnerReferences[0].Name).To(Equal(vm.Name))
Expect(pvc.OwnerReferences[0].UID).To(Equal(vm.UID))
}
Expand Down Expand Up @@ -616,6 +620,8 @@ var _ = Describe("VirtualMachineRestore Tests", func() {
Expect(v.PersistentVolumeClaim.ClaimName).ToNot(Equal(originalPVCName))
pvc, err := virtClient.CoreV1().PersistentVolumeClaims(vm.Namespace).Get(v.PersistentVolumeClaim.ClaimName, metav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
Expect(pvc.OwnerReferences[0].APIVersion).To(Equal(v1.GroupVersion.String()))
Expect(pvc.OwnerReferences[0].Kind).To(Equal("VirtualMachine"))
Expect(pvc.OwnerReferences[0].Name).To(Equal(vm.Name))
Expect(pvc.OwnerReferences[0].UID).To(Equal(vm.UID))
}
Expand Down

0 comments on commit 5778ae4

Please sign in to comment.