Skip to content

Commit

Permalink
Merge pull request #280 from nunnatsa/dv-import-fail-reason
Browse files Browse the repository at this point in the history
Add new reason for failed vm
  • Loading branch information
k8s-ci-robot committed Apr 17, 2024
2 parents f80289f + 18aae17 commit ada65bc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/kubevirt/machine.go
Expand Up @@ -283,15 +283,20 @@ func (m *Machine) getDVNotProvisionedReason(dv *cdiv1.DataVolume) (string, strin
case cdiv1.Failed:
return "DVFailed", msg, true
default:
reason := "DVNotReady"
for _, dvCond := range dv.Status.Conditions {
if dvCond.Type == cdiv1.DataVolumeRunning {
if dvCond.Status == corev1.ConditionFalse {
if dvCond.Reason == "ImagePullFailed" {
reason = "DVImagePullFailed"
}

msg = fmt.Sprintf("DataVolume %s import is not running: %s", dv.Name, dvCond.Message)
}
break
}
}
return "DVNotReady", msg, true
return reason, msg, true
}
}

Expand Down
13 changes: 13 additions & 0 deletions pkg/kubevirt/machine_test.go
Expand Up @@ -956,6 +956,19 @@ var _ = Describe("check GetVMNotReadyReason", func() {
Conditions: []cdiv1.DataVolumeCondition{},
},
}, "DVNotReady", "is not ready; Phase: ImportInProgress"),
Entry("dv with Running condition and reason = 'ImagePullFailed'", &kubevirtv1.VirtualMachine{}, &cdiv1.DataVolume{
Status: cdiv1.DataVolumeStatus{
Phase: cdiv1.ImportInProgress,
Conditions: []cdiv1.DataVolumeCondition{
{
Type: cdiv1.DataVolumeRunning,
Status: corev1.ConditionFalse,
Reason: "ImagePullFailed",
Message: "test message",
},
},
},
}, "DVImagePullFailed", "test message"),
)
})

Expand Down

0 comments on commit ada65bc

Please sign in to comment.