Skip to content

Commit

Permalink
Fix chain completion and default certificate flag issues (#1978)
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf committed Jan 25, 2018
1 parent 5dc261d commit 444a56c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
4 changes: 3 additions & 1 deletion internal/ingress/controller/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,13 @@ func NewNGINXController(config *Configuration, fs file.Filesystem) *NGINXControl
Proxy: &TCPProxy{},
}

n.store = store.New(true,
n.store = store.New(
config.EnableSSLChainCompletion,
config.Namespace,
config.ConfigMapName,
config.TCPConfigMapName,
config.UDPConfigMapName,
config.DefaultSSLCertificate,
config.ResyncPeriod,
config.Client,
fs,
Expand Down
27 changes: 17 additions & 10 deletions internal/ingress/controller/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,26 +198,29 @@ type k8sStore struct {

// mu mutex used to avoid simultaneous incovations to syncSecret
mu *sync.Mutex

defaultSSLCertificate string
}

// New creates a new object store to be used in the ingress controller
func New(checkOCSP bool,
namespace, configmap, tcp, udp string,
namespace, configmap, tcp, udp, defaultSSLCertificate string,
resyncPeriod time.Duration,
client clientset.Interface,
fs file.Filesystem,
updateCh chan Event) Storer {

store := &k8sStore{
isOCSPCheckEnabled: checkOCSP,
cache: &Controller{},
listers: &Lister{},
sslStore: NewSSLCertTracker(),
filesystem: fs,
updateCh: updateCh,
backendConfig: ngx_config.NewDefault(),
mu: &sync.Mutex{},
secretIngressMap: make(map[string]sets.String),
isOCSPCheckEnabled: checkOCSP,
cache: &Controller{},
listers: &Lister{},
sslStore: NewSSLCertTracker(),
filesystem: fs,
updateCh: updateCh,
backendConfig: ngx_config.NewDefault(),
mu: &sync.Mutex{},
secretIngressMap: make(map[string]sets.String),
defaultSSLCertificate: defaultSSLCertificate,
}

eventBroadcaster := record.NewBroadcaster()
Expand Down Expand Up @@ -612,6 +615,10 @@ func (s k8sStore) Run(stopCh chan struct{}) {
s.ReadSecrets(ing)
}

if s.defaultSSLCertificate != "" {
s.syncSecret(s.defaultSSLCertificate)
}

// start goroutine to check for missing local secrets
go wait.Until(s.checkMissingSecrets, 10*time.Second, stopCh)

Expand Down
4 changes: 4 additions & 0 deletions internal/ingress/controller/store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func TestStore(t *testing.T) {
fmt.Sprintf("%v/config", ns.Name),
fmt.Sprintf("%v/tcp", ns.Name),
fmt.Sprintf("%v/udp", ns.Name),
"",
10*time.Minute,
clientSet,
fs,
Expand Down Expand Up @@ -155,6 +156,7 @@ func TestStore(t *testing.T) {
fmt.Sprintf("%v/config", ns.Name),
fmt.Sprintf("%v/tcp", ns.Name),
fmt.Sprintf("%v/udp", ns.Name),
"",
10*time.Minute,
clientSet,
fs,
Expand Down Expand Up @@ -294,6 +296,7 @@ func TestStore(t *testing.T) {
fmt.Sprintf("%v/config", ns.Name),
fmt.Sprintf("%v/tcp", ns.Name),
fmt.Sprintf("%v/udp", ns.Name),
"",
10*time.Minute,
clientSet,
fs,
Expand Down Expand Up @@ -378,6 +381,7 @@ func TestStore(t *testing.T) {
fmt.Sprintf("%v/config", ns.Name),
fmt.Sprintf("%v/tcp", ns.Name),
fmt.Sprintf("%v/udp", ns.Name),
"",
10*time.Minute,
clientSet,
fs,
Expand Down

0 comments on commit 444a56c

Please sign in to comment.