mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-30 02:00:19 +00:00
25e3a961c3
When the initial DeleteVolume times out (as it does on slow clusters due to the low 10 second limit), the external-provisioner calls it again. The CSI standard requires the second call to succeed if the volume has been deleted in the meantime. This didn't work because DeleteVolume returned an error when failing to find the volume info file: rbdplugin: E1008 08:05:35.631783 1 utils.go:100] GRPC error: rbd: open err /var/lib/kubelet/plugins/csi-rbdplugin/controller/csi-rbd-622a252c-cad0-11e8-9112-deadbeef0101.json/open /var/lib/kubelet/plugins/csi-rbdplugin/controller/csi-rbd-622a252c-cad0-11e8-9112-deadbeef0101.json: no such file or directory The fix is to treat a missing volume info file as "volume already deleted" and return success. To detect this, the original os error must be wrapped, otherwise the caller of loadVolInfo cannot determine the root cause. Note that further work may be needed to make the driver really resilient, for example there are probably concurrency issues. But for now this fixes: #82
60 lines
906 B
Go
60 lines
906 B
Go
// +build go1.7
|
|
|
|
package errors
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
stderrors "errors"
|
|
)
|
|
|
|
func noErrors(at, depth int) error {
|
|
if at >= depth {
|
|
return stderrors.New("no error")
|
|
}
|
|
return noErrors(at+1, depth)
|
|
}
|
|
func yesErrors(at, depth int) error {
|
|
if at >= depth {
|
|
return New("ye error")
|
|
}
|
|
return yesErrors(at+1, depth)
|
|
}
|
|
|
|
func BenchmarkErrors(b *testing.B) {
|
|
var toperr error
|
|
type run struct {
|
|
stack int
|
|
std bool
|
|
}
|
|
runs := []run{
|
|
{10, false},
|
|
{10, true},
|
|
{100, false},
|
|
{100, true},
|
|
{1000, false},
|
|
{1000, true},
|
|
}
|
|
for _, r := range runs {
|
|
part := "pkg/errors"
|
|
if r.std {
|
|
part = "errors"
|
|
}
|
|
name := fmt.Sprintf("%s-stack-%d", part, r.stack)
|
|
b.Run(name, func(b *testing.B) {
|
|
var err error
|
|
f := yesErrors
|
|
if r.std {
|
|
f = noErrors
|
|
}
|
|
b.ReportAllocs()
|
|
for i := 0; i < b.N; i++ {
|
|
err = f(0, r.stack)
|
|
}
|
|
b.StopTimer()
|
|
toperr = err
|
|
})
|
|
}
|
|
}
|