Avoid data race syncing secrets

This commit is contained in:
Manuel de Brito Fontes 2018-01-15 17:54:17 -03:00
parent 3fe8524318
commit 45326e4c58
No known key found for this signature in database
GPG key ID: 786136016A8BA02A
2 changed files with 7 additions and 0 deletions

View file

@ -37,6 +37,9 @@ import (
// disk to allow copy of the content of the secret to disk to be used
// by external processes.
func (s k8sStore) syncSecret(key string) {
s.mu.Lock()
defer s.mu.Unlock()
glog.V(3).Infof("starting syncing of secret %v", key)
// TODO: getPemCertificate should not write to disk to avoid unnecessary overhead

View file

@ -21,6 +21,7 @@ import (
"fmt"
"io/ioutil"
"reflect"
"sync"
"time"
"github.com/golang/glog"
@ -182,6 +183,8 @@ type k8sStore struct {
filesystem file.Filesystem
updateCh chan Event
mu *sync.Mutex
}
// New creates a new object store to be used in the ingress controller
@ -200,6 +203,7 @@ func New(checkOCSP bool,
filesystem: fs,
updateCh: updateCh,
backendConfig: ngx_config.NewDefault(),
mu: &sync.Mutex{},
}
eventBroadcaster := record.NewBroadcaster()