Skip to content

Commit 207de58

Browse files
committed
fix: when vmExport is in skipped phase, exit task
vm export cannot recover from skipped phase and thus it doesn't make sense to wait. Signed-off-by: Karel Simon <ksimon@redhat.com>
1 parent b10a4b3 commit 207de58

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

modules/disk-uploader/pkg/vmexport/vmexport.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ func WaitUntilVirtualMachineExportReady(client kubecli.KubevirtClient, namespace
6363
if vmExport.Status != nil {
6464
log.Logger().Info("VirtualMachineExport object status", zap.String("status", string(vmExport.Status.Phase)))
6565

66+
if vmExport.Status.Phase == v1beta1.Skipped {
67+
log.Logger().Error("VirtualMachineExport is in Skipped state, and can't be exported - exiting.")
68+
return false, fmt.Errorf("VirtualMachineExport is in skipped phase")
69+
}
70+
6671
if vmExport.Status.Phase == v1beta1.Ready {
6772
log.Logger().Info("VirtualMachineExport is in Ready state, and export source is not longer used")
6873
return true, nil

modules/disk-uploader/pkg/vmexport/vmexport_suite_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ package vmexport_test
33
import (
44
"testing"
55

6+
"github.com/kubevirt/kubevirt-tekton-tasks/modules/shared/pkg/log"
67
. "github.com/onsi/ginkgo/v2"
78
. "github.com/onsi/gomega"
9+
"go.uber.org/zap"
810
)
911

1012
func TestVMExport(t *testing.T) {
13+
log.InitLogger(zap.InfoLevel)
1114
RegisterFailHandler(Fail)
1215
RunSpecs(t, "VMExport Suite")
1316
}

modules/disk-uploader/pkg/vmexport/vmexport_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,27 @@ var _ = Describe("VMExport", func() {
114114
})
115115
})
116116

117+
Describe("WaitUntilVirtualMachineExportSkipped", func() {
118+
It("should return error", func() {
119+
_, err := vmExportClient.ExportV1beta1().VirtualMachineExports(namespace).Create(context.Background(),
120+
&v1beta1.VirtualMachineExport{
121+
ObjectMeta: metav1.ObjectMeta{
122+
Name: name,
123+
Namespace: namespace,
124+
},
125+
Status: &v1beta1.VirtualMachineExportStatus{
126+
Phase: v1beta1.Skipped,
127+
},
128+
},
129+
metav1.CreateOptions{},
130+
)
131+
Expect(err).NotTo(HaveOccurred())
132+
133+
err = vmexport.WaitUntilVirtualMachineExportReady(virtClient, namespace, name)
134+
Expect(err).To(HaveOccurred())
135+
})
136+
})
137+
117138
Describe("GetRawDiskUrlFromVolumes", func() {
118139
Context("when retrieved URL from the VirtualMachineExport volumes", func() {
119140
BeforeEach(func() {

0 commit comments

Comments
 (0)