vc: Sandbox#Annotations should use annotationsLock read lock

Fixes #2222

Signed-off-by: Ted Yu <yuzhihong@gmail.com>
This commit is contained in:
Ted Yu 2019-11-19 13:44:32 -08:00
parent 66f0ec526e
commit 1afad1c0ad

View File

@ -225,6 +225,9 @@ func (s *Sandbox) Logger() *logrus.Entry {
// Annotations returns any annotation that a user could have stored through the sandbox.
func (s *Sandbox) Annotations(key string) (string, error) {
s.annotationsLock.RLock()
defer s.annotationsLock.RUnlock()
value, exist := s.config.Annotations[key]
if !exist {
return "", fmt.Errorf("Annotations key %s does not exist", key)