Merge pull request #85147 from yutedz/devmgr-rm-contents

Continue removing file in ManagerImpl#removeContents
This commit is contained in:
Kubernetes Prow Robot 2019-11-14 16:38:28 -08:00 committed by GitHub
commit 30e6238795
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -32,6 +32,7 @@ go_library(
"//pkg/util/selinux:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/errors:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
"//staging/src/k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1:go_default_library",

View File

@ -31,6 +31,7 @@ import (
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
errorsutil "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apimachinery/pkg/util/sets"
utilfeature "k8s.io/apiserver/pkg/util/feature"
pluginapi "k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1"
@ -189,6 +190,7 @@ func (m *ManagerImpl) removeContents(dir string) error {
if err != nil {
return err
}
var errs []error
for _, name := range names {
filePath := filepath.Join(dir, name)
if filePath == m.checkpointFile() {
@ -204,10 +206,12 @@ func (m *ManagerImpl) removeContents(dir string) error {
}
err = os.RemoveAll(filePath)
if err != nil {
return err
errs = append(errs, err)
klog.Errorf("Failed to remove file %s: %v", filePath, err)
continue
}
}
return nil
return errorsutil.NewAggregate(errs)
}
// checkpointFile returns device plugin checkpoint file path.