Fix: fix unhandled err (#2423)

* Fix: fix unhandled err

refer to https://lift.sonatype.com/result/bhamail/kubevela/01FFT7CSVNCPF6808ZM856V3HN?tab=results

* Test: fix panic err
This commit is contained in:
Tianxin Dong
2021-10-12 14:36:09 +08:00
committed by GitHub
parent 96c52ab2fc
commit 287c895daf
6 changed files with 29 additions and 11 deletions
+5 -2
View File
@@ -326,8 +326,11 @@ func waitWebhookSecretVolume(certDir string, timeout, interval time.Duration) er
if err != nil {
return false
}
// nolint
defer f.Close()
defer func() {
if err := f.Close(); err != nil {
klog.Error(err, "Failed to close file")
}
}()
// check if dir is empty
if _, err := f.Readdir(1); errors.Is(err, io.EOF) {
return false