Skip to content
This repository was archived by the owner on Apr 17, 2019. It is now read-only.

Commit c706999

Browse files
committed
Avoid sync without a reachable master
1 parent 295d33a commit c706999

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

ingress/controllers/nginx/controller.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -421,13 +421,19 @@ func (lbc *loadBalancerController) sync(key string) {
421421
return
422422
}
423423

424-
var cfg *api.ConfigMap
425-
426-
ns, name, _ := parseNsName(lbc.nxgConfigMap)
427-
cfg, err := lbc.getConfigMap(ns, name)
428-
if err != nil {
429-
glog.V(3).Infof("unexpected error searching configmap %v: %v", lbc.nxgConfigMap, err)
430-
cfg = &api.ConfigMap{}
424+
// by default no custom configuration configmap
425+
cfg := &api.ConfigMap{}
426+
427+
if lbc.nxgConfigMap != "" {
428+
// Search for custom configmap (defined in main args)
429+
var err error
430+
ns, name, _ := parseNsName(lbc.nxgConfigMap)
431+
cfg, err = lbc.getConfigMap(ns, name)
432+
if err != nil {
433+
glog.V(3).Infof("unexpected error searching configmap %v: %v", lbc.nxgConfigMap, err)
434+
lbc.syncQueue.requeue(key, err)
435+
return
436+
}
431437
}
432438

433439
ngxConfig := lbc.nginx.ReadConfig(cfg)

ingress/controllers/nginx/main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ func main() {
130130
}
131131
glog.Infof("Validated %v as the default backend", *defaultSvc)
132132

133+
if *nxgConfigMap != "" {
134+
_, _, err := parseNsName(*nxgConfigMap)
135+
if err != nil {
136+
glog.Fatalf("configmap error: %v", err)
137+
}
138+
}
139+
133140
lbc, err := newLoadBalancerController(kubeClient, *resyncPeriod, *defaultSvc, *watchNamespace, *nxgConfigMap, *tcpConfigMapName, *udpConfigMapName, runtimePodInfo)
134141
if err != nil {
135142
glog.Fatalf("%v", err)

0 commit comments

Comments
 (0)