Skip to content

Commit ada65bc

Browse files
authored
Merge pull request kubernetes-sigs#280 from nunnatsa/dv-import-fail-reason
Add new reason for failed vm
2 parents f80289f + 18aae17 commit ada65bc

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

pkg/kubevirt/machine.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,15 +283,20 @@ func (m *Machine) getDVNotProvisionedReason(dv *cdiv1.DataVolume) (string, strin
283283
case cdiv1.Failed:
284284
return "DVFailed", msg, true
285285
default:
286+
reason := "DVNotReady"
286287
for _, dvCond := range dv.Status.Conditions {
287288
if dvCond.Type == cdiv1.DataVolumeRunning {
288289
if dvCond.Status == corev1.ConditionFalse {
290+
if dvCond.Reason == "ImagePullFailed" {
291+
reason = "DVImagePullFailed"
292+
}
293+
289294
msg = fmt.Sprintf("DataVolume %s import is not running: %s", dv.Name, dvCond.Message)
290295
}
291296
break
292297
}
293298
}
294-
return "DVNotReady", msg, true
299+
return reason, msg, true
295300
}
296301
}
297302

pkg/kubevirt/machine_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,19 @@ var _ = Describe("check GetVMNotReadyReason", func() {
956956
Conditions: []cdiv1.DataVolumeCondition{},
957957
},
958958
}, "DVNotReady", "is not ready; Phase: ImportInProgress"),
959+
Entry("dv with Running condition and reason = 'ImagePullFailed'", &kubevirtv1.VirtualMachine{}, &cdiv1.DataVolume{
960+
Status: cdiv1.DataVolumeStatus{
961+
Phase: cdiv1.ImportInProgress,
962+
Conditions: []cdiv1.DataVolumeCondition{
963+
{
964+
Type: cdiv1.DataVolumeRunning,
965+
Status: corev1.ConditionFalse,
966+
Reason: "ImagePullFailed",
967+
Message: "test message",
968+
},
969+
},
970+
},
971+
}, "DVImagePullFailed", "test message"),
959972
)
960973
})
961974

0 commit comments

Comments
 (0)