Skip to content

Commit 3c27445

Browse files
committed
layers: continue on non-existing volume in dep-scan
When checking for an unused volume, we need to expand all available volumes. However, in case another deletion process is happening at the same time, there can be volumes we can list, but no longer check for dependencies. This would lead to errors during deletion, even though all volumes are in the expected layout. As a workaround (a fix would require syncronising volume creation/deletion between virter invocations): Ignore errors generated because a volume does no longer exist during checking if a volume is unused.
1 parent e5a9092 commit 3c27445

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

internal/virter/layer.go

+8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"compress/gzip"
1212
"crypto/sha256"
1313
"encoding/hex"
14+
"errors"
1415
"fmt"
1516
"hash"
1617
"io"
@@ -503,6 +504,13 @@ func (rl *RawLayer) DeleteIfUnused() (bool, error) {
503504
if err != nil {
504505
_, isNonVirter := err.(*nonVirterVolumeError)
505506
if isNonVirter {
507+
// Not a virter format volume -> shouldn't depend on our volumes.
508+
continue
509+
}
510+
511+
e := libvirt.Error{}
512+
if errors.As(err, &e) && e.Code == uint32(errNoStorageVol) {
513+
// Volume already deleted -> can't have a relevant dependency anyways.
506514
continue
507515
}
508516

0 commit comments

Comments
 (0)