Replace glog with klog
This commit is contained in:
parent
f4a4daed84
commit
2fa55eabf6
33 changed files with 353 additions and 327 deletions
|
@ -70,7 +70,8 @@ func TestFlagConflict(t *testing.T) {
|
|||
defer func() { os.Args = oldArgs }()
|
||||
os.Args = []string{"cmd", "--publish-service", "namespace/test", "--http-port", "0", "--https-port", "0", "--publish-status-address", "1.1.1.1"}
|
||||
|
||||
_, _, err := parseFlags()
|
||||
_, c, err := parseFlags()
|
||||
t.Logf("%v", c)
|
||||
if err == nil {
|
||||
t.Fatalf("Expected an error parsing flags but none returned")
|
||||
}
|
||||
|
|
|
@ -21,10 +21,10 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
"k8s.io/klog"
|
||||
|
||||
"k8s.io/ingress-nginx/internal/ingress/annotations/class"
|
||||
"k8s.io/ingress-nginx/internal/ingress/annotations/parser"
|
||||
|
@ -168,7 +168,7 @@ Feature backed by OpenResty Lua libraries. Requires that OCSP stapling is not en
|
|||
flag.CommandLine.Parse([]string{})
|
||||
|
||||
pflag.VisitAll(func(flag *pflag.Flag) {
|
||||
glog.V(2).Infof("FLAG: --%s=%q", flag.Name, flag.Value)
|
||||
klog.V(2).Infof("FLAG: --%s=%q", flag.Name, flag.Value)
|
||||
})
|
||||
|
||||
if *showVersion {
|
||||
|
@ -176,10 +176,10 @@ Feature backed by OpenResty Lua libraries. Requires that OCSP stapling is not en
|
|||
}
|
||||
|
||||
if *ingressClass != "" {
|
||||
glog.Infof("Watching for Ingress class: %s", *ingressClass)
|
||||
klog.Infof("Watching for Ingress class: %s", *ingressClass)
|
||||
|
||||
if *ingressClass != class.DefaultClass {
|
||||
glog.Warningf("Only Ingresses with class %q will be processed by this Ingress controller", *ingressClass)
|
||||
klog.Warningf("Only Ingresses with class %q will be processed by this Ingress controller", *ingressClass)
|
||||
}
|
||||
|
||||
class.IngressClass = *ingressClass
|
||||
|
@ -209,7 +209,7 @@ Feature backed by OpenResty Lua libraries. Requires that OCSP stapling is not en
|
|||
}
|
||||
|
||||
if !*enableSSLChainCompletion {
|
||||
glog.Warningf("SSL certificate chain completion is disabled (--enable-ssl-chain-completion=false)")
|
||||
klog.Warningf("SSL certificate chain completion is disabled (--enable-ssl-chain-completion=false)")
|
||||
}
|
||||
|
||||
if *enableSSLChainCompletion && *dynamicCertificatesEnabled {
|
||||
|
|
|
@ -28,7 +28,6 @@ import (
|
|||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
|
||||
|
@ -38,6 +37,7 @@ import (
|
|||
"k8s.io/apiserver/pkg/server/healthz"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
"k8s.io/klog"
|
||||
|
||||
"k8s.io/ingress-nginx/internal/file"
|
||||
"k8s.io/ingress-nginx/internal/ingress/controller"
|
||||
|
@ -59,6 +59,8 @@ const (
|
|||
)
|
||||
|
||||
func main() {
|
||||
klog.InitFlags(nil)
|
||||
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
|
||||
fmt.Println(version.String())
|
||||
|
@ -69,14 +71,14 @@ func main() {
|
|||
}
|
||||
|
||||
if err != nil {
|
||||
glog.Fatal(err)
|
||||
klog.Fatal(err)
|
||||
}
|
||||
|
||||
nginxVersion()
|
||||
|
||||
fs, err := file.NewLocalFS()
|
||||
if err != nil {
|
||||
glog.Fatal(err)
|
||||
klog.Fatal(err)
|
||||
}
|
||||
|
||||
kubeClient, err := createApiserverClient(conf.APIServerHost, conf.KubeConfigFile)
|
||||
|
@ -87,24 +89,24 @@ func main() {
|
|||
if len(conf.DefaultService) > 0 {
|
||||
defSvcNs, defSvcName, err := k8s.ParseNameNS(conf.DefaultService)
|
||||
if err != nil {
|
||||
glog.Fatal(err)
|
||||
klog.Fatal(err)
|
||||
}
|
||||
|
||||
_, err = kubeClient.CoreV1().Services(defSvcNs).Get(defSvcName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
// TODO (antoineco): compare with error types from k8s.io/apimachinery/pkg/api/errors
|
||||
if strings.Contains(err.Error(), "cannot get services in the namespace") {
|
||||
glog.Fatal("✖ The cluster seems to be running with a restrictive Authorization mode and the Ingress controller does not have the required permissions to operate normally.")
|
||||
klog.Fatal("✖ The cluster seems to be running with a restrictive Authorization mode and the Ingress controller does not have the required permissions to operate normally.")
|
||||
}
|
||||
glog.Fatalf("No service with name %v found: %v", conf.DefaultService, err)
|
||||
klog.Fatalf("No service with name %v found: %v", conf.DefaultService, err)
|
||||
}
|
||||
glog.Infof("Validated %v as the default backend.", conf.DefaultService)
|
||||
klog.Infof("Validated %v as the default backend.", conf.DefaultService)
|
||||
}
|
||||
|
||||
if conf.Namespace != "" {
|
||||
_, err = kubeClient.CoreV1().Namespaces().Get(conf.Namespace, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
glog.Fatalf("No namespace with name %v found: %v", conf.Namespace, err)
|
||||
klog.Fatalf("No namespace with name %v found: %v", conf.Namespace, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,7 +114,7 @@ func main() {
|
|||
defCert, defKey := ssl.GetFakeSSLCert()
|
||||
c, err := ssl.AddOrUpdateCertAndKey(fakeCertificate, defCert, defKey, []byte{}, fs)
|
||||
if err != nil {
|
||||
glog.Fatalf("Error generating self-signed certificate: %v", err)
|
||||
klog.Fatalf("Error generating self-signed certificate: %v", err)
|
||||
}
|
||||
|
||||
conf.FakeCertificatePath = c.PemFileName
|
||||
|
@ -132,7 +134,7 @@ func main() {
|
|||
if conf.EnableMetrics {
|
||||
mc, err = metric.NewCollector(conf.ListenPorts.Status, reg)
|
||||
if err != nil {
|
||||
glog.Fatalf("Error creating prometheus collector: %v", err)
|
||||
klog.Fatalf("Error creating prometheus collector: %v", err)
|
||||
}
|
||||
}
|
||||
mc.Start()
|
||||
|
@ -163,18 +165,18 @@ func handleSigterm(ngx *controller.NGINXController, exit exiter) {
|
|||
signalChan := make(chan os.Signal, 1)
|
||||
signal.Notify(signalChan, syscall.SIGTERM)
|
||||
<-signalChan
|
||||
glog.Info("Received SIGTERM, shutting down")
|
||||
klog.Info("Received SIGTERM, shutting down")
|
||||
|
||||
exitCode := 0
|
||||
if err := ngx.Stop(); err != nil {
|
||||
glog.Infof("Error during shutdown: %v", err)
|
||||
klog.Infof("Error during shutdown: %v", err)
|
||||
exitCode = 1
|
||||
}
|
||||
|
||||
glog.Info("Handled quit, awaiting Pod deletion")
|
||||
klog.Info("Handled quit, awaiting Pod deletion")
|
||||
time.Sleep(10 * time.Second)
|
||||
|
||||
glog.Infof("Exiting with %v", exitCode)
|
||||
klog.Infof("Exiting with %v", exitCode)
|
||||
exit(exitCode)
|
||||
}
|
||||
|
||||
|
@ -196,7 +198,7 @@ func createApiserverClient(apiserverHost, kubeConfig string) (*kubernetes.Client
|
|||
cfg.Burst = defaultBurst
|
||||
cfg.ContentType = "application/vnd.kubernetes.protobuf"
|
||||
|
||||
glog.Infof("Creating API client for %s", cfg.Host)
|
||||
klog.Infof("Creating API client for %s", cfg.Host)
|
||||
|
||||
client, err := kubernetes.NewForConfig(cfg)
|
||||
if err != nil {
|
||||
|
@ -216,7 +218,7 @@ func createApiserverClient(apiserverHost, kubeConfig string) (*kubernetes.Client
|
|||
|
||||
var lastErr error
|
||||
retries := 0
|
||||
glog.V(2).Info("Trying to discover Kubernetes version")
|
||||
klog.V(2).Info("Trying to discover Kubernetes version")
|
||||
err = wait.ExponentialBackoff(defaultRetry, func() (bool, error) {
|
||||
v, err = client.Discovery().ServerVersion()
|
||||
|
||||
|
@ -225,7 +227,7 @@ func createApiserverClient(apiserverHost, kubeConfig string) (*kubernetes.Client
|
|||
}
|
||||
|
||||
lastErr = err
|
||||
glog.V(2).Infof("Unexpected error discovering Kubernetes version (attempt %v): %v", retries, err)
|
||||
klog.V(2).Infof("Unexpected error discovering Kubernetes version (attempt %v): %v", retries, err)
|
||||
retries++
|
||||
return false, nil
|
||||
})
|
||||
|
@ -237,10 +239,10 @@ func createApiserverClient(apiserverHost, kubeConfig string) (*kubernetes.Client
|
|||
|
||||
// this should not happen, warn the user
|
||||
if retries > 0 {
|
||||
glog.Warningf("Initial connection to the Kubernetes API server was retried %d times.", retries)
|
||||
klog.Warningf("Initial connection to the Kubernetes API server was retried %d times.", retries)
|
||||
}
|
||||
|
||||
glog.Infof("Running in Kubernetes cluster version v%v.%v (%v) - git (%v) commit %v - platform %v",
|
||||
klog.Infof("Running in Kubernetes cluster version v%v.%v (%v) - git (%v) commit %v - platform %v",
|
||||
v.Major, v.Minor, v.GitVersion, v.GitTreeState, v.GitCommit, v.Platform)
|
||||
|
||||
return client, nil
|
||||
|
@ -248,7 +250,7 @@ func createApiserverClient(apiserverHost, kubeConfig string) (*kubernetes.Client
|
|||
|
||||
// Handler for fatal init errors. Prints a verbose error message and exits.
|
||||
func handleFatalInitError(err error) {
|
||||
glog.Fatalf("Error while initiating a connection to the Kubernetes API server. "+
|
||||
klog.Fatalf("Error while initiating a connection to the Kubernetes API server. "+
|
||||
"This could mean the cluster is misconfigured (e.g. it has invalid API server certificates "+
|
||||
"or Service Accounts configuration). Reason: %s\n"+
|
||||
"Refer to the troubleshooting guide for more information: "+
|
||||
|
@ -266,7 +268,7 @@ func registerHandlers(mux *http.ServeMux) {
|
|||
mux.HandleFunc("/stop", func(w http.ResponseWriter, r *http.Request) {
|
||||
err := syscall.Kill(syscall.Getpid(), syscall.SIGTERM)
|
||||
if err != nil {
|
||||
glog.Errorf("Unexpected error: %v", err)
|
||||
klog.Errorf("Unexpected error: %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -312,5 +314,5 @@ func startHTTPServer(port int, mux *http.ServeMux) {
|
|||
WriteTimeout: 300 * time.Second,
|
||||
IdleTimeout: 120 * time.Second,
|
||||
}
|
||||
glog.Fatal(server.ListenAndServe())
|
||||
klog.Fatal(server.ListenAndServe())
|
||||
}
|
||||
|
|
|
@ -18,17 +18,18 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"k8s.io/api/core/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/kubernetes/fake"
|
||||
"k8s.io/ingress-nginx/internal/file"
|
||||
"k8s.io/ingress-nginx/internal/ingress/controller"
|
||||
"os"
|
||||
"syscall"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/kubernetes/fake"
|
||||
|
||||
"k8s.io/ingress-nginx/internal/file"
|
||||
"k8s.io/ingress-nginx/internal/ingress/controller"
|
||||
)
|
||||
|
||||
func TestCreateApiserverClient(t *testing.T) {
|
||||
|
|
|
@ -20,13 +20,13 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
func nginxVersion() {
|
||||
flag := "-v"
|
||||
|
||||
if glog.V(2) {
|
||||
if klog.V(2) {
|
||||
flag = "-V"
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ package file
|
|||
import (
|
||||
"crypto/sha1"
|
||||
"encoding/hex"
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
|
@ -28,7 +28,7 @@ func SHA1(filename string) string {
|
|||
hasher := sha1.New()
|
||||
s, err := ioutil.ReadFile(filename)
|
||||
if err != nil {
|
||||
glog.Errorf("Error reading file %v", err)
|
||||
klog.Errorf("Error reading file %v", err)
|
||||
return ""
|
||||
}
|
||||
|
||||
|
|
|
@ -17,11 +17,11 @@ limitations under the License.
|
|||
package annotations
|
||||
|
||||
import (
|
||||
"github.com/golang/glog"
|
||||
"github.com/imdario/mergo"
|
||||
"k8s.io/ingress-nginx/internal/ingress/annotations/canary"
|
||||
"k8s.io/ingress-nginx/internal/ingress/annotations/modsecurity"
|
||||
"k8s.io/ingress-nginx/internal/ingress/annotations/sslcipher"
|
||||
"k8s.io/klog"
|
||||
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
extensions "k8s.io/api/extensions/v1beta1"
|
||||
|
@ -156,7 +156,7 @@ func (e Extractor) Extract(ing *extensions.Ingress) *Ingress {
|
|||
data := make(map[string]interface{})
|
||||
for name, annotationParser := range e.annotations {
|
||||
val, err := annotationParser.Parse(ing)
|
||||
glog.V(5).Infof("annotation %v in Ingress %v/%v: %v", name, ing.GetNamespace(), ing.GetName(), val)
|
||||
klog.V(5).Infof("annotation %v in Ingress %v/%v: %v", name, ing.GetNamespace(), ing.GetName(), val)
|
||||
if err != nil {
|
||||
if errors.IsMissingAnnotations(err) {
|
||||
continue
|
||||
|
@ -177,11 +177,11 @@ func (e Extractor) Extract(ing *extensions.Ingress) *Ingress {
|
|||
_, alreadyDenied := data[DeniedKeyName]
|
||||
if !alreadyDenied {
|
||||
data[DeniedKeyName] = err
|
||||
glog.Errorf("error reading %v annotation in Ingress %v/%v: %v", name, ing.GetNamespace(), ing.GetName(), err)
|
||||
klog.Errorf("error reading %v annotation in Ingress %v/%v: %v", name, ing.GetNamespace(), ing.GetName(), err)
|
||||
continue
|
||||
}
|
||||
|
||||
glog.V(5).Infof("error reading %v annotation in Ingress %v/%v: %v", name, ing.GetNamespace(), ing.GetName(), err)
|
||||
klog.V(5).Infof("error reading %v annotation in Ingress %v/%v: %v", name, ing.GetNamespace(), ing.GetName(), err)
|
||||
}
|
||||
|
||||
if val != nil {
|
||||
|
@ -191,7 +191,7 @@ func (e Extractor) Extract(ing *extensions.Ingress) *Ingress {
|
|||
|
||||
err := mergo.MapWithOverwrite(pia, data)
|
||||
if err != nil {
|
||||
glog.Errorf("unexpected error merging extracted annotations: %v", err)
|
||||
klog.Errorf("unexpected error merging extracted annotations: %v", err)
|
||||
}
|
||||
|
||||
return pia
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
|
||||
extensions "k8s.io/api/extensions/v1beta1"
|
||||
|
||||
|
@ -146,12 +146,12 @@ func (a authReq) Parse(ing *extensions.Ingress) (interface{}, error) {
|
|||
// Optional Parameters
|
||||
signIn, err := parser.GetStringAnnotation("auth-signin", ing)
|
||||
if err != nil {
|
||||
glog.Warning("auth-signin annotation is undefined and will not be set")
|
||||
klog.Warning("auth-signin annotation is undefined and will not be set")
|
||||
}
|
||||
|
||||
authSnippet, err := parser.GetStringAnnotation("auth-snippet", ing)
|
||||
if err != nil {
|
||||
glog.Warning("auth-snippet annotation is undefined and will not be set")
|
||||
klog.Warning("auth-snippet annotation is undefined and will not be set")
|
||||
}
|
||||
|
||||
responseHeaders := []string{}
|
||||
|
|
|
@ -20,7 +20,7 @@ import (
|
|||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
extensions "k8s.io/api/extensions/v1beta1"
|
||||
|
||||
"k8s.io/ingress-nginx/internal/ingress/annotations/parser"
|
||||
|
@ -57,7 +57,7 @@ func (a backendProtocol) Parse(ing *extensions.Ingress) (interface{}, error) {
|
|||
|
||||
proto = strings.TrimSpace(strings.ToUpper(proto))
|
||||
if !validProtocols.MatchString(proto) {
|
||||
glog.Warningf("Protocol %v is not a valid value for the backend-protocol annotation. Using HTTP as protocol", proto)
|
||||
klog.Warningf("Protocol %v is not a valid value for the backend-protocol annotation. Using HTTP as protocol", proto)
|
||||
return HTTP, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||
package class
|
||||
|
||||
import (
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
extensions "k8s.io/api/extensions/v1beta1"
|
||||
)
|
||||
|
||||
|
@ -44,7 +44,7 @@ var (
|
|||
func IsValid(ing *extensions.Ingress) bool {
|
||||
ingress, ok := ing.GetAnnotations()[IngressKey]
|
||||
if !ok {
|
||||
glog.V(3).Infof("annotation %v is not present in ingress %v/%v", IngressKey, ing.Namespace, ing.Name)
|
||||
klog.V(3).Infof("annotation %v is not present in ingress %v/%v", IngressKey, ing.Namespace, ing.Name)
|
||||
}
|
||||
|
||||
// we have 2 valid combinations
|
||||
|
|
|
@ -19,7 +19,7 @@ package sessionaffinity
|
|||
import (
|
||||
"regexp"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
|
||||
extensions "k8s.io/api/extensions/v1beta1"
|
||||
|
||||
|
@ -140,7 +140,7 @@ func (a affinity) Parse(ing *extensions.Ingress) (interface{}, error) {
|
|||
case "cookie":
|
||||
cookie = a.cookieAffinityParse(ing)
|
||||
default:
|
||||
glog.V(3).Infof("No default affinity was found for Ingress %v", ing.Name)
|
||||
klog.V(3).Infof("No default affinity was found for Ingress %v", ing.Name)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ func (n *NGINXController) Check(_ *http.Request) error {
|
|||
}
|
||||
|
||||
// check the nginx master process is running
|
||||
fs, err := proc.NewFS("/proc")
|
||||
fs, err := proc.NewFS("/proc", false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "unexpected error reading /proc directory")
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
|
||||
|
@ -675,7 +675,7 @@ func NewDefault() Configuration {
|
|||
NoAuthLocations: "/.well-known/acme-challenge",
|
||||
}
|
||||
|
||||
if glog.V(5) {
|
||||
if klog.V(5) {
|
||||
cfg.ErrorLogLevel = "debug"
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
"github.com/mitchellh/hashstructure"
|
||||
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
|
@ -143,7 +143,7 @@ func (n *NGINXController) syncIngress(interface{}) error {
|
|||
|
||||
for _, loc := range server.Locations {
|
||||
if loc.Path != rootLocation {
|
||||
glog.Warningf("Ignoring SSL Passthrough for location %q in server %q", loc.Path, server.Hostname)
|
||||
klog.Warningf("Ignoring SSL Passthrough for location %q in server %q", loc.Path, server.Hostname)
|
||||
continue
|
||||
}
|
||||
passUpstreams = append(passUpstreams, &ingress.SSLPassthroughBackend{
|
||||
|
@ -166,12 +166,12 @@ func (n *NGINXController) syncIngress(interface{}) error {
|
|||
}
|
||||
|
||||
if n.runningConfig.Equal(pcfg) {
|
||||
glog.V(3).Infof("No configuration change detected, skipping backend reload.")
|
||||
klog.V(3).Infof("No configuration change detected, skipping backend reload.")
|
||||
return nil
|
||||
}
|
||||
|
||||
if !n.IsDynamicConfigurationEnough(pcfg) {
|
||||
glog.Infof("Configuration changes detected, backend reload required.")
|
||||
klog.Infof("Configuration changes detected, backend reload required.")
|
||||
|
||||
hash, _ := hashstructure.Hash(pcfg, &hashstructure.HashOptions{
|
||||
TagName: "json",
|
||||
|
@ -183,13 +183,13 @@ func (n *NGINXController) syncIngress(interface{}) error {
|
|||
if err != nil {
|
||||
n.metricCollector.IncReloadErrorCount()
|
||||
n.metricCollector.ConfigSuccess(hash, false)
|
||||
glog.Errorf("Unexpected failure reloading the backend:\n%v", err)
|
||||
klog.Errorf("Unexpected failure reloading the backend:\n%v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
n.metricCollector.SetHosts(hosts)
|
||||
|
||||
glog.Infof("Backend successfully reloaded.")
|
||||
klog.Infof("Backend successfully reloaded.")
|
||||
n.metricCollector.ConfigSuccess(hash, true)
|
||||
n.metricCollector.IncReloadCount()
|
||||
n.metricCollector.SetSSLExpireTime(servers)
|
||||
|
@ -201,7 +201,7 @@ func (n *NGINXController) syncIngress(interface{}) error {
|
|||
// start listening on the configured port (default 18080)
|
||||
// For large configurations it might take a while so we loop
|
||||
// and back off
|
||||
glog.Info("Initial sync, sleeping for 1 second.")
|
||||
klog.Info("Initial sync, sleeping for 1 second.")
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
|
||||
|
@ -215,15 +215,15 @@ func (n *NGINXController) syncIngress(interface{}) error {
|
|||
err := wait.ExponentialBackoff(retry, func() (bool, error) {
|
||||
err := configureDynamically(pcfg, n.cfg.ListenPorts.Status, n.cfg.DynamicCertificatesEnabled)
|
||||
if err == nil {
|
||||
glog.V(2).Infof("Dynamic reconfiguration succeeded.")
|
||||
klog.V(2).Infof("Dynamic reconfiguration succeeded.")
|
||||
return true, nil
|
||||
}
|
||||
|
||||
glog.Warningf("Dynamic reconfiguration failed: %v", err)
|
||||
klog.Warningf("Dynamic reconfiguration failed: %v", err)
|
||||
return false, err
|
||||
})
|
||||
if err != nil {
|
||||
glog.Errorf("Unexpected failure reconfiguring NGINX:\n%v", err)
|
||||
klog.Errorf("Unexpected failure reconfiguring NGINX:\n%v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -240,15 +240,15 @@ func (n *NGINXController) getStreamServices(configmapName string, proto apiv1.Pr
|
|||
if configmapName == "" {
|
||||
return []ingress.L4Service{}
|
||||
}
|
||||
glog.V(3).Infof("Obtaining information about %v stream services from ConfigMap %q", proto, configmapName)
|
||||
klog.V(3).Infof("Obtaining information about %v stream services from ConfigMap %q", proto, configmapName)
|
||||
_, _, err := k8s.ParseNameNS(configmapName)
|
||||
if err != nil {
|
||||
glog.Errorf("Error parsing ConfigMap reference %q: %v", configmapName, err)
|
||||
klog.Errorf("Error parsing ConfigMap reference %q: %v", configmapName, err)
|
||||
return []ingress.L4Service{}
|
||||
}
|
||||
configmap, err := n.store.GetConfigMap(configmapName)
|
||||
if err != nil {
|
||||
glog.Errorf("Error getting ConfigMap %q: %v", configmapName, err)
|
||||
klog.Errorf("Error getting ConfigMap %q: %v", configmapName, err)
|
||||
return []ingress.L4Service{}
|
||||
}
|
||||
var svcs []ingress.L4Service
|
||||
|
@ -266,16 +266,16 @@ func (n *NGINXController) getStreamServices(configmapName string, proto apiv1.Pr
|
|||
for port, svcRef := range configmap.Data {
|
||||
externalPort, err := strconv.Atoi(port)
|
||||
if err != nil {
|
||||
glog.Warningf("%q is not a valid %v port number", port, proto)
|
||||
klog.Warningf("%q is not a valid %v port number", port, proto)
|
||||
continue
|
||||
}
|
||||
if reserverdPorts.Has(externalPort) {
|
||||
glog.Warningf("Port %d cannot be used for %v stream services. It is reserved for the Ingress controller.", externalPort, proto)
|
||||
klog.Warningf("Port %d cannot be used for %v stream services. It is reserved for the Ingress controller.", externalPort, proto)
|
||||
continue
|
||||
}
|
||||
nsSvcPort := strings.Split(svcRef, ":")
|
||||
if len(nsSvcPort) < 2 {
|
||||
glog.Warningf("Invalid Service reference %q for %v port %d", svcRef, proto, externalPort)
|
||||
klog.Warningf("Invalid Service reference %q for %v port %d", svcRef, proto, externalPort)
|
||||
continue
|
||||
}
|
||||
nsName := nsSvcPort[0]
|
||||
|
@ -293,19 +293,19 @@ func (n *NGINXController) getStreamServices(configmapName string, proto apiv1.Pr
|
|||
}
|
||||
svcNs, svcName, err := k8s.ParseNameNS(nsName)
|
||||
if err != nil {
|
||||
glog.Warningf("%v", err)
|
||||
klog.Warningf("%v", err)
|
||||
continue
|
||||
}
|
||||
svc, err := n.store.GetService(nsName)
|
||||
if err != nil {
|
||||
glog.Warningf("Error getting Service %q: %v", nsName, err)
|
||||
klog.Warningf("Error getting Service %q: %v", nsName, err)
|
||||
continue
|
||||
}
|
||||
var endps []ingress.Endpoint
|
||||
targetPort, err := strconv.Atoi(svcPort)
|
||||
if err != nil {
|
||||
// not a port number, fall back to using port name
|
||||
glog.V(3).Infof("Searching Endpoints with %v port name %q for Service %q", proto, svcPort, nsName)
|
||||
klog.V(3).Infof("Searching Endpoints with %v port name %q for Service %q", proto, svcPort, nsName)
|
||||
for _, sp := range svc.Spec.Ports {
|
||||
if sp.Name == svcPort {
|
||||
if sp.Protocol == proto {
|
||||
|
@ -315,7 +315,7 @@ func (n *NGINXController) getStreamServices(configmapName string, proto apiv1.Pr
|
|||
}
|
||||
}
|
||||
} else {
|
||||
glog.V(3).Infof("Searching Endpoints with %v port number %d for Service %q", proto, targetPort, nsName)
|
||||
klog.V(3).Infof("Searching Endpoints with %v port number %d for Service %q", proto, targetPort, nsName)
|
||||
for _, sp := range svc.Spec.Ports {
|
||||
if sp.Port == int32(targetPort) {
|
||||
if sp.Protocol == proto {
|
||||
|
@ -328,7 +328,7 @@ func (n *NGINXController) getStreamServices(configmapName string, proto apiv1.Pr
|
|||
// stream services cannot contain empty upstreams and there is
|
||||
// no default backend equivalent
|
||||
if len(endps) == 0 {
|
||||
glog.Warningf("Service %q does not have any active Endpoint for %v port %v", nsName, proto, svcPort)
|
||||
klog.Warningf("Service %q does not have any active Endpoint for %v port %v", nsName, proto, svcPort)
|
||||
continue
|
||||
}
|
||||
svcs = append(svcs, ingress.L4Service{
|
||||
|
@ -365,14 +365,14 @@ func (n *NGINXController) getDefaultUpstream() *ingress.Backend {
|
|||
|
||||
svc, err := n.store.GetService(svcKey)
|
||||
if err != nil {
|
||||
glog.Warningf("Error getting default backend %q: %v", svcKey, err)
|
||||
klog.Warningf("Error getting default backend %q: %v", svcKey, err)
|
||||
upstream.Endpoints = append(upstream.Endpoints, n.DefaultEndpoint())
|
||||
return upstream
|
||||
}
|
||||
|
||||
endps := getEndpoints(svc, &svc.Spec.Ports[0], apiv1.ProtocolTCP, n.store.GetServiceEndpoints)
|
||||
if len(endps) == 0 {
|
||||
glog.Warningf("Service %q does not have any active Endpoint", svcKey)
|
||||
klog.Warningf("Service %q does not have any active Endpoint", svcKey)
|
||||
endps = []ingress.Endpoint{n.DefaultEndpoint()}
|
||||
}
|
||||
|
||||
|
@ -406,7 +406,7 @@ func (n *NGINXController) getBackendServers(ingresses []*ingress.Ingress) ([]*in
|
|||
|
||||
if rule.HTTP == nil &&
|
||||
host != defServerName {
|
||||
glog.V(3).Infof("Ingress %q does not contain any HTTP rule, using default backend", ingKey)
|
||||
klog.V(3).Infof("Ingress %q does not contain any HTTP rule, using default backend", ingKey)
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -417,16 +417,16 @@ func (n *NGINXController) getBackendServers(ingresses []*ingress.Ingress) ([]*in
|
|||
if server.CertificateAuth.CAFileName == "" {
|
||||
server.CertificateAuth = anns.CertificateAuth
|
||||
if server.CertificateAuth.Secret != "" && server.CertificateAuth.CAFileName == "" {
|
||||
glog.V(3).Infof("Secret %q has no 'ca.crt' key, mutual authentication disabled for Ingress %q",
|
||||
klog.V(3).Infof("Secret %q has no 'ca.crt' key, mutual authentication disabled for Ingress %q",
|
||||
server.CertificateAuth.Secret, ingKey)
|
||||
}
|
||||
} else {
|
||||
glog.V(3).Infof("Server %q is already configured for mutual authentication (Ingress %q)",
|
||||
klog.V(3).Infof("Server %q is already configured for mutual authentication (Ingress %q)",
|
||||
server.Hostname, ingKey)
|
||||
}
|
||||
|
||||
if rule.HTTP == nil {
|
||||
glog.V(3).Infof("Ingress %q does not contain any HTTP rule, using default backend", ingKey)
|
||||
klog.V(3).Infof("Ingress %q does not contain any HTTP rule, using default backend", ingKey)
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -451,12 +451,12 @@ func (n *NGINXController) getBackendServers(ingresses []*ingress.Ingress) ([]*in
|
|||
addLoc = false
|
||||
|
||||
if !loc.IsDefBackend {
|
||||
glog.V(3).Infof("Location %q already configured for server %q with upstream %q (Ingress %q)",
|
||||
klog.V(3).Infof("Location %q already configured for server %q with upstream %q (Ingress %q)",
|
||||
loc.Path, server.Hostname, loc.Backend, ingKey)
|
||||
break
|
||||
}
|
||||
|
||||
glog.V(3).Infof("Replacing location %q for server %q with upstream %q to use upstream %q (Ingress %q)",
|
||||
klog.V(3).Infof("Replacing location %q for server %q with upstream %q to use upstream %q (Ingress %q)",
|
||||
loc.Path, server.Hostname, loc.Backend, ups.Name, ingKey)
|
||||
|
||||
loc.Backend = ups.Name
|
||||
|
@ -496,7 +496,7 @@ func (n *NGINXController) getBackendServers(ingresses []*ingress.Ingress) ([]*in
|
|||
|
||||
// new location
|
||||
if addLoc {
|
||||
glog.V(3).Infof("Adding location %q for server %q with upstream %q (Ingress %q)",
|
||||
klog.V(3).Infof("Adding location %q for server %q with upstream %q (Ingress %q)",
|
||||
nginxPath, server.Hostname, ups.Name, ingKey)
|
||||
|
||||
loc := &ingress.Location{
|
||||
|
@ -543,7 +543,7 @@ func (n *NGINXController) getBackendServers(ingresses []*ingress.Ingress) ([]*in
|
|||
if anns.SessionAffinity.Type == "cookie" {
|
||||
cookiePath := anns.SessionAffinity.Cookie.Path
|
||||
if anns.Rewrite.UseRegex && cookiePath == "" {
|
||||
glog.Warningf("session-cookie-path should be set when use-regex is true")
|
||||
klog.Warningf("session-cookie-path should be set when use-regex is true")
|
||||
}
|
||||
|
||||
ups.SessionAffinity.CookieSessionAffinity.Name = anns.SessionAffinity.Cookie.Name
|
||||
|
@ -562,7 +562,7 @@ func (n *NGINXController) getBackendServers(ingresses []*ingress.Ingress) ([]*in
|
|||
}
|
||||
|
||||
if anns.Canary.Enabled {
|
||||
glog.Infof("Canary ingress %v detected. Finding eligible backends to merge into.", ing.Name)
|
||||
klog.Infof("Canary ingress %v detected. Finding eligible backends to merge into.", ing.Name)
|
||||
mergeAlternativeBackends(ing, upstreams, servers)
|
||||
}
|
||||
}
|
||||
|
@ -577,13 +577,13 @@ func (n *NGINXController) getBackendServers(ingresses []*ingress.Ingress) ([]*in
|
|||
for _, location := range server.Locations {
|
||||
if upstream.Name == location.Backend {
|
||||
if len(upstream.Endpoints) == 0 {
|
||||
glog.V(3).Infof("Upstream %q has no active Endpoint", upstream.Name)
|
||||
klog.V(3).Infof("Upstream %q has no active Endpoint", upstream.Name)
|
||||
// check if the location contains endpoints and a custom default backend
|
||||
if location.DefaultBackend != nil {
|
||||
sp := location.DefaultBackend.Spec.Ports[0]
|
||||
endps := getEndpoints(location.DefaultBackend, &sp, apiv1.ProtocolTCP, n.store.GetServiceEndpoints)
|
||||
if len(endps) > 0 {
|
||||
glog.V(3).Infof("Using custom default backend for location %q in server %q (Service \"%v/%v\")",
|
||||
klog.V(3).Infof("Using custom default backend for location %q in server %q (Service \"%v/%v\")",
|
||||
location.Path, server.Hostname, location.DefaultBackend.Namespace, location.DefaultBackend.Name)
|
||||
|
||||
nb := upstream.DeepCopy()
|
||||
|
@ -599,7 +599,7 @@ func (n *NGINXController) getBackendServers(ingresses []*ingress.Ingress) ([]*in
|
|||
if server.SSLPassthrough {
|
||||
if location.Path == rootLocation {
|
||||
if location.Backend == defUpstreamName {
|
||||
glog.Warningf("Server %q has no default backend, ignoring SSL Passthrough.", server.Hostname)
|
||||
klog.Warningf("Server %q has no default backend, ignoring SSL Passthrough.", server.Hostname)
|
||||
continue
|
||||
}
|
||||
isHTTPSfrom = append(isHTTPSfrom, server)
|
||||
|
@ -650,7 +650,7 @@ func (n *NGINXController) createUpstreams(data []*ingress.Ingress, du *ingress.B
|
|||
if ing.Spec.Backend != nil {
|
||||
defBackend = upstreamName(ing.Namespace, ing.Spec.Backend.ServiceName, ing.Spec.Backend.ServicePort)
|
||||
|
||||
glog.V(3).Infof("Creating upstream %q", defBackend)
|
||||
klog.V(3).Infof("Creating upstream %q", defBackend)
|
||||
upstreams[defBackend] = newUpstream(defBackend)
|
||||
if upstreams[defBackend].SecureCACert.Secret == "" {
|
||||
upstreams[defBackend].SecureCACert = anns.SecureUpstream.CACert
|
||||
|
@ -668,7 +668,7 @@ func (n *NGINXController) createUpstreams(data []*ingress.Ingress, du *ingress.B
|
|||
if anns.ServiceUpstream {
|
||||
endpoint, err := n.getServiceClusterEndpoint(svcKey, ing.Spec.Backend)
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to determine a suitable ClusterIP Endpoint for Service %q: %v", svcKey, err)
|
||||
klog.Errorf("Failed to determine a suitable ClusterIP Endpoint for Service %q: %v", svcKey, err)
|
||||
} else {
|
||||
upstreams[defBackend].Endpoints = []ingress.Endpoint{endpoint}
|
||||
}
|
||||
|
@ -688,13 +688,13 @@ func (n *NGINXController) createUpstreams(data []*ingress.Ingress, du *ingress.B
|
|||
endps, err := n.serviceEndpoints(svcKey, ing.Spec.Backend.ServicePort.String())
|
||||
upstreams[defBackend].Endpoints = append(upstreams[defBackend].Endpoints, endps...)
|
||||
if err != nil {
|
||||
glog.Warningf("Error creating upstream %q: %v", defBackend, err)
|
||||
klog.Warningf("Error creating upstream %q: %v", defBackend, err)
|
||||
}
|
||||
}
|
||||
|
||||
s, err := n.store.GetService(svcKey)
|
||||
if err != nil {
|
||||
glog.Warningf("Error obtaining Service %q: %v", svcKey, err)
|
||||
klog.Warningf("Error obtaining Service %q: %v", svcKey, err)
|
||||
}
|
||||
upstreams[defBackend].Service = s
|
||||
}
|
||||
|
@ -711,7 +711,7 @@ func (n *NGINXController) createUpstreams(data []*ingress.Ingress, du *ingress.B
|
|||
continue
|
||||
}
|
||||
|
||||
glog.V(3).Infof("Creating upstream %q", name)
|
||||
klog.V(3).Infof("Creating upstream %q", name)
|
||||
upstreams[name] = newUpstream(name)
|
||||
upstreams[name].Port = path.Backend.ServicePort
|
||||
|
||||
|
@ -733,7 +733,7 @@ func (n *NGINXController) createUpstreams(data []*ingress.Ingress, du *ingress.B
|
|||
if anns.ServiceUpstream {
|
||||
endpoint, err := n.getServiceClusterEndpoint(svcKey, &path.Backend)
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to determine a suitable ClusterIP Endpoint for Service %q: %v", svcKey, err)
|
||||
klog.Errorf("Failed to determine a suitable ClusterIP Endpoint for Service %q: %v", svcKey, err)
|
||||
} else {
|
||||
upstreams[name].Endpoints = []ingress.Endpoint{endpoint}
|
||||
}
|
||||
|
@ -752,7 +752,7 @@ func (n *NGINXController) createUpstreams(data []*ingress.Ingress, du *ingress.B
|
|||
if len(upstreams[name].Endpoints) == 0 {
|
||||
endp, err := n.serviceEndpoints(svcKey, path.Backend.ServicePort.String())
|
||||
if err != nil {
|
||||
glog.Warningf("Error obtaining Endpoints for Service %q: %v", svcKey, err)
|
||||
klog.Warningf("Error obtaining Endpoints for Service %q: %v", svcKey, err)
|
||||
continue
|
||||
}
|
||||
upstreams[name].Endpoints = endp
|
||||
|
@ -760,7 +760,7 @@ func (n *NGINXController) createUpstreams(data []*ingress.Ingress, du *ingress.B
|
|||
|
||||
s, err := n.store.GetService(svcKey)
|
||||
if err != nil {
|
||||
glog.Warningf("Error obtaining Service %q: %v", svcKey, err)
|
||||
klog.Warningf("Error obtaining Service %q: %v", svcKey, err)
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -816,7 +816,7 @@ func (n *NGINXController) serviceEndpoints(svcKey, backendPort string) ([]ingres
|
|||
return upstreams, err
|
||||
}
|
||||
|
||||
glog.V(3).Infof("Obtaining ports information for Service %q", svcKey)
|
||||
klog.V(3).Infof("Obtaining ports information for Service %q", svcKey)
|
||||
for _, servicePort := range svc.Spec.Ports {
|
||||
// targetPort could be a string, use either the port name or number (int)
|
||||
if strconv.Itoa(int(servicePort.Port)) == backendPort ||
|
||||
|
@ -825,7 +825,7 @@ func (n *NGINXController) serviceEndpoints(svcKey, backendPort string) ([]ingres
|
|||
|
||||
endps := getEndpoints(svc, &servicePort, apiv1.ProtocolTCP, n.store.GetServiceEndpoints)
|
||||
if len(endps) == 0 {
|
||||
glog.Warningf("Service %q does not have any active Endpoint.", svcKey)
|
||||
klog.Warningf("Service %q does not have any active Endpoint.", svcKey)
|
||||
}
|
||||
|
||||
if n.cfg.SortBackends {
|
||||
|
@ -848,7 +848,7 @@ func (n *NGINXController) serviceEndpoints(svcKey, backendPort string) ([]ingres
|
|||
if len(svc.Spec.Ports) == 0 && svc.Spec.Type == apiv1.ServiceTypeExternalName {
|
||||
externalPort, err := strconv.Atoi(backendPort)
|
||||
if err != nil {
|
||||
glog.Warningf("Only numeric ports are allowed in ExternalName Services: %q is not a valid port number.", backendPort)
|
||||
klog.Warningf("Only numeric ports are allowed in ExternalName Services: %q is not a valid port number.", backendPort)
|
||||
return upstreams, nil
|
||||
}
|
||||
|
||||
|
@ -859,7 +859,7 @@ func (n *NGINXController) serviceEndpoints(svcKey, backendPort string) ([]ingres
|
|||
}
|
||||
endps := getEndpoints(svc, &servicePort, apiv1.ProtocolTCP, n.store.GetServiceEndpoints)
|
||||
if len(endps) == 0 {
|
||||
glog.Warningf("Service %q does not have any active Endpoint.", svcKey)
|
||||
klog.Warningf("Service %q does not have any active Endpoint.", svcKey)
|
||||
return upstreams, nil
|
||||
}
|
||||
|
||||
|
@ -950,7 +950,7 @@ func (n *NGINXController) createServers(data []*ingress.Ingress,
|
|||
// special "catch all" case, Ingress with a backend but no rule
|
||||
defLoc := servers[defServerName].Locations[0]
|
||||
if defLoc.IsDefBackend && len(ing.Spec.Rules) == 0 {
|
||||
glog.Infof("Ingress %q defines a backend but no rule. Using it to configure the catch-all server %q",
|
||||
klog.Infof("Ingress %q defines a backend but no rule. Using it to configure the catch-all server %q",
|
||||
ingKey, defServerName)
|
||||
|
||||
defLoc.IsDefBackend = false
|
||||
|
@ -978,7 +978,7 @@ func (n *NGINXController) createServers(data []*ingress.Ingress,
|
|||
defLoc.BackendProtocol = anns.BackendProtocol
|
||||
defLoc.ModSecurity = anns.ModSecurity
|
||||
} else {
|
||||
glog.V(3).Infof("Ingress %q defines both a backend and rules. Using its backend as default upstream for all its rules.",
|
||||
klog.V(3).Infof("Ingress %q defines both a backend and rules. Using its backend as default upstream for all its rules.",
|
||||
ingKey)
|
||||
}
|
||||
}
|
||||
|
@ -1029,7 +1029,7 @@ func (n *NGINXController) createServers(data []*ingress.Ingress,
|
|||
aliases["Alias"] = host
|
||||
}
|
||||
} else {
|
||||
glog.Warningf("Aliases already configured for server %q, skipping (Ingress %q)",
|
||||
klog.Warningf("Aliases already configured for server %q, skipping (Ingress %q)",
|
||||
host, ingKey)
|
||||
}
|
||||
}
|
||||
|
@ -1038,7 +1038,7 @@ func (n *NGINXController) createServers(data []*ingress.Ingress,
|
|||
if servers[host].ServerSnippet == "" {
|
||||
servers[host].ServerSnippet = anns.ServerSnippet
|
||||
} else {
|
||||
glog.Warningf("Server snippet already configured for server %q, skipping (Ingress %q)",
|
||||
klog.Warningf("Server snippet already configured for server %q, skipping (Ingress %q)",
|
||||
host, ingKey)
|
||||
}
|
||||
}
|
||||
|
@ -1054,14 +1054,14 @@ func (n *NGINXController) createServers(data []*ingress.Ingress,
|
|||
}
|
||||
|
||||
if len(ing.Spec.TLS) == 0 {
|
||||
glog.V(3).Infof("Ingress %q does not contains a TLS section.", ingKey)
|
||||
klog.V(3).Infof("Ingress %q does not contains a TLS section.", ingKey)
|
||||
continue
|
||||
}
|
||||
|
||||
tlsSecretName := extractTLSSecretName(host, ing, n.store.GetLocalSSLCert)
|
||||
|
||||
if tlsSecretName == "" {
|
||||
glog.V(3).Infof("Host %q is listed in the TLS section but secretName is empty. Using default certificate.", host)
|
||||
klog.V(3).Infof("Host %q is listed in the TLS section but secretName is empty. Using default certificate.", host)
|
||||
servers[host].SSLCert.PemFileName = defaultPemFileName
|
||||
servers[host].SSLCert.PemSHA = defaultPemSHA
|
||||
continue
|
||||
|
@ -1070,7 +1070,7 @@ func (n *NGINXController) createServers(data []*ingress.Ingress,
|
|||
secrKey := fmt.Sprintf("%v/%v", ing.Namespace, tlsSecretName)
|
||||
cert, err := n.store.GetLocalSSLCert(secrKey)
|
||||
if err != nil {
|
||||
glog.Warningf("Error getting SSL certificate %q: %v. Using default certificate", secrKey, err)
|
||||
klog.Warningf("Error getting SSL certificate %q: %v. Using default certificate", secrKey, err)
|
||||
servers[host].SSLCert.PemFileName = defaultPemFileName
|
||||
servers[host].SSLCert.PemSHA = defaultPemSHA
|
||||
continue
|
||||
|
@ -1078,15 +1078,15 @@ func (n *NGINXController) createServers(data []*ingress.Ingress,
|
|||
|
||||
err = cert.Certificate.VerifyHostname(host)
|
||||
if err != nil {
|
||||
glog.Warningf("Unexpected error validating SSL certificate %q for server %q: %v", secrKey, host, err)
|
||||
glog.Warning("Validating certificate against DNS names. This will be deprecated in a future version.")
|
||||
klog.Warningf("Unexpected error validating SSL certificate %q for server %q: %v", secrKey, host, err)
|
||||
klog.Warning("Validating certificate against DNS names. This will be deprecated in a future version.")
|
||||
// check the Common Name field
|
||||
// https://github.com/golang/go/issues/22922
|
||||
err := verifyHostname(host, cert.Certificate)
|
||||
if err != nil {
|
||||
glog.Warningf("SSL certificate %q does not contain a Common Name or Subject Alternative Name for server %q: %v",
|
||||
klog.Warningf("SSL certificate %q does not contain a Common Name or Subject Alternative Name for server %q: %v",
|
||||
secrKey, host, err)
|
||||
glog.Warningf("Using default certificate")
|
||||
klog.Warningf("Using default certificate")
|
||||
servers[host].SSLCert.PemFileName = defaultPemFileName
|
||||
servers[host].SSLCert.PemSHA = defaultPemSHA
|
||||
continue
|
||||
|
@ -1102,14 +1102,14 @@ func (n *NGINXController) createServers(data []*ingress.Ingress,
|
|||
servers[host].SSLCert = *cert
|
||||
|
||||
if cert.ExpireTime.Before(time.Now().Add(240 * time.Hour)) {
|
||||
glog.Warningf("SSL certificate for server %q is about to expire (%v)", host, cert.ExpireTime)
|
||||
klog.Warningf("SSL certificate for server %q is about to expire (%v)", host, cert.ExpireTime)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for alias, host := range aliases {
|
||||
if _, ok := servers[alias]; ok {
|
||||
glog.Warningf("Conflicting hostname (%v) and alias (%v). Removing alias to avoid conflicts.", host, alias)
|
||||
klog.Warningf("Conflicting hostname (%v) and alias (%v). Removing alias to avoid conflicts.", host, alias)
|
||||
servers[host].Alias = ""
|
||||
}
|
||||
}
|
||||
|
@ -1124,7 +1124,7 @@ func canMergeBackend(primary *ingress.Backend, alternative *ingress.Backend) boo
|
|||
// Performs the merge action and checks to ensure that one two alternative backends do not merge into each other
|
||||
func mergeAlternativeBackend(priUps *ingress.Backend, altUps *ingress.Backend) bool {
|
||||
if priUps.NoServer {
|
||||
glog.Warningf("unable to merge alternative backend %v into primary backend %v because %v is a primary backend",
|
||||
klog.Warningf("unable to merge alternative backend %v into primary backend %v because %v is a primary backend",
|
||||
altUps.Name, priUps.Name, priUps.Name)
|
||||
return false
|
||||
}
|
||||
|
@ -1154,7 +1154,7 @@ func mergeAlternativeBackends(ing *ingress.Ingress, upstreams map[string]*ingres
|
|||
priUps := upstreams[loc.Backend]
|
||||
|
||||
if canMergeBackend(priUps, altUps) {
|
||||
glog.Infof("matching backend %v found for alternative backend %v",
|
||||
klog.Infof("matching backend %v found for alternative backend %v",
|
||||
priUps.Name, altUps.Name)
|
||||
|
||||
merged = mergeAlternativeBackend(priUps, altUps)
|
||||
|
@ -1162,7 +1162,7 @@ func mergeAlternativeBackends(ing *ingress.Ingress, upstreams map[string]*ingres
|
|||
}
|
||||
|
||||
if !merged {
|
||||
glog.Warningf("unable to find real backend for alternative backend %v. Deleting.", altUps.Name)
|
||||
klog.Warningf("unable to find real backend for alternative backend %v. Deleting.", altUps.Name)
|
||||
delete(upstreams, altUps.Name)
|
||||
}
|
||||
}
|
||||
|
@ -1177,7 +1177,7 @@ func mergeAlternativeBackends(ing *ingress.Ingress, upstreams map[string]*ingres
|
|||
|
||||
server, ok := servers[rule.Host]
|
||||
if !ok {
|
||||
glog.Errorf("cannot merge alternative backend %s into hostname %s that does not exist",
|
||||
klog.Errorf("cannot merge alternative backend %s into hostname %s that does not exist",
|
||||
altUps.Name,
|
||||
rule.Host)
|
||||
|
||||
|
@ -1189,7 +1189,7 @@ func mergeAlternativeBackends(ing *ingress.Ingress, upstreams map[string]*ingres
|
|||
priUps := upstreams[loc.Backend]
|
||||
|
||||
if canMergeBackend(priUps, altUps) && loc.Path == path.Path {
|
||||
glog.Infof("matching backend %v found for alternative backend %v",
|
||||
klog.Infof("matching backend %v found for alternative backend %v",
|
||||
priUps.Name, altUps.Name)
|
||||
|
||||
merged = mergeAlternativeBackend(priUps, altUps)
|
||||
|
@ -1197,7 +1197,7 @@ func mergeAlternativeBackends(ing *ingress.Ingress, upstreams map[string]*ingres
|
|||
}
|
||||
|
||||
if !merged {
|
||||
glog.Warningf("unable to find real backend for alternative backend %v. Deleting.", altUps.Name)
|
||||
klog.Warningf("unable to find real backend for alternative backend %v. Deleting.", altUps.Name)
|
||||
delete(upstreams, altUps.Name)
|
||||
}
|
||||
}
|
||||
|
@ -1232,7 +1232,7 @@ func extractTLSSecretName(host string, ing *ingress.Ingress,
|
|||
|
||||
cert, err := getLocalSSLCert(secrKey)
|
||||
if err != nil {
|
||||
glog.Warningf("Error getting SSL certificate %q: %v", secrKey, err)
|
||||
klog.Warningf("Error getting SSL certificate %q: %v", secrKey, err)
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -1244,7 +1244,7 @@ func extractTLSSecretName(host string, ing *ingress.Ingress,
|
|||
if err != nil {
|
||||
continue
|
||||
}
|
||||
glog.V(3).Infof("Found SSL certificate matching host %q: %q", host, secrKey)
|
||||
klog.V(3).Infof("Found SSL certificate matching host %q: %q", host, secrKey)
|
||||
return tls.SecretName
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import (
|
|||
"reflect"
|
||||
"strconv"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
|
||||
|
@ -48,18 +48,18 @@ func getEndpoints(s *corev1.Service, port *corev1.ServicePort, proto corev1.Prot
|
|||
|
||||
// ExternalName services
|
||||
if s.Spec.Type == corev1.ServiceTypeExternalName {
|
||||
glog.V(3).Infof("Ingress using Service %q of type ExternalName.", svcKey)
|
||||
klog.V(3).Infof("Ingress using Service %q of type ExternalName.", svcKey)
|
||||
|
||||
targetPort := port.TargetPort.IntValue()
|
||||
if targetPort <= 0 {
|
||||
glog.Errorf("ExternalName Service %q has an invalid port (%v)", svcKey, targetPort)
|
||||
klog.Errorf("ExternalName Service %q has an invalid port (%v)", svcKey, targetPort)
|
||||
return upsServers
|
||||
}
|
||||
|
||||
if net.ParseIP(s.Spec.ExternalName) == nil {
|
||||
_, err := net.LookupHost(s.Spec.ExternalName)
|
||||
if err != nil {
|
||||
glog.Errorf("Error resolving host %q: %v", s.Spec.ExternalName, err)
|
||||
klog.Errorf("Error resolving host %q: %v", s.Spec.ExternalName, err)
|
||||
return upsServers
|
||||
}
|
||||
}
|
||||
|
@ -70,10 +70,10 @@ func getEndpoints(s *corev1.Service, port *corev1.ServicePort, proto corev1.Prot
|
|||
})
|
||||
}
|
||||
|
||||
glog.V(3).Infof("Getting Endpoints for Service %q and port %v", svcKey, port.String())
|
||||
klog.V(3).Infof("Getting Endpoints for Service %q and port %v", svcKey, port.String())
|
||||
ep, err := getServiceEndpoints(svcKey)
|
||||
if err != nil {
|
||||
glog.Warningf("Error obtaining Endpoints for Service %q: %v", svcKey, err)
|
||||
klog.Warningf("Error obtaining Endpoints for Service %q: %v", svcKey, err)
|
||||
return upsServers
|
||||
}
|
||||
|
||||
|
@ -113,6 +113,6 @@ func getEndpoints(s *corev1.Service, port *corev1.ServicePort, proto corev1.Prot
|
|||
}
|
||||
}
|
||||
|
||||
glog.V(3).Infof("Endpoints found for Service %q: %v", svcKey, upsServers)
|
||||
klog.V(3).Infof("Endpoints found for Service %q: %v", svcKey, upsServers)
|
||||
return upsServers
|
||||
}
|
||||
|
|
|
@ -34,8 +34,6 @@ import (
|
|||
"text/template"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
|
||||
proxyproto "github.com/armon/go-proxyproto"
|
||||
"github.com/eapache/channels"
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
|
@ -44,6 +42,7 @@ import (
|
|||
v1core "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
"k8s.io/client-go/tools/record"
|
||||
"k8s.io/client-go/util/flowcontrol"
|
||||
"k8s.io/klog"
|
||||
"k8s.io/kubernetes/pkg/util/filesystem"
|
||||
|
||||
"k8s.io/ingress-nginx/internal/file"
|
||||
|
@ -76,14 +75,14 @@ var (
|
|||
// NewNGINXController creates a new NGINX Ingress controller.
|
||||
func NewNGINXController(config *Configuration, mc metric.Collector, fs file.Filesystem) *NGINXController {
|
||||
eventBroadcaster := record.NewBroadcaster()
|
||||
eventBroadcaster.StartLogging(glog.Infof)
|
||||
eventBroadcaster.StartLogging(klog.Infof)
|
||||
eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{
|
||||
Interface: config.Client.CoreV1().Events(config.Namespace),
|
||||
})
|
||||
|
||||
h, err := dns.GetSystemNameServers()
|
||||
if err != nil {
|
||||
glog.Warningf("Error reading system nameservers: %v", err)
|
||||
klog.Warningf("Error reading system nameservers: %v", err)
|
||||
}
|
||||
|
||||
n := &NGINXController{
|
||||
|
@ -113,7 +112,7 @@ func NewNGINXController(config *Configuration, mc metric.Collector, fs file.File
|
|||
|
||||
pod, err := k8s.GetPodDetails(config.Client)
|
||||
if err != nil {
|
||||
glog.Fatalf("unexpected error obtaining pod information: %v", err)
|
||||
klog.Fatalf("unexpected error obtaining pod information: %v", err)
|
||||
}
|
||||
|
||||
n.store = store.New(
|
||||
|
@ -147,14 +146,14 @@ func NewNGINXController(config *Configuration, mc metric.Collector, fs file.File
|
|||
UseNodeInternalIP: config.UseNodeInternalIP,
|
||||
})
|
||||
} else {
|
||||
glog.Warning("Update of Ingress status is disabled (flag --update-status)")
|
||||
klog.Warning("Update of Ingress status is disabled (flag --update-status)")
|
||||
}
|
||||
|
||||
onTemplateChange := func() {
|
||||
template, err := ngx_template.NewTemplate(tmplPath, fs)
|
||||
if err != nil {
|
||||
// this error is different from the rest because it must be clear why nginx is not working
|
||||
glog.Errorf(`
|
||||
klog.Errorf(`
|
||||
-------------------------------------------------------------------------------
|
||||
Error loading new template: %v
|
||||
-------------------------------------------------------------------------------
|
||||
|
@ -163,13 +162,13 @@ Error loading new template: %v
|
|||
}
|
||||
|
||||
n.t = template
|
||||
glog.Info("New NGINX configuration template loaded.")
|
||||
klog.Info("New NGINX configuration template loaded.")
|
||||
n.syncQueue.EnqueueTask(task.GetDummyObject("template-change"))
|
||||
}
|
||||
|
||||
ngxTpl, err := ngx_template.NewTemplate(tmplPath, fs)
|
||||
if err != nil {
|
||||
glog.Fatalf("Invalid NGINX configuration template: %v", err)
|
||||
klog.Fatalf("Invalid NGINX configuration template: %v", err)
|
||||
}
|
||||
|
||||
n.t = ngxTpl
|
||||
|
@ -181,7 +180,7 @@ Error loading new template: %v
|
|||
|
||||
_, err = watch.NewFileWatcher(tmplPath, onTemplateChange)
|
||||
if err != nil {
|
||||
glog.Fatalf("Error creating file watcher for %v: %v", tmplPath, err)
|
||||
klog.Fatalf("Error creating file watcher for %v: %v", tmplPath, err)
|
||||
}
|
||||
|
||||
filesToWatch := []string{}
|
||||
|
@ -199,16 +198,16 @@ Error loading new template: %v
|
|||
})
|
||||
|
||||
if err != nil {
|
||||
glog.Fatalf("Error creating file watchers: %v", err)
|
||||
klog.Fatalf("Error creating file watchers: %v", err)
|
||||
}
|
||||
|
||||
for _, f := range filesToWatch {
|
||||
_, err = watch.NewFileWatcher(f, func() {
|
||||
glog.Infof("File %v changed. Reloading NGINX", f)
|
||||
klog.Infof("File %v changed. Reloading NGINX", f)
|
||||
n.syncQueue.EnqueueTask(task.GetDummyObject("file-change"))
|
||||
})
|
||||
if err != nil {
|
||||
glog.Fatalf("Error creating file watcher for %v: %v", f, err)
|
||||
klog.Fatalf("Error creating file watcher for %v: %v", f, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -262,7 +261,7 @@ type NGINXController struct {
|
|||
|
||||
// Start starts a new NGINX master process running in the foreground.
|
||||
func (n *NGINXController) Start() {
|
||||
glog.Info("Starting NGINX Ingress controller")
|
||||
klog.Info("Starting NGINX Ingress controller")
|
||||
|
||||
n.store.Run(n.stopCh)
|
||||
|
||||
|
@ -283,7 +282,7 @@ func (n *NGINXController) Start() {
|
|||
n.setupSSLProxy()
|
||||
}
|
||||
|
||||
glog.Info("Starting NGINX process")
|
||||
klog.Info("Starting NGINX process")
|
||||
n.start(cmd)
|
||||
|
||||
go n.syncQueue.Run(time.Second, n.stopCh)
|
||||
|
@ -319,7 +318,7 @@ func (n *NGINXController) Start() {
|
|||
break
|
||||
}
|
||||
if evt, ok := event.(store.Event); ok {
|
||||
glog.V(3).Infof("Event %v received - object %v", evt.Type, evt.Obj)
|
||||
klog.V(3).Infof("Event %v received - object %v", evt.Type, evt.Obj)
|
||||
if evt.Type == store.ConfigurationEvent {
|
||||
// TODO: is this necessary? Consider removing this special case
|
||||
n.syncQueue.EnqueueTask(task.GetDummyObject("configmap-change"))
|
||||
|
@ -328,7 +327,7 @@ func (n *NGINXController) Start() {
|
|||
|
||||
n.syncQueue.EnqueueSkippableTask(evt.Obj)
|
||||
} else {
|
||||
glog.Warningf("Unexpected event type received %T", event)
|
||||
klog.Warningf("Unexpected event type received %T", event)
|
||||
}
|
||||
case <-n.stopCh:
|
||||
break
|
||||
|
@ -347,7 +346,7 @@ func (n *NGINXController) Stop() error {
|
|||
return fmt.Errorf("shutdown already in progress")
|
||||
}
|
||||
|
||||
glog.Info("Shutting down controller queues")
|
||||
klog.Info("Shutting down controller queues")
|
||||
close(n.stopCh)
|
||||
go n.syncQueue.Shutdown()
|
||||
if n.syncStatus != nil {
|
||||
|
@ -355,7 +354,7 @@ func (n *NGINXController) Stop() error {
|
|||
}
|
||||
|
||||
// send stop signal to NGINX
|
||||
glog.Info("Stopping NGINX process")
|
||||
klog.Info("Stopping NGINX process")
|
||||
cmd := nginxExecCommand("-s", "quit")
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
|
@ -368,7 +367,7 @@ func (n *NGINXController) Stop() error {
|
|||
timer := time.NewTicker(time.Second * 1)
|
||||
for range timer.C {
|
||||
if !process.IsNginxRunning() {
|
||||
glog.Info("NGINX process has stopped")
|
||||
klog.Info("NGINX process has stopped")
|
||||
timer.Stop()
|
||||
break
|
||||
}
|
||||
|
@ -381,7 +380,7 @@ func (n *NGINXController) start(cmd *exec.Cmd) {
|
|||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
if err := cmd.Start(); err != nil {
|
||||
glog.Fatalf("NGINX error: %v", err)
|
||||
klog.Fatalf("NGINX error: %v", err)
|
||||
n.ngxErrCh <- err
|
||||
return
|
||||
}
|
||||
|
@ -444,7 +443,7 @@ func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) error {
|
|||
for _, pb := range ingressCfg.PassthroughBackends {
|
||||
svc := pb.Service
|
||||
if svc == nil {
|
||||
glog.Warningf("Missing Service for SSL Passthrough backend %q", pb.Backend)
|
||||
klog.Warningf("Missing Service for SSL Passthrough backend %q", pb.Backend)
|
||||
continue
|
||||
}
|
||||
port, err := strconv.Atoi(pb.Port.String())
|
||||
|
@ -497,7 +496,7 @@ func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) error {
|
|||
} else {
|
||||
n = fmt.Sprintf("www.%v", srv.Hostname)
|
||||
}
|
||||
glog.V(3).Infof("Creating redirect from %q to %q", srv.Hostname, n)
|
||||
klog.V(3).Infof("Creating redirect from %q to %q", srv.Hostname, n)
|
||||
if _, ok := redirectServers[n]; !ok {
|
||||
found := false
|
||||
for _, esrv := range ingressCfg.Servers {
|
||||
|
@ -514,24 +513,24 @@ func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) error {
|
|||
}
|
||||
if cfg.ServerNameHashBucketSize == 0 {
|
||||
nameHashBucketSize := nginxHashBucketSize(longestName)
|
||||
glog.V(3).Infof("Adjusting ServerNameHashBucketSize variable to %d", nameHashBucketSize)
|
||||
klog.V(3).Infof("Adjusting ServerNameHashBucketSize variable to %d", nameHashBucketSize)
|
||||
cfg.ServerNameHashBucketSize = nameHashBucketSize
|
||||
}
|
||||
serverNameHashMaxSize := nextPowerOf2(serverNameBytes)
|
||||
if cfg.ServerNameHashMaxSize < serverNameHashMaxSize {
|
||||
glog.V(3).Infof("Adjusting ServerNameHashMaxSize variable to %d", serverNameHashMaxSize)
|
||||
klog.V(3).Infof("Adjusting ServerNameHashMaxSize variable to %d", serverNameHashMaxSize)
|
||||
cfg.ServerNameHashMaxSize = serverNameHashMaxSize
|
||||
}
|
||||
|
||||
// the limit of open files is per worker process
|
||||
// and we leave some room to avoid consuming all the FDs available
|
||||
wp, err := strconv.Atoi(cfg.WorkerProcesses)
|
||||
glog.V(3).Infof("Number of worker processes: %d", wp)
|
||||
klog.V(3).Infof("Number of worker processes: %d", wp)
|
||||
if err != nil {
|
||||
wp = 1
|
||||
}
|
||||
maxOpenFiles := (sysctlFSFileMax() / wp) - 1024
|
||||
glog.V(2).Infof("Maximum number of open file descriptors: %d", maxOpenFiles)
|
||||
klog.V(2).Infof("Maximum number of open file descriptors: %d", maxOpenFiles)
|
||||
if maxOpenFiles < 1024 {
|
||||
// this means the value of RLIMIT_NOFILE is too low.
|
||||
maxOpenFiles = 1024
|
||||
|
@ -541,7 +540,7 @@ func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) error {
|
|||
if cfg.ProxySetHeaders != "" {
|
||||
cmap, err := n.store.GetConfigMap(cfg.ProxySetHeaders)
|
||||
if err != nil {
|
||||
glog.Warningf("Error reading ConfigMap %q from local store: %v", cfg.ProxySetHeaders, err)
|
||||
klog.Warningf("Error reading ConfigMap %q from local store: %v", cfg.ProxySetHeaders, err)
|
||||
}
|
||||
|
||||
setHeaders = cmap.Data
|
||||
|
@ -551,7 +550,7 @@ func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) error {
|
|||
if cfg.AddHeaders != "" {
|
||||
cmap, err := n.store.GetConfigMap(cfg.AddHeaders)
|
||||
if err != nil {
|
||||
glog.Warningf("Error reading ConfigMap %q from local store: %v", cfg.AddHeaders, err)
|
||||
klog.Warningf("Error reading ConfigMap %q from local store: %v", cfg.AddHeaders, err)
|
||||
}
|
||||
|
||||
addHeaders = cmap.Data
|
||||
|
@ -563,7 +562,7 @@ func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) error {
|
|||
|
||||
secret, err := n.store.GetSecret(secretName)
|
||||
if err != nil {
|
||||
glog.Warningf("Error reading Secret %q from local store: %v", secretName, err)
|
||||
klog.Warningf("Error reading Secret %q from local store: %v", secretName, err)
|
||||
}
|
||||
|
||||
nsSecName := strings.Replace(secretName, "/", "-", -1)
|
||||
|
@ -572,7 +571,7 @@ func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) error {
|
|||
if ok {
|
||||
pemFileName, err := ssl.AddOrUpdateDHParam(nsSecName, dh, n.fileSystem)
|
||||
if err != nil {
|
||||
glog.Warningf("Error adding or updating dhparam file %v: %v", nsSecName, err)
|
||||
klog.Warningf("Error adding or updating dhparam file %v: %v", nsSecName, err)
|
||||
} else {
|
||||
sslDHParam = pemFileName
|
||||
}
|
||||
|
@ -624,7 +623,7 @@ func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if glog.V(2) {
|
||||
if klog.V(2) {
|
||||
src, _ := ioutil.ReadFile(cfgPath)
|
||||
if !bytes.Equal(src, content) {
|
||||
tmpfile, err := ioutil.TempFile("", "new-nginx-cfg")
|
||||
|
@ -640,7 +639,7 @@ func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) error {
|
|||
// TODO: executing diff can return exit code != 0
|
||||
diffOutput, _ := exec.Command("diff", "-u", cfgPath, tmpfile.Name()).CombinedOutput()
|
||||
|
||||
glog.Infof("NGINX configuration diff:\n%v", string(diffOutput))
|
||||
klog.Infof("NGINX configuration diff:\n%v", string(diffOutput))
|
||||
|
||||
// we do not defer the deletion of temp files in order
|
||||
// to keep them around for inspection in case of error
|
||||
|
@ -691,7 +690,7 @@ func (n *NGINXController) setupSSLProxy() {
|
|||
sslPort := n.cfg.ListenPorts.HTTPS
|
||||
proxyPort := n.cfg.ListenPorts.SSLProxy
|
||||
|
||||
glog.Info("Starting TLS proxy for SSL Passthrough")
|
||||
klog.Info("Starting TLS proxy for SSL Passthrough")
|
||||
n.Proxy = &TCPProxy{
|
||||
Default: &TCPServer{
|
||||
Hostname: "localhost",
|
||||
|
@ -703,7 +702,7 @@ func (n *NGINXController) setupSSLProxy() {
|
|||
|
||||
listener, err := net.Listen("tcp", fmt.Sprintf(":%v", sslPort))
|
||||
if err != nil {
|
||||
glog.Fatalf("%v", err)
|
||||
klog.Fatalf("%v", err)
|
||||
}
|
||||
|
||||
proxyList := &proxyproto.Listener{Listener: listener, ProxyHeaderTimeout: cfg.ProxyProtocolHeaderTimeout}
|
||||
|
@ -723,11 +722,11 @@ func (n *NGINXController) setupSSLProxy() {
|
|||
}
|
||||
|
||||
if err != nil {
|
||||
glog.Warningf("Error accepting TCP connection: %v", err)
|
||||
klog.Warningf("Error accepting TCP connection: %v", err)
|
||||
continue
|
||||
}
|
||||
|
||||
glog.V(3).Infof("Handling connection from remote address %s to local %s", conn.RemoteAddr(), conn.LocalAddr())
|
||||
klog.V(3).Infof("Handling connection from remote address %s to local %s", conn.RemoteAddr(), conn.LocalAddr())
|
||||
go n.Proxy.Handle(conn)
|
||||
}
|
||||
}()
|
||||
|
@ -884,7 +883,7 @@ func post(url string, data interface{}) error {
|
|||
return err
|
||||
}
|
||||
|
||||
glog.V(2).Infof("Posting to %s", url)
|
||||
klog.V(2).Infof("Posting to %s", url)
|
||||
resp, err := http.Post(url, "application/json", bytes.NewReader(buf))
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -892,7 +891,7 @@ func post(url string, data interface{}) error {
|
|||
|
||||
defer func() {
|
||||
if err := resp.Body.Close(); err != nil {
|
||||
glog.Warningf("Error while closing response body:\n%v", err)
|
||||
klog.Warningf("Error while closing response body:\n%v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
"github.com/imdario/mergo"
|
||||
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
|
@ -39,13 +39,13 @@ func (s k8sStore) syncSecret(key string) {
|
|||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
glog.V(3).Infof("Syncing Secret %q", key)
|
||||
klog.V(3).Infof("Syncing Secret %q", key)
|
||||
|
||||
// TODO: getPemCertificate should not write to disk to avoid unnecessary overhead
|
||||
cert, err := s.getPemCertificate(key)
|
||||
if err != nil {
|
||||
if !isErrSecretForAuth(err) {
|
||||
glog.Warningf("Error obtaining X.509 certificate: %v", err)
|
||||
klog.Warningf("Error obtaining X.509 certificate: %v", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ func (s k8sStore) syncSecret(key string) {
|
|||
// no need to update
|
||||
return
|
||||
}
|
||||
glog.Infof("Updating Secret %q in the local store", key)
|
||||
klog.Infof("Updating Secret %q in the local store", key)
|
||||
s.sslStore.Update(key, cert)
|
||||
// this update must trigger an update
|
||||
// (like an update event from a change in Ingress)
|
||||
|
@ -65,7 +65,7 @@ func (s k8sStore) syncSecret(key string) {
|
|||
return
|
||||
}
|
||||
|
||||
glog.Infof("Adding Secret %q to the local store", key)
|
||||
klog.Infof("Adding Secret %q to the local store", key)
|
||||
s.sslStore.Add(key, cert)
|
||||
// this update must trigger an update
|
||||
// (like an update event from a change in Ingress)
|
||||
|
@ -116,7 +116,7 @@ func (s k8sStore) getPemCertificate(secretName string) (*ingress.SSLCert, error)
|
|||
if ca != nil {
|
||||
msg += " and authentication"
|
||||
}
|
||||
glog.V(3).Info(msg)
|
||||
klog.V(3).Info(msg)
|
||||
|
||||
} else if ca != nil {
|
||||
sslCert, err = ssl.AddCertAuth(nsSecName, ca, s.filesystem)
|
||||
|
@ -127,7 +127,7 @@ func (s k8sStore) getPemCertificate(secretName string) (*ingress.SSLCert, error)
|
|||
|
||||
// makes this secret in 'syncSecret' to be used for Certificate Authentication
|
||||
// this does not enable Certificate Authentication
|
||||
glog.V(3).Infof("Configuring Secret %q for TLS authentication", secretName)
|
||||
klog.V(3).Infof("Configuring Secret %q for TLS authentication", secretName)
|
||||
|
||||
} else {
|
||||
if auth != nil {
|
||||
|
@ -158,7 +158,7 @@ func (s k8sStore) checkSSLChainIssues() {
|
|||
|
||||
data, err := ssl.FullChainCert(secret.PemFileName, s.filesystem)
|
||||
if err != nil {
|
||||
glog.Errorf("Error generating CA certificate chain for Secret %q: %v", secrKey, err)
|
||||
klog.Errorf("Error generating CA certificate chain for Secret %q: %v", secrKey, err)
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -166,13 +166,13 @@ func (s k8sStore) checkSSLChainIssues() {
|
|||
|
||||
file, err := s.filesystem.Create(fullChainPemFileName)
|
||||
if err != nil {
|
||||
glog.Errorf("Error creating SSL certificate file for Secret %q: %v", secrKey, err)
|
||||
klog.Errorf("Error creating SSL certificate file for Secret %q: %v", secrKey, err)
|
||||
continue
|
||||
}
|
||||
|
||||
_, err = file.Write(data)
|
||||
if err != nil {
|
||||
glog.Errorf("Error creating SSL certificate for Secret %q: %v", secrKey, err)
|
||||
klog.Errorf("Error creating SSL certificate for Secret %q: %v", secrKey, err)
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -180,13 +180,13 @@ func (s k8sStore) checkSSLChainIssues() {
|
|||
|
||||
err = mergo.MergeWithOverwrite(dst, secret)
|
||||
if err != nil {
|
||||
glog.Errorf("Error creating SSL certificate for Secret %q: %v", secrKey, err)
|
||||
klog.Errorf("Error creating SSL certificate for Secret %q: %v", secrKey, err)
|
||||
continue
|
||||
}
|
||||
|
||||
dst.FullChainPemFileName = fullChainPemFileName
|
||||
|
||||
glog.Infof("Updating local copy of SSL certificate %q with missing intermediate CA certs", secrKey)
|
||||
klog.Infof("Updating local copy of SSL certificate %q with missing intermediate CA certs", secrKey)
|
||||
s.sslStore.Update(secrKey, dst)
|
||||
// this update must trigger an update
|
||||
// (like an update event from a change in Ingress)
|
||||
|
|
|
@ -25,7 +25,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/eapache/channels"
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
extensions "k8s.io/api/extensions/v1beta1"
|
||||
|
@ -247,7 +247,7 @@ func New(checkOCSP bool,
|
|||
}
|
||||
|
||||
eventBroadcaster := record.NewBroadcaster()
|
||||
eventBroadcaster.StartLogging(glog.Infof)
|
||||
eventBroadcaster.StartLogging(klog.Infof)
|
||||
eventBroadcaster.StartRecordingToSink(&clientcorev1.EventSinkImpl{
|
||||
Interface: client.CoreV1().Events(namespace),
|
||||
})
|
||||
|
@ -305,7 +305,7 @@ func New(checkOCSP bool,
|
|||
ing := obj.(*extensions.Ingress)
|
||||
if !class.IsValid(ing) {
|
||||
a, _ := parser.GetStringAnnotation(class.IngressKey, ing)
|
||||
glog.Infof("ignoring add for ingress %v based on annotation %v with value %v", ing.Name, class.IngressKey, a)
|
||||
klog.Infof("ignoring add for ingress %v based on annotation %v with value %v", ing.Name, class.IngressKey, a)
|
||||
return
|
||||
}
|
||||
recorder.Eventf(ing, corev1.EventTypeNormal, "CREATE", fmt.Sprintf("Ingress %s/%s", ing.Namespace, ing.Name))
|
||||
|
@ -325,17 +325,17 @@ func New(checkOCSP bool,
|
|||
// If we reached here it means the ingress was deleted but its final state is unrecorded.
|
||||
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
|
||||
if !ok {
|
||||
glog.Errorf("couldn't get object from tombstone %#v", obj)
|
||||
klog.Errorf("couldn't get object from tombstone %#v", obj)
|
||||
return
|
||||
}
|
||||
ing, ok = tombstone.Obj.(*extensions.Ingress)
|
||||
if !ok {
|
||||
glog.Errorf("Tombstone contained object that is not an Ingress: %#v", obj)
|
||||
klog.Errorf("Tombstone contained object that is not an Ingress: %#v", obj)
|
||||
return
|
||||
}
|
||||
}
|
||||
if !class.IsValid(ing) {
|
||||
glog.Infof("ignoring delete for ingress %v based on annotation %v", ing.Name, class.IngressKey)
|
||||
klog.Infof("ignoring delete for ingress %v based on annotation %v", ing.Name, class.IngressKey)
|
||||
return
|
||||
}
|
||||
recorder.Eventf(ing, corev1.EventTypeNormal, "DELETE", fmt.Sprintf("Ingress %s/%s", ing.Namespace, ing.Name))
|
||||
|
@ -356,10 +356,10 @@ func New(checkOCSP bool,
|
|||
validOld := class.IsValid(oldIng)
|
||||
validCur := class.IsValid(curIng)
|
||||
if !validOld && validCur {
|
||||
glog.Infof("creating ingress %v based on annotation %v", curIng.Name, class.IngressKey)
|
||||
klog.Infof("creating ingress %v based on annotation %v", curIng.Name, class.IngressKey)
|
||||
recorder.Eventf(curIng, corev1.EventTypeNormal, "CREATE", fmt.Sprintf("Ingress %s/%s", curIng.Namespace, curIng.Name))
|
||||
} else if validOld && !validCur {
|
||||
glog.Infof("removing ingress %v based on annotation %v", curIng.Name, class.IngressKey)
|
||||
klog.Infof("removing ingress %v based on annotation %v", curIng.Name, class.IngressKey)
|
||||
recorder.Eventf(curIng, corev1.EventTypeNormal, "DELETE", fmt.Sprintf("Ingress %s/%s", curIng.Namespace, curIng.Name))
|
||||
} else if validCur && !reflect.DeepEqual(old, cur) {
|
||||
recorder.Eventf(curIng, corev1.EventTypeNormal, "UPDATE", fmt.Sprintf("Ingress %s/%s", curIng.Namespace, curIng.Name))
|
||||
|
@ -437,12 +437,12 @@ func New(checkOCSP bool,
|
|||
// If we reached here it means the secret was deleted but its final state is unrecorded.
|
||||
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
|
||||
if !ok {
|
||||
glog.Errorf("couldn't get object from tombstone %#v", obj)
|
||||
klog.Errorf("couldn't get object from tombstone %#v", obj)
|
||||
return
|
||||
}
|
||||
sec, ok = tombstone.Obj.(*corev1.Secret)
|
||||
if !ok {
|
||||
glog.Errorf("Tombstone contained object that is not a Secret: %#v", obj)
|
||||
klog.Errorf("Tombstone contained object that is not a Secret: %#v", obj)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -527,7 +527,7 @@ func New(checkOCSP bool,
|
|||
key := k8s.MetaNamespaceKey(ingKey)
|
||||
ing, err := store.getIngress(key)
|
||||
if err != nil {
|
||||
glog.Errorf("could not find Ingress %v in local store: %v", key, err)
|
||||
klog.Errorf("could not find Ingress %v in local store: %v", key, err)
|
||||
continue
|
||||
}
|
||||
store.syncIngress(ing)
|
||||
|
@ -581,7 +581,7 @@ func New(checkOCSP bool,
|
|||
ns, name, _ := k8s.ParseNameNS(configmap)
|
||||
cm, err := client.CoreV1().ConfigMaps(ns).Get(name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
glog.Warningf("Unexpected error reading configuration configmap: %v", err)
|
||||
klog.Warningf("Unexpected error reading configuration configmap: %v", err)
|
||||
}
|
||||
|
||||
store.setConfig(cm)
|
||||
|
@ -623,7 +623,7 @@ func (s *k8sStore) syncIngress(ing *extensions.Ingress) {
|
|||
// references in secretIngressMap.
|
||||
func (s *k8sStore) updateSecretIngressMap(ing *extensions.Ingress) {
|
||||
key := k8s.MetaNamespaceKey(ing)
|
||||
glog.V(3).Infof("updating references to secrets for ingress %v", key)
|
||||
klog.V(3).Infof("updating references to secrets for ingress %v", key)
|
||||
|
||||
// delete all existing references first
|
||||
s.secretIngressMap.Delete(key)
|
||||
|
@ -649,7 +649,7 @@ func (s *k8sStore) updateSecretIngressMap(ing *extensions.Ingress) {
|
|||
for _, ann := range secretAnnotations {
|
||||
secrKey, err := objectRefAnnotationNsKey(ann, ing)
|
||||
if err != nil && !errors.IsMissingAnnotations(err) {
|
||||
glog.Errorf("error reading secret reference in annotation %q: %s", ann, err)
|
||||
klog.Errorf("error reading secret reference in annotation %q: %s", ann, err)
|
||||
continue
|
||||
}
|
||||
if secrKey != "" {
|
||||
|
@ -775,18 +775,18 @@ func (s k8sStore) writeSSLSessionTicketKey(cmap *corev1.ConfigMap, fileName stri
|
|||
|
||||
// 81 used instead of 80 because of padding
|
||||
if !(ticketBytes == 48 || ticketBytes == 81) {
|
||||
glog.Warningf("ssl-session-ticket-key must contain either 48 or 80 bytes")
|
||||
klog.Warningf("ssl-session-ticket-key must contain either 48 or 80 bytes")
|
||||
}
|
||||
|
||||
decodedTicket, err := base64.StdEncoding.DecodeString(ticketString)
|
||||
if err != nil {
|
||||
glog.Errorf("unexpected error decoding ssl-session-ticket-key: %v", err)
|
||||
klog.Errorf("unexpected error decoding ssl-session-ticket-key: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(fileName, decodedTicket, file.ReadWriteByUser)
|
||||
if err != nil {
|
||||
glog.Errorf("unexpected error writing ssl-session-ticket-key to %s: %v", fileName, err)
|
||||
klog.Errorf("unexpected error writing ssl-session-ticket-key to %s: %v", fileName, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
"io"
|
||||
"net"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
|
||||
"github.com/paultag/sniff/parser"
|
||||
)
|
||||
|
@ -63,19 +63,19 @@ func (p *TCPProxy) Handle(conn net.Conn) {
|
|||
|
||||
length, err := conn.Read(data)
|
||||
if err != nil {
|
||||
glog.V(4).Infof("Error reading the first 4k of the connection: %s", err)
|
||||
klog.V(4).Infof("Error reading the first 4k of the connection: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
proxy := p.Default
|
||||
hostname, err := parser.GetHostname(data[:])
|
||||
if err == nil {
|
||||
glog.V(4).Infof("Parsed hostname from TLS Client Hello: %s", hostname)
|
||||
klog.V(4).Infof("Parsed hostname from TLS Client Hello: %s", hostname)
|
||||
proxy = p.Get(hostname)
|
||||
}
|
||||
|
||||
if proxy == nil {
|
||||
glog.V(4).Infof("There is no configured proxy for SSL connections.")
|
||||
klog.V(4).Infof("There is no configured proxy for SSL connections.")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -96,16 +96,16 @@ func (p *TCPProxy) Handle(conn net.Conn) {
|
|||
protocol = "TCP6"
|
||||
}
|
||||
proxyProtocolHeader := fmt.Sprintf("PROXY %s %s %s %d %d\r\n", protocol, remoteAddr.IP.String(), localAddr.IP.String(), remoteAddr.Port, localAddr.Port)
|
||||
glog.V(4).Infof("Writing Proxy Protocol header: %s", proxyProtocolHeader)
|
||||
klog.V(4).Infof("Writing Proxy Protocol header: %s", proxyProtocolHeader)
|
||||
_, err = fmt.Fprintf(clientConn, proxyProtocolHeader)
|
||||
}
|
||||
if err != nil {
|
||||
glog.Errorf("Error writing Proxy Protocol header: %s", err)
|
||||
klog.Errorf("Error writing Proxy Protocol header: %s", err)
|
||||
clientConn.Close()
|
||||
} else {
|
||||
_, err = clientConn.Write(data[:length])
|
||||
if err != nil {
|
||||
glog.Errorf("Error writing the first 4k of proxy data: %s", err)
|
||||
klog.Errorf("Error writing the first 4k of proxy data: %s", err)
|
||||
clientConn.Close()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
|
||||
"github.com/mitchellh/hashstructure"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
|
@ -83,7 +83,7 @@ func ReadConfig(src map[string]string) config.Configuration {
|
|||
for _, i := range strings.Split(val, ",") {
|
||||
j, err := strconv.Atoi(i)
|
||||
if err != nil {
|
||||
glog.Warningf("%v is not a valid http code: %v", i, err)
|
||||
klog.Warningf("%v is not a valid http code: %v", i, err)
|
||||
} else {
|
||||
errors = append(errors, j)
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ func ReadConfig(src map[string]string) config.Configuration {
|
|||
bindAddressIpv4List = append(bindAddressIpv4List, fmt.Sprintf("%v", ns))
|
||||
}
|
||||
} else {
|
||||
glog.Warningf("%v is not a valid textual representation of an IP address", i)
|
||||
klog.Warningf("%v is not a valid textual representation of an IP address", i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -140,12 +140,12 @@ func ReadConfig(src map[string]string) config.Configuration {
|
|||
delete(conf, httpRedirectCode)
|
||||
j, err := strconv.Atoi(val)
|
||||
if err != nil {
|
||||
glog.Warningf("%v is not a valid HTTP code: %v", val, err)
|
||||
klog.Warningf("%v is not a valid HTTP code: %v", val, err)
|
||||
} else {
|
||||
if validRedirectCodes.Has(j) {
|
||||
to.HTTPRedirectCode = j
|
||||
} else {
|
||||
glog.Warningf("The code %v is not a valid as HTTP redirect code. Using the default.", val)
|
||||
klog.Warningf("The code %v is not a valid as HTTP redirect code. Using the default.", val)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ func ReadConfig(src map[string]string) config.Configuration {
|
|||
delete(conf, proxyHeaderTimeout)
|
||||
duration, err := time.ParseDuration(val)
|
||||
if err != nil {
|
||||
glog.Warningf("proxy-protocol-header-timeout of %v encountered an error while being parsed %v. Switching to use default value instead.", val, err)
|
||||
klog.Warningf("proxy-protocol-header-timeout of %v encountered an error while being parsed %v. Switching to use default value instead.", val, err)
|
||||
} else {
|
||||
to.ProxyProtocolHeaderTimeout = duration
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ func ReadConfig(src map[string]string) config.Configuration {
|
|||
delete(conf, proxyStreamResponses)
|
||||
j, err := strconv.Atoi(val)
|
||||
if err != nil {
|
||||
glog.Warningf("%v is not a valid number: %v", val, err)
|
||||
klog.Warningf("%v is not a valid number: %v", val, err)
|
||||
} else {
|
||||
streamResponses = j
|
||||
}
|
||||
|
@ -220,18 +220,18 @@ func ReadConfig(src map[string]string) config.Configuration {
|
|||
|
||||
decoder, err := mapstructure.NewDecoder(config)
|
||||
if err != nil {
|
||||
glog.Warningf("unexpected error merging defaults: %v", err)
|
||||
klog.Warningf("unexpected error merging defaults: %v", err)
|
||||
}
|
||||
err = decoder.Decode(conf)
|
||||
if err != nil {
|
||||
glog.Warningf("unexpected error merging defaults: %v", err)
|
||||
klog.Warningf("unexpected error merging defaults: %v", err)
|
||||
}
|
||||
|
||||
hash, err := hashstructure.Hash(to, &hashstructure.HashOptions{
|
||||
TagName: "json",
|
||||
})
|
||||
if err != nil {
|
||||
glog.Warningf("unexpected error obtaining hash: %v", err)
|
||||
klog.Warningf("unexpected error obtaining hash: %v", err)
|
||||
}
|
||||
|
||||
to.Checksum = fmt.Sprintf("%v", hash)
|
||||
|
@ -245,7 +245,7 @@ func filterErrors(codes []int) []int {
|
|||
if code > 299 && code < 600 {
|
||||
fa = append(fa, code)
|
||||
} else {
|
||||
glog.Warningf("error code %v is not valid for custom error pages", code)
|
||||
klog.Warningf("error code %v is not valid for custom error pages", code)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import (
|
|||
text_template "text/template"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
|
@ -84,12 +84,12 @@ func (t *Template) Write(conf config.TemplateConfig) ([]byte, error) {
|
|||
outCmdBuf := t.bp.Get()
|
||||
defer t.bp.Put(outCmdBuf)
|
||||
|
||||
if glog.V(3) {
|
||||
if klog.V(3) {
|
||||
b, err := json.Marshal(conf)
|
||||
if err != nil {
|
||||
glog.Errorf("unexpected error: %v", err)
|
||||
klog.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
glog.Infof("NGINX configuration: %v", string(b))
|
||||
klog.Infof("NGINX configuration: %v", string(b))
|
||||
}
|
||||
|
||||
err := t.tmpl.Execute(tmplBuf, conf)
|
||||
|
@ -103,7 +103,7 @@ func (t *Template) Write(conf config.TemplateConfig) ([]byte, error) {
|
|||
cmd.Stdin = tmplBuf
|
||||
cmd.Stdout = outCmdBuf
|
||||
if err := cmd.Run(); err != nil {
|
||||
glog.Warningf("unexpected error cleaning template: %v", err)
|
||||
klog.Warningf("unexpected error cleaning template: %v", err)
|
||||
return tmplBuf.Bytes(), nil
|
||||
}
|
||||
|
||||
|
@ -202,7 +202,7 @@ func shouldConfigureLuaRestyWAF(disableLuaRestyWAF bool, mode string) bool {
|
|||
func buildLuaSharedDictionaries(s interface{}, disableLuaRestyWAF bool) string {
|
||||
servers, ok := s.([]*ingress.Server)
|
||||
if !ok {
|
||||
glog.Errorf("expected an '[]*ingress.Server' type but %T was returned", s)
|
||||
klog.Errorf("expected an '[]*ingress.Server' type but %T was returned", s)
|
||||
return ""
|
||||
}
|
||||
|
||||
|
@ -238,12 +238,12 @@ func buildLuaSharedDictionaries(s interface{}, disableLuaRestyWAF bool) string {
|
|||
func buildResolversForLua(res interface{}, disableIpv6 interface{}) string {
|
||||
nss, ok := res.([]net.IP)
|
||||
if !ok {
|
||||
glog.Errorf("expected a '[]net.IP' type but %T was returned", res)
|
||||
klog.Errorf("expected a '[]net.IP' type but %T was returned", res)
|
||||
return ""
|
||||
}
|
||||
no6, ok := disableIpv6.(bool)
|
||||
if !ok {
|
||||
glog.Errorf("expected a 'bool' type but %T was returned", disableIpv6)
|
||||
klog.Errorf("expected a 'bool' type but %T was returned", disableIpv6)
|
||||
return ""
|
||||
}
|
||||
|
||||
|
@ -267,12 +267,12 @@ func buildResolvers(res interface{}, disableIpv6 interface{}) string {
|
|||
// NGINX need IPV6 addresses to be surrounded by brackets
|
||||
nss, ok := res.([]net.IP)
|
||||
if !ok {
|
||||
glog.Errorf("expected a '[]net.IP' type but %T was returned", res)
|
||||
klog.Errorf("expected a '[]net.IP' type but %T was returned", res)
|
||||
return ""
|
||||
}
|
||||
no6, ok := disableIpv6.(bool)
|
||||
if !ok {
|
||||
glog.Errorf("expected a 'bool' type but %T was returned", disableIpv6)
|
||||
klog.Errorf("expected a 'bool' type but %T was returned", disableIpv6)
|
||||
return ""
|
||||
}
|
||||
|
||||
|
@ -316,7 +316,7 @@ func stripLocationModifer(path string) string {
|
|||
func enforceRegexModifier(input interface{}) bool {
|
||||
locations, ok := input.([]*ingress.Location)
|
||||
if !ok {
|
||||
glog.Errorf("expected an '[]*ingress.Location' type but %T was returned", input)
|
||||
klog.Errorf("expected an '[]*ingress.Location' type but %T was returned", input)
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -333,7 +333,7 @@ func enforceRegexModifier(input interface{}) bool {
|
|||
func buildLocation(input interface{}, enforceRegex bool) string {
|
||||
location, ok := input.(*ingress.Location)
|
||||
if !ok {
|
||||
glog.Errorf("expected an '*ingress.Location' type but %T was returned", input)
|
||||
klog.Errorf("expected an '*ingress.Location' type but %T was returned", input)
|
||||
return slash
|
||||
}
|
||||
|
||||
|
@ -360,7 +360,7 @@ func buildLocation(input interface{}, enforceRegex bool) string {
|
|||
func buildAuthLocation(input interface{}) string {
|
||||
location, ok := input.(*ingress.Location)
|
||||
if !ok {
|
||||
glog.Errorf("expected an '*ingress.Location' type but %T was returned", input)
|
||||
klog.Errorf("expected an '*ingress.Location' type but %T was returned", input)
|
||||
return ""
|
||||
}
|
||||
|
||||
|
@ -378,7 +378,7 @@ func buildAuthResponseHeaders(input interface{}) []string {
|
|||
location, ok := input.(*ingress.Location)
|
||||
res := []string{}
|
||||
if !ok {
|
||||
glog.Errorf("expected an '*ingress.Location' type but %T was returned", input)
|
||||
klog.Errorf("expected an '*ingress.Location' type but %T was returned", input)
|
||||
return res
|
||||
}
|
||||
|
||||
|
@ -398,7 +398,7 @@ func buildAuthResponseHeaders(input interface{}) []string {
|
|||
func buildLogFormatUpstream(input interface{}) string {
|
||||
cfg, ok := input.(config.Configuration)
|
||||
if !ok {
|
||||
glog.Errorf("expected a 'config.Configuration' type but %T was returned", input)
|
||||
klog.Errorf("expected a 'config.Configuration' type but %T was returned", input)
|
||||
return ""
|
||||
}
|
||||
|
||||
|
@ -412,13 +412,13 @@ func buildLogFormatUpstream(input interface{}) string {
|
|||
func buildProxyPass(host string, b interface{}, loc interface{}) string {
|
||||
backends, ok := b.([]*ingress.Backend)
|
||||
if !ok {
|
||||
glog.Errorf("expected an '[]*ingress.Backend' type but %T was returned", b)
|
||||
klog.Errorf("expected an '[]*ingress.Backend' type but %T was returned", b)
|
||||
return ""
|
||||
}
|
||||
|
||||
location, ok := loc.(*ingress.Location)
|
||||
if !ok {
|
||||
glog.Errorf("expected a '*ingress.Location' type but %T was returned", loc)
|
||||
klog.Errorf("expected a '*ingress.Location' type but %T was returned", loc)
|
||||
return ""
|
||||
}
|
||||
|
||||
|
@ -520,7 +520,7 @@ func filterRateLimits(input interface{}) []ratelimit.Config {
|
|||
|
||||
servers, ok := input.([]*ingress.Server)
|
||||
if !ok {
|
||||
glog.Errorf("expected a '[]ratelimit.RateLimit' type but %T was returned", input)
|
||||
klog.Errorf("expected a '[]ratelimit.RateLimit' type but %T was returned", input)
|
||||
return ratelimits
|
||||
}
|
||||
for _, server := range servers {
|
||||
|
@ -544,7 +544,7 @@ func buildRateLimitZones(input interface{}) []string {
|
|||
|
||||
servers, ok := input.([]*ingress.Server)
|
||||
if !ok {
|
||||
glog.Errorf("expected a '[]*ingress.Server' type but %T was returned", input)
|
||||
klog.Errorf("expected a '[]*ingress.Server' type but %T was returned", input)
|
||||
return zones.List()
|
||||
}
|
||||
|
||||
|
@ -594,7 +594,7 @@ func buildRateLimit(input interface{}) []string {
|
|||
|
||||
loc, ok := input.(*ingress.Location)
|
||||
if !ok {
|
||||
glog.Errorf("expected an '*ingress.Location' type but %T was returned", input)
|
||||
klog.Errorf("expected an '*ingress.Location' type but %T was returned", input)
|
||||
return limits
|
||||
}
|
||||
|
||||
|
@ -634,7 +634,7 @@ func buildRateLimit(input interface{}) []string {
|
|||
func isLocationInLocationList(location interface{}, rawLocationList string) bool {
|
||||
loc, ok := location.(*ingress.Location)
|
||||
if !ok {
|
||||
glog.Errorf("expected an '*ingress.Location' type but %T was returned", location)
|
||||
klog.Errorf("expected an '*ingress.Location' type but %T was returned", location)
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -656,7 +656,7 @@ func isLocationInLocationList(location interface{}, rawLocationList string) bool
|
|||
func isLocationAllowed(input interface{}) bool {
|
||||
loc, ok := input.(*ingress.Location)
|
||||
if !ok {
|
||||
glog.Errorf("expected an '*ingress.Location' type but %T was returned", input)
|
||||
klog.Errorf("expected an '*ingress.Location' type but %T was returned", input)
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -675,7 +675,7 @@ var (
|
|||
func buildDenyVariable(a interface{}) string {
|
||||
l, ok := a.(string)
|
||||
if !ok {
|
||||
glog.Errorf("expected a 'string' type but %T was returned", a)
|
||||
klog.Errorf("expected a 'string' type but %T was returned", a)
|
||||
return ""
|
||||
}
|
||||
|
||||
|
@ -689,7 +689,7 @@ func buildDenyVariable(a interface{}) string {
|
|||
func buildUpstreamName(loc interface{}) string {
|
||||
location, ok := loc.(*ingress.Location)
|
||||
if !ok {
|
||||
glog.Errorf("expected a '*ingress.Location' type but %T was returned", loc)
|
||||
klog.Errorf("expected a '*ingress.Location' type but %T was returned", loc)
|
||||
return ""
|
||||
}
|
||||
|
||||
|
@ -701,7 +701,7 @@ func buildUpstreamName(loc interface{}) string {
|
|||
func buildNextUpstream(i, r interface{}) string {
|
||||
nextUpstream, ok := i.(string)
|
||||
if !ok {
|
||||
glog.Errorf("expected a 'string' type but %T was returned", i)
|
||||
klog.Errorf("expected a 'string' type but %T was returned", i)
|
||||
return ""
|
||||
}
|
||||
|
||||
|
@ -765,13 +765,13 @@ type ingressInformation struct {
|
|||
func getIngressInformation(i, p interface{}) *ingressInformation {
|
||||
ing, ok := i.(*ingress.Ingress)
|
||||
if !ok {
|
||||
glog.Errorf("expected an '*ingress.Ingress' type but %T was returned", i)
|
||||
klog.Errorf("expected an '*ingress.Ingress' type but %T was returned", i)
|
||||
return &ingressInformation{}
|
||||
}
|
||||
|
||||
path, ok := p.(string)
|
||||
if !ok {
|
||||
glog.Errorf("expected a 'string' type but %T was returned", p)
|
||||
klog.Errorf("expected a 'string' type but %T was returned", p)
|
||||
return &ingressInformation{}
|
||||
}
|
||||
|
||||
|
@ -808,7 +808,7 @@ func getIngressInformation(i, p interface{}) *ingressInformation {
|
|||
func buildForwardedFor(input interface{}) string {
|
||||
s, ok := input.(string)
|
||||
if !ok {
|
||||
glog.Errorf("expected a 'string' type but %T was returned", input)
|
||||
klog.Errorf("expected a 'string' type but %T was returned", input)
|
||||
return ""
|
||||
}
|
||||
|
||||
|
@ -820,7 +820,7 @@ func buildForwardedFor(input interface{}) string {
|
|||
func buildAuthSignURL(input interface{}) string {
|
||||
s, ok := input.(string)
|
||||
if !ok {
|
||||
glog.Errorf("expected an 'string' type but %T was returned", input)
|
||||
klog.Errorf("expected an 'string' type but %T was returned", input)
|
||||
return ""
|
||||
}
|
||||
|
||||
|
@ -855,7 +855,7 @@ func randomString() string {
|
|||
func buildOpentracing(input interface{}) string {
|
||||
cfg, ok := input.(config.Configuration)
|
||||
if !ok {
|
||||
glog.Errorf("expected a 'config.Configuration' type but %T was returned", input)
|
||||
klog.Errorf("expected a 'config.Configuration' type but %T was returned", input)
|
||||
return ""
|
||||
}
|
||||
|
||||
|
@ -881,7 +881,7 @@ func buildOpentracing(input interface{}) string {
|
|||
func buildInfluxDB(input interface{}) string {
|
||||
cfg, ok := input.(influxdb.Config)
|
||||
if !ok {
|
||||
glog.Errorf("expected an 'influxdb.Config' type but %T was returned", input)
|
||||
klog.Errorf("expected an 'influxdb.Config' type but %T was returned", input)
|
||||
return ""
|
||||
}
|
||||
|
||||
|
@ -901,7 +901,7 @@ func buildInfluxDB(input interface{}) string {
|
|||
func proxySetHeader(loc interface{}) string {
|
||||
location, ok := loc.(*ingress.Location)
|
||||
if !ok {
|
||||
glog.Errorf("expected a '*ingress.Location' type but %T was returned", loc)
|
||||
klog.Errorf("expected a '*ingress.Location' type but %T was returned", loc)
|
||||
return "proxy_set_header"
|
||||
}
|
||||
|
||||
|
@ -932,7 +932,7 @@ func buildCustomErrorDeps(proxySetHeaders map[string]string, errorCodes []int, e
|
|||
func collectCustomErrorsPerServer(input interface{}) []int {
|
||||
server, ok := input.(*ingress.Server)
|
||||
if !ok {
|
||||
glog.Errorf("expected a '*ingress.Server' type but %T was returned", input)
|
||||
klog.Errorf("expected a '*ingress.Server' type but %T was returned", input)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -954,7 +954,7 @@ func collectCustomErrorsPerServer(input interface{}) []int {
|
|||
func opentracingPropagateContext(loc interface{}) string {
|
||||
location, ok := loc.(*ingress.Location)
|
||||
if !ok {
|
||||
glog.Errorf("expected a '*ingress.Location' type but %T was returned", loc)
|
||||
klog.Errorf("expected a '*ingress.Location' type but %T was returned", loc)
|
||||
return "opentracing_propagate_context"
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
|
||||
"fmt"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
|
||||
api "k8s.io/api/core/v1"
|
||||
"k8s.io/kubernetes/pkg/util/sysctl"
|
||||
|
@ -57,7 +57,7 @@ func upstreamName(namespace string, service string, port intstr.IntOrString) str
|
|||
func sysctlSomaxconn() int {
|
||||
maxConns, err := sysctl.New().GetSysctl("net/core/somaxconn")
|
||||
if err != nil || maxConns < 512 {
|
||||
glog.V(3).Infof("net.core.somaxconn=%v (using system default)", maxConns)
|
||||
klog.V(3).Infof("net.core.somaxconn=%v (using system default)", maxConns)
|
||||
return 511
|
||||
}
|
||||
|
||||
|
@ -70,10 +70,10 @@ func sysctlFSFileMax() int {
|
|||
var rLimit syscall.Rlimit
|
||||
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
|
||||
if err != nil {
|
||||
glog.Errorf("Error reading system maximum number of open file descriptors (RLIMIT_NOFILE): %v", err)
|
||||
klog.Errorf("Error reading system maximum number of open file descriptors (RLIMIT_NOFILE): %v", err)
|
||||
return 0
|
||||
}
|
||||
glog.V(2).Infof("rlimit.max=%v", rLimit.Max)
|
||||
klog.V(2).Infof("rlimit.max=%v", rLimit.Max)
|
||||
return int(rLimit.Max)
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import (
|
|||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
|
@ -181,11 +181,11 @@ func (cm *Controller) SetSSLExpireTime(servers []*ingress.Server) {
|
|||
func (cm *Controller) RemoveMetrics(hosts []string, registry prometheus.Gatherer) {
|
||||
mfs, err := registry.Gather()
|
||||
if err != nil {
|
||||
glog.Errorf("Error gathering metrics: %v", err)
|
||||
klog.Errorf("Error gathering metrics: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
glog.V(2).Infof("removing SSL certificate metrics for %v hosts", hosts)
|
||||
klog.V(2).Infof("removing SSL certificate metrics for %v hosts", hosts)
|
||||
toRemove := sets.NewString(hosts...)
|
||||
|
||||
for _, mf := range mfs {
|
||||
|
@ -212,10 +212,10 @@ func (cm *Controller) RemoveMetrics(hosts []string, registry prometheus.Gatherer
|
|||
continue
|
||||
}
|
||||
|
||||
glog.V(2).Infof("Removing prometheus metric from gauge %v for host %v", metricName, host)
|
||||
klog.V(2).Infof("Removing prometheus metric from gauge %v for host %v", metricName, host)
|
||||
removed := cm.sslExpireTime.Delete(labels)
|
||||
if !removed {
|
||||
glog.V(2).Infof("metric %v for host %v with labels not removed: %v", metricName, host, labels)
|
||||
klog.V(2).Infof("metric %v for host %v with labels not removed: %v", metricName, host, labels)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
"regexp"
|
||||
"strconv"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
|
@ -189,7 +189,7 @@ func parse(data string) *basicStatus {
|
|||
|
||||
func getNginxStatus(port int, path string) (*basicStatus, error) {
|
||||
url := fmt.Sprintf("http://0.0.0.0:%v%v", port, path)
|
||||
glog.V(3).Infof("start scraping url: %v", url)
|
||||
klog.V(3).Infof("start scraping url: %v", url)
|
||||
|
||||
data, err := httpBody(url)
|
||||
|
||||
|
@ -204,7 +204,7 @@ func getNginxStatus(port int, path string) (*basicStatus, error) {
|
|||
func (p nginxStatusCollector) scrape(ch chan<- prometheus.Metric) {
|
||||
s, err := getNginxStatus(p.ngxHealthPort, p.ngxStatusPath)
|
||||
if err != nil {
|
||||
glog.Warningf("unexpected error obtaining nginx status info: %v", err)
|
||||
klog.Warningf("unexpected error obtaining nginx status info: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
"net"
|
||||
"os"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
|
@ -203,19 +203,19 @@ func NewSocketCollector(pod, namespace, class string) (*SocketCollector, error)
|
|||
}
|
||||
|
||||
func (sc *SocketCollector) handleMessage(msg []byte) {
|
||||
glog.V(5).Infof("msg: %v", string(msg))
|
||||
klog.V(5).Infof("msg: %v", string(msg))
|
||||
|
||||
// Unmarshal bytes
|
||||
var statsBatch []socketData
|
||||
err := jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(msg, &statsBatch)
|
||||
if err != nil {
|
||||
glog.Errorf("Unexpected error deserializing JSON payload: %v. Payload:\n%v", err, string(msg))
|
||||
klog.Errorf("Unexpected error deserializing JSON payload: %v. Payload:\n%v", err, string(msg))
|
||||
return
|
||||
}
|
||||
|
||||
for _, stats := range statsBatch {
|
||||
if !sc.hosts.Has(stats.Host) {
|
||||
glog.V(3).Infof("skiping metric for host %v that is not being served", stats.Host)
|
||||
klog.V(3).Infof("skiping metric for host %v that is not being served", stats.Host)
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -243,7 +243,7 @@ func (sc *SocketCollector) handleMessage(msg []byte) {
|
|||
|
||||
requestsMetric, err := sc.requests.GetMetricWith(collectorLabels)
|
||||
if err != nil {
|
||||
glog.Errorf("Error fetching requests metric: %v", err)
|
||||
klog.Errorf("Error fetching requests metric: %v", err)
|
||||
} else {
|
||||
requestsMetric.Inc()
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ func (sc *SocketCollector) handleMessage(msg []byte) {
|
|||
if stats.Latency != -1 {
|
||||
latencyMetric, err := sc.upstreamLatency.GetMetricWith(latencyLabels)
|
||||
if err != nil {
|
||||
glog.Errorf("Error fetching latency metric: %v", err)
|
||||
klog.Errorf("Error fetching latency metric: %v", err)
|
||||
} else {
|
||||
latencyMetric.Observe(stats.Latency)
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ func (sc *SocketCollector) handleMessage(msg []byte) {
|
|||
if stats.RequestTime != -1 {
|
||||
requestTimeMetric, err := sc.requestTime.GetMetricWith(requestLabels)
|
||||
if err != nil {
|
||||
glog.Errorf("Error fetching request duration metric: %v", err)
|
||||
klog.Errorf("Error fetching request duration metric: %v", err)
|
||||
} else {
|
||||
requestTimeMetric.Observe(stats.RequestTime)
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ func (sc *SocketCollector) handleMessage(msg []byte) {
|
|||
if stats.RequestLength != -1 {
|
||||
requestLengthMetric, err := sc.requestLength.GetMetricWith(requestLabels)
|
||||
if err != nil {
|
||||
glog.Errorf("Error fetching request length metric: %v", err)
|
||||
klog.Errorf("Error fetching request length metric: %v", err)
|
||||
} else {
|
||||
requestLengthMetric.Observe(stats.RequestLength)
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ func (sc *SocketCollector) handleMessage(msg []byte) {
|
|||
if stats.ResponseTime != -1 {
|
||||
responseTimeMetric, err := sc.responseTime.GetMetricWith(requestLabels)
|
||||
if err != nil {
|
||||
glog.Errorf("Error fetching upstream response time metric: %v", err)
|
||||
klog.Errorf("Error fetching upstream response time metric: %v", err)
|
||||
} else {
|
||||
responseTimeMetric.Observe(stats.ResponseTime)
|
||||
}
|
||||
|
@ -287,14 +287,14 @@ func (sc *SocketCollector) handleMessage(msg []byte) {
|
|||
if stats.ResponseLength != -1 {
|
||||
bytesSentMetric, err := sc.bytesSent.GetMetricWith(requestLabels)
|
||||
if err != nil {
|
||||
glog.Errorf("Error fetching bytes sent metric: %v", err)
|
||||
klog.Errorf("Error fetching bytes sent metric: %v", err)
|
||||
} else {
|
||||
bytesSentMetric.Observe(stats.ResponseLength)
|
||||
}
|
||||
|
||||
responseSizeMetric, err := sc.responseLength.GetMetricWith(requestLabels)
|
||||
if err != nil {
|
||||
glog.Errorf("Error fetching bytes sent metric: %v", err)
|
||||
klog.Errorf("Error fetching bytes sent metric: %v", err)
|
||||
} else {
|
||||
responseSizeMetric.Observe(stats.ResponseLength)
|
||||
}
|
||||
|
@ -325,12 +325,12 @@ func (sc *SocketCollector) Stop() {
|
|||
func (sc *SocketCollector) RemoveMetrics(ingresses []string, registry prometheus.Gatherer) {
|
||||
mfs, err := registry.Gather()
|
||||
if err != nil {
|
||||
glog.Errorf("Error gathering metrics: %v", err)
|
||||
klog.Errorf("Error gathering metrics: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
// 1. remove metrics of removed ingresses
|
||||
glog.V(2).Infof("removing ingresses %v from metrics", ingresses)
|
||||
klog.V(2).Infof("removing ingresses %v from metrics", ingresses)
|
||||
for _, mf := range mfs {
|
||||
metricName := mf.GetName()
|
||||
metric, ok := sc.metricMapping[metricName]
|
||||
|
@ -362,13 +362,13 @@ func (sc *SocketCollector) RemoveMetrics(ingresses []string, registry prometheus
|
|||
continue
|
||||
}
|
||||
|
||||
glog.V(2).Infof("Removing prometheus metric from histogram %v for ingress %v", metricName, ingKey)
|
||||
klog.V(2).Infof("Removing prometheus metric from histogram %v for ingress %v", metricName, ingKey)
|
||||
|
||||
h, ok := metric.(*prometheus.HistogramVec)
|
||||
if ok {
|
||||
removed := h.Delete(labels)
|
||||
if !removed {
|
||||
glog.V(2).Infof("metric %v for ingress %v with labels not removed: %v", metricName, ingKey, labels)
|
||||
klog.V(2).Infof("metric %v for ingress %v with labels not removed: %v", metricName, ingKey, labels)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -376,7 +376,7 @@ func (sc *SocketCollector) RemoveMetrics(ingresses []string, registry prometheus
|
|||
if ok {
|
||||
removed := s.Delete(labels)
|
||||
if !removed {
|
||||
glog.V(2).Infof("metric %v for ingress %v with labels not removed: %v", metricName, ingKey, labels)
|
||||
klog.V(2).Infof("metric %v for ingress %v with labels not removed: %v", metricName, ingKey, labels)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
pool "gopkg.in/go-playground/pool.v3"
|
||||
|
@ -123,7 +123,7 @@ func (s statusSync) Run() {
|
|||
var stopCh chan struct{}
|
||||
callbacks := leaderelection.LeaderCallbacks{
|
||||
OnStartedLeading: func(ctx context.Context) {
|
||||
glog.V(2).Infof("I am the new status update leader")
|
||||
klog.V(2).Infof("I am the new status update leader")
|
||||
stopCh = make(chan struct{})
|
||||
go s.syncQueue.Run(time.Second, stopCh)
|
||||
// trigger initial sync
|
||||
|
@ -136,7 +136,7 @@ func (s statusSync) Run() {
|
|||
}, stopCh)
|
||||
},
|
||||
OnStoppedLeading: func() {
|
||||
glog.V(2).Info("I am not status update leader anymore")
|
||||
klog.V(2).Info("I am not status update leader anymore")
|
||||
close(stopCh)
|
||||
|
||||
// cancel the context
|
||||
|
@ -145,7 +145,7 @@ func (s statusSync) Run() {
|
|||
cancelContext = newLeaderCtx(ctx)
|
||||
},
|
||||
OnNewLeader: func(identity string) {
|
||||
glog.Infof("new leader elected: %v", identity)
|
||||
klog.Infof("new leader elected: %v", identity)
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ func (s statusSync) Run() {
|
|||
Callbacks: callbacks,
|
||||
})
|
||||
if err != nil {
|
||||
glog.Fatalf("unexpected error starting leader election: %v", err)
|
||||
klog.Fatalf("unexpected error starting leader election: %v", err)
|
||||
}
|
||||
|
||||
cancelContext = newLeaderCtx(ctx)
|
||||
|
@ -193,36 +193,36 @@ func (s statusSync) Shutdown() {
|
|||
}
|
||||
|
||||
if !s.UpdateStatusOnShutdown {
|
||||
glog.Warningf("skipping update of status of Ingress rules")
|
||||
klog.Warningf("skipping update of status of Ingress rules")
|
||||
return
|
||||
}
|
||||
|
||||
glog.Info("updating status of Ingress rules (remove)")
|
||||
klog.Info("updating status of Ingress rules (remove)")
|
||||
|
||||
addrs, err := s.runningAddresses()
|
||||
if err != nil {
|
||||
glog.Errorf("error obtaining running IPs: %v", addrs)
|
||||
klog.Errorf("error obtaining running IPs: %v", addrs)
|
||||
return
|
||||
}
|
||||
|
||||
if len(addrs) > 1 {
|
||||
// leave the job to the next leader
|
||||
glog.Infof("leaving status update for next leader (%v)", len(addrs))
|
||||
klog.Infof("leaving status update for next leader (%v)", len(addrs))
|
||||
return
|
||||
}
|
||||
|
||||
if s.isRunningMultiplePods() {
|
||||
glog.V(2).Infof("skipping Ingress status update (multiple pods running - another one will be elected as master)")
|
||||
klog.V(2).Infof("skipping Ingress status update (multiple pods running - another one will be elected as master)")
|
||||
return
|
||||
}
|
||||
|
||||
glog.Infof("removing address from ingress status (%v)", addrs)
|
||||
klog.Infof("removing address from ingress status (%v)", addrs)
|
||||
s.updateStatus([]apiv1.LoadBalancerIngress{})
|
||||
}
|
||||
|
||||
func (s *statusSync) sync(key interface{}) error {
|
||||
if s.syncQueue.IsShuttingDown() {
|
||||
glog.V(2).Infof("skipping Ingress status update (shutting down in progress)")
|
||||
klog.V(2).Infof("skipping Ingress status update (shutting down in progress)")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -247,7 +247,7 @@ func (s statusSync) keyfunc(input interface{}) (interface{}, error) {
|
|||
func NewStatusSyncer(config Config) Sync {
|
||||
pod, err := k8s.GetPodDetails(config.Client)
|
||||
if err != nil {
|
||||
glog.Fatalf("unexpected error obtaining pod information: %v", err)
|
||||
klog.Fatalf("unexpected error obtaining pod information: %v", err)
|
||||
}
|
||||
|
||||
st := statusSync{
|
||||
|
@ -360,7 +360,7 @@ func (s *statusSync) updateStatus(newIngressPoint []apiv1.LoadBalancerIngress) {
|
|||
curIPs := ing.Status.LoadBalancer.Ingress
|
||||
sort.SliceStable(curIPs, lessLoadBalancerIngress(curIPs))
|
||||
if ingressSliceEqual(curIPs, newIngressPoint) {
|
||||
glog.V(3).Infof("skipping update of Ingress %v/%v (no change)", ing.Namespace, ing.Name)
|
||||
klog.V(3).Infof("skipping update of Ingress %v/%v (no change)", ing.Namespace, ing.Name)
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -385,11 +385,11 @@ func runUpdate(ing *ingress.Ingress, status []apiv1.LoadBalancerIngress,
|
|||
return nil, errors.Wrap(err, fmt.Sprintf("unexpected error searching Ingress %v/%v", ing.Namespace, ing.Name))
|
||||
}
|
||||
|
||||
glog.Infof("updating Ingress %v/%v status to %v", currIng.Namespace, currIng.Name, status)
|
||||
klog.Infof("updating Ingress %v/%v status to %v", currIng.Namespace, currIng.Name, status)
|
||||
currIng.Status.LoadBalancer.Ingress = status
|
||||
_, err = ingClient.UpdateStatus(currIng)
|
||||
if err != nil {
|
||||
glog.Warningf("error updating ingress rule: %v", err)
|
||||
klog.Warningf("error updating ingress rule: %v", err)
|
||||
}
|
||||
|
||||
return true, nil
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
|
@ -42,7 +42,7 @@ func ParseNameNS(input string) (string, string, error) {
|
|||
func GetNodeIPOrName(kubeClient clientset.Interface, name string, useInternalIP bool) string {
|
||||
node, err := kubeClient.CoreV1().Nodes().Get(name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
glog.Errorf("Error getting node %v: %v", name, err)
|
||||
klog.Errorf("Error getting node %v: %v", name, err)
|
||||
return ""
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ func GetPodDetails(kubeClient clientset.Interface) (*PodInfo, error) {
|
|||
func MetaNamespaceKey(obj interface{}) string {
|
||||
key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj)
|
||||
if err != nil {
|
||||
glog.Warning(err)
|
||||
klog.Warning(err)
|
||||
}
|
||||
|
||||
return key
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
var defResolvConf = "/etc/resolv.conf"
|
||||
|
@ -53,6 +53,6 @@ func GetSystemNameServers() ([]net.IP, error) {
|
|||
}
|
||||
}
|
||||
|
||||
glog.V(3).Infof("nameservers IP address/es to use: %v", nameservers)
|
||||
klog.V(3).Infof("nameservers IP address/es to use: %v", nameservers)
|
||||
return nameservers, nil
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
"github.com/zakjan/cert-chain-resolver/certUtil"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
|
@ -56,7 +56,7 @@ func AddOrUpdateCertAndKey(name string, cert, key, ca []byte,
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("could not create temp pem file %v: %v", pemFileName, err)
|
||||
}
|
||||
glog.V(3).Infof("Creating temp file %v for Keypair: %v", tempPemFile.Name(), pemName)
|
||||
klog.V(3).Infof("Creating temp file %v for Keypair: %v", tempPemFile.Name(), pemName)
|
||||
|
||||
_, err = tempPemFile.Write(cert)
|
||||
if err != nil {
|
||||
|
@ -110,11 +110,11 @@ func AddOrUpdateCertAndKey(name string, cert, key, ca []byte,
|
|||
}
|
||||
|
||||
if len(pemCert.Extensions) > 0 {
|
||||
glog.V(3).Info("parsing ssl certificate extensions")
|
||||
klog.V(3).Info("parsing ssl certificate extensions")
|
||||
for _, ext := range getExtension(pemCert, oidExtensionSubjectAltName) {
|
||||
dns, _, _, err := parseSANExtension(ext.Value)
|
||||
if err != nil {
|
||||
glog.Warningf("unexpected error parsing certificate extensions: %v", err)
|
||||
klog.Warningf("unexpected error parsing certificate extensions: %v", err)
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -224,11 +224,11 @@ func CreateSSLCert(name string, cert, key, ca []byte) (*ingress.SSLCert, error)
|
|||
}
|
||||
|
||||
if len(pemCert.Extensions) > 0 {
|
||||
glog.V(3).Info("parsing ssl certificate extensions")
|
||||
klog.V(3).Info("parsing ssl certificate extensions")
|
||||
for _, ext := range getExtension(pemCert, oidExtensionSubjectAltName) {
|
||||
dns, _, _, err := parseSANExtension(ext.Value)
|
||||
if err != nil {
|
||||
glog.Warningf("unexpected error parsing certificate extensions: %v", err)
|
||||
klog.Warningf("unexpected error parsing certificate extensions: %v", err)
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -366,7 +366,7 @@ func AddCertAuth(name string, ca []byte, fs file.Filesystem) (*ingress.SSLCert,
|
|||
return nil, fmt.Errorf("could not write CA file %v: %v", caFileName, err)
|
||||
}
|
||||
|
||||
glog.V(3).Infof("Created CA Certificate for Authentication: %v", caFileName)
|
||||
klog.V(3).Infof("Created CA Certificate for Authentication: %v", caFileName)
|
||||
return &ingress.SSLCert{
|
||||
Certificate: pemCert,
|
||||
CAFileName: caFileName,
|
||||
|
@ -382,7 +382,7 @@ func AddOrUpdateDHParam(name string, dh []byte, fs file.Filesystem) (string, err
|
|||
|
||||
tempPemFile, err := fs.TempFile(file.DefaultSSLDirectory, pemName)
|
||||
|
||||
glog.V(3).Infof("Creating temp file %v for DH param: %v", tempPemFile.Name(), pemName)
|
||||
klog.V(3).Infof("Creating temp file %v for DH param: %v", tempPemFile.Name(), pemName)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not create temp pem file %v: %v", pemFileName, err)
|
||||
}
|
||||
|
@ -432,7 +432,7 @@ func GetFakeSSLCert() ([]byte, []byte) {
|
|||
priv, err = rsa.GenerateKey(rand.Reader, 2048)
|
||||
|
||||
if err != nil {
|
||||
glog.Fatalf("failed to generate fake private key: %s", err)
|
||||
klog.Fatalf("failed to generate fake private key: %s", err)
|
||||
}
|
||||
|
||||
notBefore := time.Now()
|
||||
|
@ -443,7 +443,7 @@ func GetFakeSSLCert() ([]byte, []byte) {
|
|||
serialNumber, err := rand.Int(rand.Reader, serialNumberLimit)
|
||||
|
||||
if err != nil {
|
||||
glog.Fatalf("failed to generate fake serial number: %s", err)
|
||||
klog.Fatalf("failed to generate fake serial number: %s", err)
|
||||
}
|
||||
|
||||
template := x509.Certificate{
|
||||
|
@ -462,7 +462,7 @@ func GetFakeSSLCert() ([]byte, []byte) {
|
|||
}
|
||||
derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.(*rsa.PrivateKey).PublicKey, priv)
|
||||
if err != nil {
|
||||
glog.Fatalf("Failed to create fake certificate: %s", err)
|
||||
klog.Fatalf("Failed to create fake certificate: %s", err)
|
||||
}
|
||||
|
||||
cert := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: derBytes})
|
||||
|
|
|
@ -18,20 +18,20 @@ package ssl
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/rsa"
|
||||
"crypto/x509"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
certutil "k8s.io/client-go/util/cert"
|
||||
"k8s.io/client-go/util/cert/triple"
|
||||
|
||||
"k8s.io/ingress-nginx/internal/file"
|
||||
)
|
||||
|
||||
// generateRSACerts generates a self signed certificate using a self generated ca
|
||||
func generateRSACerts(host string) (*triple.KeyPair, *triple.KeyPair, error) {
|
||||
ca, err := triple.NewCA("self-sign-ca")
|
||||
func generateRSACerts(host string) (*keyPair, *keyPair, error) {
|
||||
ca, err := newCA("self-sign-ca")
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ func generateRSACerts(host string) (*triple.KeyPair, *triple.KeyPair, error) {
|
|||
return nil, nil, fmt.Errorf("unable to sign the server certificate: %v", err)
|
||||
}
|
||||
|
||||
return &triple.KeyPair{
|
||||
return &keyPair{
|
||||
Key: key,
|
||||
Cert: cert,
|
||||
}, ca, nil
|
||||
|
@ -182,3 +182,26 @@ func TestCreateSSLCert(t *testing.T) {
|
|||
t.Fatalf("expected cname echoheaders but %v returned", ngxCert.CN[0])
|
||||
}
|
||||
}
|
||||
|
||||
type keyPair struct {
|
||||
Key *rsa.PrivateKey
|
||||
Cert *x509.Certificate
|
||||
}
|
||||
|
||||
func newCA(name string) (*keyPair, error) {
|
||||
key, err := certutil.NewPrivateKey()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to create a private key for a new CA: %v", err)
|
||||
}
|
||||
config := certutil.Config{
|
||||
CommonName: name,
|
||||
}
|
||||
cert, err := certutil.NewSelfSignedCACert(config, key)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to create a self-signed certificate for a new CA: %v", err)
|
||||
}
|
||||
return &keyPair{
|
||||
Key: key,
|
||||
Cert: cert,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import (
|
|||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
|
@ -75,7 +75,7 @@ func (t *Queue) EnqueueSkippableTask(obj interface{}) {
|
|||
// enqueue enqueues ns/name of the given api object in the task queue.
|
||||
func (t *Queue) enqueue(obj interface{}, skippable bool) {
|
||||
if t.IsShuttingDown() {
|
||||
glog.Errorf("queue has been shutdown, failed to enqueue: %v", obj)
|
||||
klog.Errorf("queue has been shutdown, failed to enqueue: %v", obj)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -84,10 +84,10 @@ func (t *Queue) enqueue(obj interface{}, skippable bool) {
|
|||
// make sure the timestamp is bigger than lastSync
|
||||
ts = time.Now().Add(24 * time.Hour).UnixNano()
|
||||
}
|
||||
glog.V(3).Infof("queuing item %v", obj)
|
||||
klog.V(3).Infof("queuing item %v", obj)
|
||||
key, err := t.fn(obj)
|
||||
if err != nil {
|
||||
glog.Errorf("%v", err)
|
||||
klog.Errorf("%v", err)
|
||||
return
|
||||
}
|
||||
t.queue.Add(Element{
|
||||
|
@ -119,15 +119,15 @@ func (t *Queue) worker() {
|
|||
|
||||
item := key.(Element)
|
||||
if t.lastSync > item.Timestamp {
|
||||
glog.V(3).Infof("skipping %v sync (%v > %v)", item.Key, t.lastSync, item.Timestamp)
|
||||
klog.V(3).Infof("skipping %v sync (%v > %v)", item.Key, t.lastSync, item.Timestamp)
|
||||
t.queue.Forget(key)
|
||||
t.queue.Done(key)
|
||||
continue
|
||||
}
|
||||
|
||||
glog.V(3).Infof("syncing %v", item.Key)
|
||||
klog.V(3).Infof("syncing %v", item.Key)
|
||||
if err := t.sync(key); err != nil {
|
||||
glog.Warningf("requeuing %v, err %v", item.Key, err)
|
||||
klog.Warningf("requeuing %v, err %v", item.Key, err)
|
||||
t.queue.AddRateLimited(Element{
|
||||
Key: item.Key,
|
||||
Timestamp: time.Now().UnixNano(),
|
||||
|
|
|
@ -19,7 +19,7 @@ package e2e
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
|
||||
"k8s.io/ingress-nginx/test/e2e/framework"
|
||||
|
@ -29,7 +29,7 @@ func init() {
|
|||
framework.RegisterParseFlags()
|
||||
|
||||
if "" == framework.TestContext.KubeConfig {
|
||||
glog.Fatalf("environment variable %v must be set", clientcmd.RecommendedConfigPathEnvVar)
|
||||
klog.Fatalf("environment variable %v must be set", clientcmd.RecommendedConfigPathEnvVar)
|
||||
}
|
||||
}
|
||||
func TestE2E(t *testing.T) {
|
||||
|
|
|
@ -30,7 +30,7 @@ import (
|
|||
"k8s.io/client-go/kubernetes"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
|
@ -235,8 +235,8 @@ func (f *Framework) matchNginxConditions(name string, matcher func(cfg string) b
|
|||
|
||||
var match bool
|
||||
errs := InterceptGomegaFailures(func() {
|
||||
if glog.V(10) && len(o) > 0 {
|
||||
glog.Infof("nginx.conf:\n%v", o)
|
||||
if klog.V(10) && len(o) > 0 {
|
||||
klog.Infof("nginx.conf:\n%v", o)
|
||||
}
|
||||
|
||||
// passes the nginx config to the passed function
|
||||
|
@ -250,7 +250,7 @@ func (f *Framework) matchNginxConditions(name string, matcher func(cfg string) b
|
|||
}
|
||||
|
||||
if len(errs) > 0 {
|
||||
glog.V(2).Infof("Errors waiting for conditions: %v", errs)
|
||||
klog.V(2).Infof("Errors waiting for conditions: %v", errs)
|
||||
}
|
||||
|
||||
return false, nil
|
||||
|
@ -329,7 +329,7 @@ func UpdateDeployment(kubeClientSet kubernetes.Interface, namespace string, name
|
|||
}
|
||||
|
||||
if *deployment.Spec.Replicas != int32(replicas) {
|
||||
glog.Infof("updating replica count from %v to %v...", *deployment.Spec.Replicas, replicas)
|
||||
klog.Infof("updating replica count from %v to %v...", *deployment.Spec.Replicas, replicas)
|
||||
deployment, err := kubeClientSet.AppsV1beta1().Deployments(namespace).Get(name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in a new issue