@@ -20,7 +20,6 @@ import (
2020 "fmt"
2121 "path/filepath"
2222 "strings"
23- "sync"
2423
2524 "github.com/NVIDIA/nvidia-container-toolkit/internal/logger"
2625 "github.com/NVIDIA/nvidia-container-toolkit/internal/lookup"
@@ -35,15 +34,13 @@ type mounts struct {
3534 lookup lookup.Locator
3635 root string
3736 required []string
38- sync.Mutex
39- cache []Mount
4037}
4138
4239var _ Discover = (* mounts )(nil )
4340
4441// NewMounts creates a discoverer for the required mounts using the specified locator.
4542func 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 ) )
4744}
4845
4946// newMounts creates a discoverer for the required mounts using the specified locator.
@@ -60,15 +57,6 @@ func (d *mounts) Mounts() ([]Mount, error) {
6057 if d .lookup == nil {
6158 return nil , fmt .Errorf ("no lookup defined" )
6259 }
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-
7260 uniqueMounts := make (map [string ]Mount )
7361
7462 for _ , candidate := range d .required {
@@ -112,10 +100,7 @@ func (d *mounts) Mounts() ([]Mount, error) {
112100 for _ , m := range uniqueMounts {
113101 mounts = append (mounts , m )
114102 }
115-
116- d .cache = mounts
117-
118- return d .cache , nil
103+ return mounts , nil
119104}
120105
121106// relativeTo returns the path relative to the root for the file locator
0 commit comments