Skip to content

Commit 4323363

Browse files
scooby87github-actions[bot]
authored andcommitted
test(vm-disk): pin the importer error against a real stuck DataVolume
The table test builds its Running conditions by hand, so it can only confirm the shape it already assumes. A DataVolume read off a cluster where the importer had failed on a 404 for days carries a Bound condition with the same error, which the message must not pick up, and proves the error sits where the controller looks for it. Assisted-by: LLM Signed-off-by: Alexey Artamonov <[email protected]> (cherry picked from commit 970ccc2)
1 parent 095d9a1 commit 4323363

2 files changed

Lines changed: 83 additions & 0 deletions

File tree

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"apiVersion": "cdi.kubevirt.io/v1beta1",
3+
"kind": "DataVolume",
4+
"metadata": {
5+
"annotations": {
6+
"cdi.kubevirt.io/storage.usePopulator": "true",
7+
"vm-disk.cozystack.io/optical": "false"
8+
},
9+
"labels": {
10+
"app.kubernetes.io/instance": "vm-disk-test",
11+
"app.kubernetes.io/managed-by": "Helm"
12+
},
13+
"name": "vm-disk-test",
14+
"namespace": "default"
15+
},
16+
"spec": {
17+
"contentType": "kubevirt",
18+
"source": {
19+
"http": {
20+
"url": "https://images.example.com/missing.img"
21+
}
22+
},
23+
"storage": {
24+
"resources": {
25+
"requests": {
26+
"storage": "1Gi"
27+
}
28+
},
29+
"storageClassName": "replicated"
30+
}
31+
},
32+
"status": {
33+
"claimName": "vm-disk-test",
34+
"conditions": [
35+
{
36+
"lastHeartbeatTime": "2026-09-30T13:19:48Z",
37+
"lastTransitionTime": "2026-09-30T13:19:32Z",
38+
"message": "target PVC vm-disk-test Pending and [prime-9ea0ceb1-e03b-48fa-9944-3de75e766f6b] : Unable to connect to http data source: expected status code 200, got 404. Status: 404 Not Found",
39+
"reason": "Pending",
40+
"status": "False",
41+
"type": "Bound"
42+
},
43+
{
44+
"lastHeartbeatTime": "2026-10-07T14:50:42Z",
45+
"lastTransitionTime": "2026-09-30T13:19:32Z",
46+
"status": "False",
47+
"type": "Ready"
48+
},
49+
{
50+
"lastHeartbeatTime": "2026-10-07T14:50:42Z",
51+
"lastTransitionTime": "2026-10-07T14:50:42Z",
52+
"message": "Unable to connect to http data source: expected status code 200, got 404. Status: 404 Not Found",
53+
"reason": "Error",
54+
"status": "False",
55+
"type": "Running"
56+
}
57+
],
58+
"phase": "ImportInProgress",
59+
"progress": "N/A",
60+
"restartCount": 1988
61+
}
62+
}

‎internal/controller/workloadmonitor_controller_test.go‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"net/http"
88
"net/http/httptest"
9+
"os"
910
"slices"
1011
"strings"
1112
"testing"
@@ -1723,6 +1724,26 @@ func TestReconcile_DataVolumeMessageCarriesTheImporterError(t *testing.T) {
17231724
})
17241725
}
17251726

1727+
// The fixture is a DataVolume read off a CDI v1.64 cluster after its importer
1728+
// had restarted 1988 times on a 404; only names and the URL are changed. For a
1729+
// single-container importer failing like this one, the pinned v1.66 differs
1730+
// only in requiring every container to run before it reports Running=True.
1731+
func TestReconcile_LiveStuckImportNamesTheSourceError(t *testing.T) {
1732+
raw, err := os.ReadFile("testdata/datavolume-http-404.json")
1733+
if err != nil {
1734+
t.Fatal(err)
1735+
}
1736+
dv := &unstructured.Unstructured{}
1737+
if err := dv.UnmarshalJSON(raw); err != nil {
1738+
t.Fatal(err)
1739+
}
1740+
got := reconcileDataVolumeMonitor(t, true, nil, dv)
1741+
const want = "DataVolume vm-disk-test is ImportInProgress: Unable to connect to http data source: expected status code 200, got 404. Status: 404 Not Found"
1742+
if *got.Status.Operational || got.Status.Message != want {
1743+
t.Errorf("Operational=%v Message=%q, want false and %q", *got.Status.Operational, got.Status.Message, want)
1744+
}
1745+
}
1746+
17261747
func TestReconcile_PopulatedDataVolumeClearsTheLastVerdict(t *testing.T) {
17271748
s := newTestScheme()
17281749
selector := map[string]string{"app.kubernetes.io/instance": "vm-disk-test"}

0 commit comments

Comments
 (0)