Skip to content

Commit fb046f7

Browse files
committed
Continue removing file in ManagerImpl#removeContents
1 parent bcb171b commit fb046f7

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pkg/kubelet/cm/devicemanager/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ go_library(
3232
"//pkg/util/selinux:go_default_library",
3333
"//staging/src/k8s.io/api/core/v1:go_default_library",
3434
"//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library",
35+
"//staging/src/k8s.io/apimachinery/pkg/util/errors:go_default_library",
3536
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
3637
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
3738
"//staging/src/k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1:go_default_library",

pkg/kubelet/cm/devicemanager/manager.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131

3232
v1 "k8s.io/api/core/v1"
3333
"k8s.io/apimachinery/pkg/api/resource"
34+
errorsutil "k8s.io/apimachinery/pkg/util/errors"
3435
"k8s.io/apimachinery/pkg/util/sets"
3536
utilfeature "k8s.io/apiserver/pkg/util/feature"
3637
pluginapi "k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1"
@@ -189,6 +190,7 @@ func (m *ManagerImpl) removeContents(dir string) error {
189190
if err != nil {
190191
return err
191192
}
193+
var errs []error
192194
for _, name := range names {
193195
filePath := filepath.Join(dir, name)
194196
if filePath == m.checkpointFile() {
@@ -204,10 +206,12 @@ func (m *ManagerImpl) removeContents(dir string) error {
204206
}
205207
err = os.RemoveAll(filePath)
206208
if err != nil {
207-
return err
209+
errs = append(errs, err)
210+
klog.Errorf("Failed to remove file %s: %v", filePath, err)
211+
continue
208212
}
209213
}
210-
return nil
214+
return errorsutil.NewAggregate(errs)
211215
}
212216

213217
// checkpointFile returns device plugin checkpoint file path.

0 commit comments

Comments
 (0)