From d64f210af3e7a2ac013a36ee917a857397dac297 Mon Sep 17 00:00:00 2001 From: James Rasell Date: Thu, 29 Aug 2019 09:17:33 +0100 Subject: [PATCH] Use mutex when reading out all policies to remove possible race. --- pkg/policy/backend/memory/memory.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/policy/backend/memory/memory.go b/pkg/policy/backend/memory/memory.go index 407c0e8..815bba3 100644 --- a/pkg/policy/backend/memory/memory.go +++ b/pkg/policy/backend/memory/memory.go @@ -21,7 +21,10 @@ func NewJobScalingPolicies() backend.PolicyBackend { } func (p *PolicyBackend) GetPolicies() (map[string]map[string]*policy.GroupScalingPolicy, error) { - return p.policies, nil + p.RLock() + val := p.policies + p.RUnlock() + return val, nil } func (p *PolicyBackend) GetJobPolicy(job string) (map[string]*policy.GroupScalingPolicy, error) {