Commit f29ac26
Avoid panic when MaxSnaps is set to 0
When the MaxSnaps configuration option is set to 0 the following panic
occurs during installation:
```
[PANICKED] Test Panicked
In [It] at: /usr/lib64/go/1.24/src/runtime/panic.go:115 @ 07/01/25 10:04:57.47
runtime error: index out of range [0] with length 0
Full Stack Trace
github.com/rancher/elemental-toolkit/v2/pkg/snapshotter.(*LoopDevice).cleanOldSnapshots(0xc00025a300)
/home/frelon/src/elemental-toolkit/pkg/snapshotter/loopdevice.go:468 +0x3e7
github.com/rancher/elemental-toolkit/v2/pkg/snapshotter.(*LoopDevice).CloseTransaction(0xc00025a300, 0xc000234a00)
/home/frelon/src/elemental-toolkit/pkg/snapshotter/loopdevice.go:271 +0x11d5
github.com/rancher/elemental-toolkit/v2/pkg/snapshotter_test.init.func3.12()
/home/frelon/src/elemental-toolkit/pkg/snapshotter/loopdevice_test.go:204 +0x38e
```
This commit checks that we don't try to delete old snapshots in case
there are none.
Signed-off-by: Fredrik Lönnegren <[email protected]>
(cherry picked from commit d8450e0)1 parent 46dcd19 commit f29ac26
2 files changed
+15
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
464 | 464 | | |
465 | 465 | | |
466 | 466 | | |
467 | | - | |
| 467 | + | |
468 | 468 | | |
469 | 469 | | |
470 | 470 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
25 | 28 | | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
29 | 32 | | |
30 | 33 | | |
31 | | - | |
32 | | - | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
192 | 193 | | |
193 | 194 | | |
194 | 195 | | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
195 | 207 | | |
196 | 208 | | |
197 | 209 | | |
| |||
0 commit comments