mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-09 13:12:20 +00:00
Clean up error logs.
Use %v for errors, tidy some messages, make error messages start lowe-case (as per go guidelines). Just accumulated nits.
This commit is contained in:
@@ -135,7 +135,7 @@ func (s ConfigSourceEtcd) decodeServices(node *etcd.Node, retServices []api.Serv
|
||||
var svc api.Service
|
||||
err := latest.Codec.DecodeInto([]byte(node.Value), &svc)
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to load Service: %s (%#v)", node.Value, err)
|
||||
glog.Errorf("Failed to load Service: %s (%v)", node.Value, err)
|
||||
} else {
|
||||
// so we got a service we can handle, and now get endpoints
|
||||
retServices = append(retServices, svc)
|
||||
@@ -182,7 +182,7 @@ func (s ConfigSourceEtcd) GetEndpoints(namespace, service string) (api.Endpoints
|
||||
key := path.Join(registryRoot, "endpoints", namespace, service)
|
||||
response, err := s.client.Get(key, true, false)
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to get the key: %s %v", key, err)
|
||||
glog.Errorf("Failed to get the key %q: %v", key, err)
|
||||
return api.Endpoints{}, err
|
||||
}
|
||||
// Parse all the endpoint specifications in this value.
|
||||
@@ -256,7 +256,7 @@ func (s ConfigSourceEtcd) ProcessEndpointResponse(response *etcd.Response) {
|
||||
var endpoints api.Endpoints
|
||||
err := latest.Codec.DecodeInto([]byte(response.Node.Value), &endpoints)
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to parse service out of etcd key: %v : %+v", response.Node.Value, err)
|
||||
glog.Errorf("Failed to parse service out of etcd key: %v : %v", response.Node.Value, err)
|
||||
return
|
||||
}
|
||||
endpointsUpdate := EndpointsUpdate{Op: ADD, Endpoints: []api.Endpoints{endpoints}}
|
||||
|
@@ -82,7 +82,7 @@ func tryConnect(service string, srcAddr net.Addr, protocol string, proxier *Prox
|
||||
for _, retryTimeout := range endpointDialTimeout {
|
||||
endpoint, err := proxier.loadBalancer.NextEndpoint(service, srcAddr)
|
||||
if err != nil {
|
||||
glog.Errorf("Couldn't find an endpoint for %s %v", service, err)
|
||||
glog.Errorf("Couldn't find an endpoint for %s: %v", service, err)
|
||||
return nil, err
|
||||
}
|
||||
glog.V(3).Infof("Mapped service %q to endpoint %s", service, endpoint)
|
||||
@@ -296,7 +296,7 @@ func newProxySocket(protocol api.Protocol, ip net.IP, port int) (proxySocket, er
|
||||
}
|
||||
return &udpProxySocket{conn}, nil
|
||||
}
|
||||
return nil, fmt.Errorf("Unknown protocol %q", protocol)
|
||||
return nil, fmt.Errorf("unknown protocol %q", protocol)
|
||||
}
|
||||
|
||||
// Proxier is a simple proxy for TCP connections between a localhost:lport
|
||||
@@ -316,13 +316,13 @@ func NewProxier(loadBalancer LoadBalancer, listenAddress net.IP, iptables iptabl
|
||||
glog.Infof("Initializing iptables")
|
||||
// Set up the iptables foundations we need.
|
||||
if err := iptablesInit(iptables); err != nil {
|
||||
glog.Errorf("Failed to initialize iptables: %s", err)
|
||||
glog.Errorf("Failed to initialize iptables: %v", err)
|
||||
return nil
|
||||
}
|
||||
// Flush old iptables rules (since the bound ports will be invalid after a restart).
|
||||
// When OnUpdate() is first called, the rules will be recreated.
|
||||
if err := iptablesFlush(iptables); err != nil {
|
||||
glog.Errorf("Failed to flush iptables: %s", err)
|
||||
glog.Errorf("Failed to flush iptables: %v", err)
|
||||
return nil
|
||||
}
|
||||
return &Proxier{
|
||||
@@ -343,7 +343,7 @@ func (proxier *Proxier) SyncLoop() {
|
||||
case <-time.After(syncInterval):
|
||||
glog.V(2).Infof("Periodic sync")
|
||||
if err := iptablesInit(proxier.iptables); err != nil {
|
||||
glog.Errorf("Failed to ensure iptables: %s", err)
|
||||
glog.Errorf("Failed to ensure iptables: %v", err)
|
||||
}
|
||||
proxier.ensurePortals()
|
||||
}
|
||||
@@ -358,7 +358,7 @@ func (proxier *Proxier) ensurePortals() {
|
||||
for name, info := range proxier.serviceMap {
|
||||
err := proxier.openPortal(name, info)
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to ensure portal for %q: %s", name, err)
|
||||
glog.Errorf("Failed to ensure portal for %q: %v", name, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -449,17 +449,17 @@ func (proxier *Proxier) OnUpdate(services []api.Service) {
|
||||
glog.V(4).Infof("Something changed for service %q: stopping it", service.Name)
|
||||
err := proxier.closePortal(service.Name, info)
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to close portal for %q: %s", service.Name, err)
|
||||
glog.Errorf("Failed to close portal for %q: %v", service.Name, err)
|
||||
}
|
||||
err = proxier.stopProxy(service.Name, info)
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to stop service %q: %s", service.Name, err)
|
||||
glog.Errorf("Failed to stop service %q: %v", service.Name, err)
|
||||
}
|
||||
}
|
||||
glog.V(1).Infof("Adding new service %q at %s:%d/%s (local :%d)", service.Name, serviceIP, service.Spec.Port, service.Spec.Protocol, service.Spec.ProxyPort)
|
||||
info, err := proxier.addServiceOnPort(service.Name, service.Spec.Protocol, service.Spec.ProxyPort, udpIdleTimeout)
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to start proxy for %q: %+v", service.Name, err)
|
||||
glog.Errorf("Failed to start proxy for %q: %v", service.Name, err)
|
||||
continue
|
||||
}
|
||||
info.portalIP = serviceIP
|
||||
@@ -469,7 +469,7 @@ func (proxier *Proxier) OnUpdate(services []api.Service) {
|
||||
}
|
||||
err = proxier.openPortal(service.Name, info)
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to open portal for %q: %s", service.Name, err)
|
||||
glog.Errorf("Failed to open portal for %q: %v", service.Name, err)
|
||||
}
|
||||
}
|
||||
proxier.mu.Lock()
|
||||
@@ -479,11 +479,11 @@ func (proxier *Proxier) OnUpdate(services []api.Service) {
|
||||
glog.V(1).Infof("Stopping service %q", name)
|
||||
err := proxier.closePortal(name, info)
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to close portal for %q: %s", name, err)
|
||||
glog.Errorf("Failed to close portal for %q: %v", name, err)
|
||||
}
|
||||
err = proxier.stopProxyInternal(name, info)
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to stop service %q: %s", name, err)
|
||||
glog.Errorf("Failed to stop service %q: %v", name, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ func (r *udpEchoServer) Loop() {
|
||||
for {
|
||||
n, cliAddr, err := r.ReadFrom(buffer[0:])
|
||||
if err != nil {
|
||||
fmt.Printf("ReadFrom failed: %#v\n", err)
|
||||
fmt.Printf("ReadFrom failed: %v\n", err)
|
||||
continue
|
||||
}
|
||||
r.WriteTo(buffer[0:n], cliAddr)
|
||||
|
Reference in New Issue
Block a user