@@ -20,7 +20,6 @@ import (
20
20
"fmt"
21
21
"path/filepath"
22
22
"strings"
23
- "sync"
24
23
25
24
"github.com/NVIDIA/nvidia-container-toolkit/internal/logger"
26
25
"github.com/NVIDIA/nvidia-container-toolkit/internal/lookup"
@@ -35,15 +34,13 @@ type mounts struct {
35
34
lookup lookup.Locator
36
35
root string
37
36
required []string
38
- sync.Mutex
39
- cache []Mount
40
37
}
41
38
42
39
var _ Discover = (* mounts )(nil )
43
40
44
41
// NewMounts creates a discoverer for the required mounts using the specified locator.
45
42
func NewMounts (logger logger.Interface , lookup lookup.Locator , root string , required []string ) Discover {
46
- return newMounts (logger , lookup , root , required )
43
+ return WithCache ( newMounts (logger , lookup , root , required ) )
47
44
}
48
45
49
46
// newMounts creates a discoverer for the required mounts using the specified locator.
@@ -60,15 +57,6 @@ func (d *mounts) Mounts() ([]Mount, error) {
60
57
if d .lookup == nil {
61
58
return nil , fmt .Errorf ("no lookup defined" )
62
59
}
63
-
64
- if d .cache != nil {
65
- d .logger .Debugf ("returning cached mounts" )
66
- return d .cache , nil
67
- }
68
-
69
- d .Lock ()
70
- defer d .Unlock ()
71
-
72
60
uniqueMounts := make (map [string ]Mount )
73
61
74
62
for _ , candidate := range d .required {
@@ -112,10 +100,7 @@ func (d *mounts) Mounts() ([]Mount, error) {
112
100
for _ , m := range uniqueMounts {
113
101
mounts = append (mounts , m )
114
102
}
115
-
116
- d .cache = mounts
117
-
118
- return d .cache , nil
103
+ return mounts , nil
119
104
}
120
105
121
106
// relativeTo returns the path relative to the root for the file locator
0 commit comments