mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +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
|
err error
|
||||||
pod *api.Pod
|
pod *api.Pod
|
||||||
pods []api.Pod
|
pods []api.Pod
|
||||||
sync.RWMutex
|
sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func MakeMockPodRegistry(pods []api.Pod) *MockPodRegistry {
|
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) {
|
func (registry *MockPodRegistry) ListPods(selector labels.Selector) ([]api.Pod, error) {
|
||||||
registry.RLock()
|
registry.Lock()
|
||||||
defer registry.RUnlock()
|
defer registry.Unlock()
|
||||||
if registry.err != nil {
|
if registry.err != nil {
|
||||||
return registry.pods, registry.err
|
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) {
|
func (registry *MockPodRegistry) GetPod(podId string) (*api.Pod, error) {
|
||||||
registry.RLock()
|
registry.Lock()
|
||||||
defer registry.RUnlock()
|
defer registry.Unlock()
|
||||||
return registry.pod, registry.err
|
return registry.pod, registry.err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (registry *MockPodRegistry) CreatePod(machine string, pod api.Pod) error {
|
func (registry *MockPodRegistry) CreatePod(machine string, pod api.Pod) error {
|
||||||
registry.RLock()
|
registry.Lock()
|
||||||
defer registry.RUnlock()
|
defer registry.Unlock()
|
||||||
return registry.err
|
return registry.err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (registry *MockPodRegistry) UpdatePod(pod api.Pod) error {
|
func (registry *MockPodRegistry) UpdatePod(pod api.Pod) error {
|
||||||
registry.RLock()
|
registry.Lock()
|
||||||
defer registry.RUnlock()
|
defer registry.Unlock()
|
||||||
return registry.err
|
return registry.err
|
||||||
}
|
}
|
||||||
func (registry *MockPodRegistry) DeletePod(podId string) error {
|
func (registry *MockPodRegistry) DeletePod(podId string) error {
|
||||||
registry.RLock()
|
registry.Lock()
|
||||||
defer registry.RUnlock()
|
defer registry.Unlock()
|
||||||
return registry.err
|
return registry.err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user