diff --git a/controllers/nginx/main.go b/controllers/nginx/main.go index 737d69359..a3d9a3f08 100644 --- a/controllers/nginx/main.go +++ b/controllers/nginx/main.go @@ -19,7 +19,6 @@ package main import ( "flag" "fmt" - "io/ioutil" "net/http" "net/http/pprof" "os" @@ -120,8 +119,6 @@ func main() { } } - checkTemplate() - lbc, err := newLoadBalancerController(kubeClient, *resyncPeriod, *defaultSvc, *watchNamespace, *nxgConfigMap, *tcpConfigMapName, *udpConfigMapName, *defSSLCertificate, runtimePodInfo) @@ -188,28 +185,3 @@ func handleSigterm(lbc *loadBalancerController) { glog.Infof("Exiting with %v", exitCode) os.Exit(exitCode) } - -const ( - defTmpl = "/etc/nginx/template/nginx.tmpl" - fallbackTmpl = "/etc/nginx/nginx.tmpl" -) - -// checkTemplate verifies the NGINX template exists (file /etc/nginx/template/nginx.tmpl) -// If the file does not exists it means: -// a. custom docker image -// b. standard image using watch-resource sidecar with emptyDir volume -// If the file /etc/nginx/nginx.tmpl exists copy the file to /etc/nginx/template/nginx.tmpl -// or terminate the execution (It is not possible to start NGINX without a template) -func checkTemplate() { - _, err := os.Stat(defTmpl) - if err != nil { - glog.Warningf("error checking template %v: %v", defTmpl, err) - data, err := ioutil.ReadFile(fallbackTmpl) - if err != nil { - glog.Fatalf("error reading template %v: %v", fallbackTmpl, err) - } - if err = ioutil.WriteFile(defTmpl, data, 0644); err != nil { - glog.Fatalf("error copying %v to %v: %v", fallbackTmpl, defTmpl, err) - } - } -} diff --git a/controllers/nginx/nginx/template/template.go b/controllers/nginx/nginx/template/template.go index dd1d09dd4..401460415 100644 --- a/controllers/nginx/nginx/template/template.go +++ b/controllers/nginx/nginx/template/template.go @@ -271,7 +271,7 @@ func buildRateLimit(input interface{}) []string { // maximum number of connections that can be queued for acceptance // http://nginx.org/en/docs/http/ngx_http_core_module.html#listen func sysctlSomaxconn() int { - maxConns, err := sysctl.GetSysctl("net/core/somaxconn") + maxConns, err := sysctl.New().GetSysctl("net/core/somaxconn") if err != nil || maxConns < 512 { glog.Warningf("system net.core.somaxconn=%v. Using NGINX default (511)", maxConns) return 511