mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
use mutex instead of rwmutex
This commit is contained in:
parent
3083a33e5f
commit
f99a50ba69
@ -27,7 +27,7 @@ type MockPodRegistry struct {
|
||||
err error
|
||||
pod *api.Pod
|
||||
pods []api.Pod
|
||||
sync.RWMutex
|
||||
sync.Mutex
|
||||
}
|
||||
|
||||
func MakeMockPodRegistry(pods []api.Pod) *MockPodRegistry {
|
||||
@ -37,8 +37,8 @@ func MakeMockPodRegistry(pods []api.Pod) *MockPodRegistry {
|
||||
}
|
||||
|
||||
func (registry *MockPodRegistry) ListPods(selector labels.Selector) ([]api.Pod, error) {
|
||||
registry.RLock()
|
||||
defer registry.RUnlock()
|
||||
registry.Lock()
|
||||
defer registry.Unlock()
|
||||
if registry.err != nil {
|
||||
return registry.pods, registry.err
|
||||
}
|
||||
@ -52,24 +52,24 @@ func (registry *MockPodRegistry) ListPods(selector labels.Selector) ([]api.Pod,
|
||||
}
|
||||
|
||||
func (registry *MockPodRegistry) GetPod(podId string) (*api.Pod, error) {
|
||||
registry.RLock()
|
||||
defer registry.RUnlock()
|
||||
registry.Lock()
|
||||
defer registry.Unlock()
|
||||
return registry.pod, registry.err
|
||||
}
|
||||
|
||||
func (registry *MockPodRegistry) CreatePod(machine string, pod api.Pod) error {
|
||||
registry.RLock()
|
||||
defer registry.RUnlock()
|
||||
registry.Lock()
|
||||
defer registry.Unlock()
|
||||
return registry.err
|
||||
}
|
||||
|
||||
func (registry *MockPodRegistry) UpdatePod(pod api.Pod) error {
|
||||
registry.RLock()
|
||||
defer registry.RUnlock()
|
||||
registry.Lock()
|
||||
defer registry.Unlock()
|
||||
return registry.err
|
||||
}
|
||||
func (registry *MockPodRegistry) DeletePod(podId string) error {
|
||||
registry.RLock()
|
||||
defer registry.RUnlock()
|
||||
registry.Lock()
|
||||
defer registry.Unlock()
|
||||
return registry.err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user