@@ -18,10 +18,9 @@ package kubelet
18
18
19
19
import (
20
20
"fmt"
21
- "sync"
22
-
23
- "github.com/golang/groupcache/lru"
24
21
"k8s.io/apimachinery/pkg/types"
22
+ "k8s.io/utils/lru"
23
+
25
24
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
26
25
)
27
26
@@ -37,7 +36,6 @@ import (
37
36
// TODO(random-liu): Use more reliable cache which could collect garbage of failed pod.
38
37
// TODO(random-liu): Move reason cache to somewhere better.
39
38
type ReasonCache struct {
40
- lock sync.Mutex
41
39
cache * lru.Cache
42
40
}
43
41
@@ -63,8 +61,6 @@ func (c *ReasonCache) composeKey(uid types.UID, name string) string {
63
61
64
62
// add adds error reason into the cache
65
63
func (c * ReasonCache ) add (uid types.UID , name string , reason error , message string ) {
66
- c .lock .Lock ()
67
- defer c .lock .Unlock ()
68
64
c .cache .Add (c .composeKey (uid , name ), ReasonItem {reason , message })
69
65
}
70
66
@@ -86,17 +82,13 @@ func (c *ReasonCache) Update(uid types.UID, result kubecontainer.PodSyncResult)
86
82
87
83
// Remove removes error reason from the cache
88
84
func (c * ReasonCache ) Remove (uid types.UID , name string ) {
89
- c .lock .Lock ()
90
- defer c .lock .Unlock ()
91
85
c .cache .Remove (c .composeKey (uid , name ))
92
86
}
93
87
94
88
// Get gets error reason from the cache. The return values are error reason, error message and
95
89
// whether an error reason is found in the cache. If no error reason is found, empty string will
96
90
// be returned for error reason and error message.
97
91
func (c * ReasonCache ) Get (uid types.UID , name string ) (* ReasonItem , bool ) {
98
- c .lock .Lock ()
99
- defer c .lock .Unlock ()
100
92
value , ok := c .cache .Get (c .composeKey (uid , name ))
101
93
if ! ok {
102
94
return nil , false
0 commit comments