Migrated proxier_health.go , proxier.go to structured logging (#105767)

* fixed improperly migrated logs

* Update pkg/proxy/winkernel/proxier.go

Co-authored-by: Marek Siarkowicz <marek.siarkowicz@protonmail.com>

Co-authored-by: Marek Siarkowicz <marek.siarkowicz@protonmail.com>
This commit is contained in:
Shivanshu Raj Shrivastava 2021-10-21 22:47:48 +05:30 committed by GitHub
parent c767c9d993
commit d3350f45e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 28 deletions

View File

@ -104,7 +104,7 @@ func (hs *proxierHealthServer) Run() error {
return fmt.Errorf("%v", msg)
}
klog.V(3).Infof("starting healthz on %s", hs.addr)
klog.V(3).InfoS("Starting healthz HTTP server", "address", hs.addr)
if err := server.Serve(listener); err != nil {
return fmt.Errorf("proxier healthz closed with error: %v", err)

View File

@ -149,7 +149,7 @@ func newHostNetworkService() (HostNetworkService, hcn.SupportedFeatures) {
func getNetworkName(hnsNetworkName string) (string, error) {
if len(hnsNetworkName) == 0 {
klog.V(3).InfoS("network-name flag not set, checking environment variable")
klog.V(3).InfoS("Flag --network-name not set, checking environment variable")
hnsNetworkName = os.Getenv("KUBE_NETWORK")
if len(hnsNetworkName) == 0 {
return "", fmt.Errorf("Environment variable KUBE_NETWORK and network-flag not initialized")
@ -320,11 +320,11 @@ func (proxier *Proxier) onEndpointsMapChange(svcPortName *proxy.ServicePortName)
svcInfo, ok := svc.(*serviceInfo)
if !ok {
klog.ErrorS(nil, "Failed to cast serviceInfo", "svcPortName", svcPortName.String())
klog.ErrorS(nil, "Failed to cast serviceInfo", "servicePortName", svcPortName)
return
}
klog.V(3).InfoS("Endpoints are modified. Service is stale", "svcPortName", svcPortName.String())
klog.V(3).InfoS("Endpoints are modified. Service is stale", "servicePortName", svcPortName)
svcInfo.cleanupAllPolicies(proxier.endpointsMap[*svcPortName])
} else {
// If no service exists, just cleanup the remote endpoints
@ -367,11 +367,11 @@ func (proxier *Proxier) onServiceMapChange(svcPortName *proxy.ServicePortName) {
svcInfo, ok := svc.(*serviceInfo)
if !ok {
klog.ErrorS(nil, "Failed to cast serviceInfo", "svcPortName", svcPortName.String())
klog.ErrorS(nil, "Failed to cast serviceInfo", "servicePortName", svcPortName)
return
}
klog.V(3).InfoS("Updating existing service port", "svcPortName", svcPortName.String(), "clusterIP", svcInfo.ClusterIP(), "port", svcInfo.Port(), "protocol", svcInfo.Protocol())
klog.V(3).InfoS("Updating existing service port", "servicePortName", svcPortName, "clusterIP", svcInfo.ClusterIP(), "port", svcInfo.Port(), "protocol", svcInfo.Protocol())
svcInfo.cleanupAllPolicies(proxier.endpointsMap[*svcPortName])
}
}
@ -426,7 +426,7 @@ func (ep *endpointsInfo) Cleanup() {
// Never delete a Local Endpoint. Local Endpoints are already created by other entities.
// Remove only remote endpoints created by this service
if *ep.refCount <= 0 && !ep.GetIsLocal() {
klog.V(4).InfoS("Removing endpoints, since no one is referencing it", "endpoint", ep.String())
klog.V(4).InfoS("Removing endpoints, since no one is referencing it", "endpoint", ep)
err := ep.hns.deleteEndpoint(ep.hnsID)
if err == nil {
ep.hnsID = ""
@ -598,12 +598,12 @@ func NewProxier(
masqueradeMark := fmt.Sprintf("%#08x/%#08x", masqueradeValue, masqueradeValue)
if nodeIP == nil {
klog.InfoS("invalid nodeIP, initializing kube-proxy with 127.0.0.1 as nodeIP")
klog.InfoS("Invalid nodeIP, initializing kube-proxy with 127.0.0.1 as nodeIP")
nodeIP = netutils.ParseIPSloppy("127.0.0.1")
}
if len(clusterCIDR) == 0 {
klog.InfoS("clusterCIDR not specified, unable to distinguish between internal and external traffic")
klog.InfoS("ClusterCIDR not specified, unable to distinguish between internal and external traffic")
}
serviceHealthServer := healthcheck.NewServiceHealthServer(hostname, recorder, []string{} /* windows listen to all node addresses */)
@ -659,10 +659,10 @@ func NewProxier(
if nodeIP.IsUnspecified() {
// attempt to get the correct ip address
klog.V(2).InfoS("node ip was unspecified, attempting to find node ip")
klog.V(2).InfoS("Node ip was unspecified, attempting to find node ip")
nodeIP, err = apiutil.ResolveBindAddress(nodeIP)
if err != nil {
klog.InfoS("failed to find an ip. You may need set the --bind-address flag", "err", err)
klog.InfoS("Failed to find an ip. You may need set the --bind-address flag", "err", err)
}
}
@ -672,7 +672,7 @@ func NewProxier(
for _, addr := range addresses {
addrIP, _, _ := netutils.ParseCIDRSloppy(addr.String())
if addrIP.String() == nodeIP.String() {
klog.V(2).InfoS("record Host MAC address", "addr", inter.HardwareAddr.String())
klog.V(2).InfoS("Record Host MAC address", "addr", inter.HardwareAddr)
hostMac = inter.HardwareAddr.String()
}
}
@ -714,7 +714,7 @@ func NewProxier(
proxier.serviceChanges = serviceChanges
burstSyncs := 2
klog.V(3).InfoS("record sync param", "minSyncPeriod", minSyncPeriod, "syncPeriod", syncPeriod, "burstSyncs", burstSyncs)
klog.V(3).InfoS("Record sync param", "minSyncPeriod", minSyncPeriod, "syncPeriod", syncPeriod, "burstSyncs", burstSyncs)
proxier.syncRunner = async.NewBoundedFrequencyRunner("sync-runner", proxier.syncProxyRules, minSyncPeriod, syncPeriod, burstSyncs)
return proxier, nil
}
@ -895,12 +895,12 @@ func (proxier *Proxier) OnServiceSynced() {
func shouldSkipService(svcName types.NamespacedName, service *v1.Service) bool {
// if ClusterIP is "None" or empty, skip proxying
if !helper.IsServiceIPSet(service) {
klog.V(3).InfoS("Skipping service due to clusterIP", "svcName", svcName.String(), "clusterIP", service.Spec.ClusterIP)
klog.V(3).InfoS("Skipping service due to clusterIP", "serviceName", svcName, "clusterIP", service.Spec.ClusterIP)
return true
}
// Even if ClusterIP is set, ServiceTypeExternalName services don't get proxied
if service.Spec.Type == v1.ServiceTypeExternalName {
klog.V(3).InfoS("Skipping service due to Type=ExternalName", "svcName", svcName.String())
klog.V(3).InfoS("Skipping service due to Type=ExternalName", "serviceName", svcName)
return true
}
return false
@ -946,7 +946,7 @@ func (proxier *Proxier) cleanupAllPolicies() {
for svcName, svc := range proxier.serviceMap {
svcInfo, ok := svc.(*serviceInfo)
if !ok {
klog.ErrorS(nil, "Failed to cast serviceInfo", "svcName", svcName.String())
klog.ErrorS(nil, "Failed to cast serviceInfo", "serviceName", svcName)
continue
}
svcInfo.cleanupAllPolicies(proxier.endpointsMap[svcName])
@ -975,7 +975,7 @@ func (proxier *Proxier) syncProxyRules() {
start := time.Now()
defer func() {
SyncProxyRulesLatency.Observe(metrics.SinceInSeconds(start))
klog.V(4).InfoS("syncProxyRules complete", "elapsed", time.Since(start))
klog.V(4).InfoS("Syncing proxy rules complete", "elapsed", time.Since(start))
}()
// don't sync rules till we've received services and endpoints
if !proxier.isInitialized() {
@ -1007,7 +1007,7 @@ func (proxier *Proxier) syncProxyRules() {
// merge stale services gathered from updateEndpointsMap
for _, svcPortName := range endpointUpdateResult.StaleServiceNames {
if svcInfo, ok := proxier.serviceMap[svcPortName]; ok && svcInfo != nil && svcInfo.Protocol() == v1.ProtocolUDP {
klog.V(2).InfoS("Stale udp service", "svcPortName", svcPortName.String(), "clusterIP", svcInfo.ClusterIP().String())
klog.V(2).InfoS("Stale udp service", "servicePortName", svcPortName, "clusterIP", svcInfo.ClusterIP())
staleServices.Insert(svcInfo.ClusterIP().String())
}
}
@ -1029,7 +1029,7 @@ func (proxier *Proxier) syncProxyRules() {
for svcName, svc := range proxier.serviceMap {
svcInfo, ok := svc.(*serviceInfo)
if !ok {
klog.ErrorS(nil, "Failed to cast serviceInfo", "svcName", svcName.String())
klog.ErrorS(nil, "Failed to cast serviceInfo", "serviceName", svcName)
continue
}
@ -1041,7 +1041,7 @@ func (proxier *Proxier) syncProxyRules() {
if strings.EqualFold(proxier.network.networkType, NETWORK_TYPE_OVERLAY) {
serviceVipEndpoint, _ := hns.getEndpointByIpAddress(svcInfo.ClusterIP().String(), hnsNetworkName)
if serviceVipEndpoint == nil {
klog.V(4).InfoS("No existing remote endpoint", "ip", svcInfo.ClusterIP().String())
klog.V(4).InfoS("No existing remote endpoint", "IP", svcInfo.ClusterIP())
hnsEndpoint := &endpointsInfo{
ip: svcInfo.ClusterIP().String(),
isLocal: false,
@ -1063,7 +1063,7 @@ func (proxier *Proxier) syncProxyRules() {
var hnsEndpoints []endpointsInfo
var hnsLocalEndpoints []endpointsInfo
klog.V(4).InfoS("Applying Policy", "serviceInfo", svcName.String())
klog.V(4).InfoS("Applying Policy", "serviceInfo", svcName)
// Create Remote endpoints for every endpoint, corresponding to the service
containsPublicIP := false
containsNodeIP := false
@ -1071,7 +1071,7 @@ func (proxier *Proxier) syncProxyRules() {
for _, epInfo := range proxier.endpointsMap[svcName] {
ep, ok := epInfo.(*endpointsInfo)
if !ok {
klog.ErrorS(nil, "Failed to cast endpointsInfo", "svcName", svcName.String())
klog.ErrorS(nil, "Failed to cast endpointsInfo", "serviceName", svcName)
continue
}
@ -1118,7 +1118,7 @@ func (proxier *Proxier) syncProxyRules() {
proxier.network = *updatedNetwork
providerAddress := proxier.network.findRemoteSubnetProviderAddress(ep.IP())
if len(providerAddress) == 0 {
klog.InfoS("Could not find provider address, assuming it is a public IP", "ip", ep.IP())
klog.InfoS("Could not find provider address, assuming it is a public IP", "IP", ep.IP())
providerAddress = proxier.nodeIP.String()
}
@ -1189,7 +1189,7 @@ func (proxier *Proxier) syncProxyRules() {
klog.V(3).InfoS("Endpoint resource found", "endpointsInfo", ep)
}
klog.V(3).InfoS("Associated endpoints for service", "endpointsInfo", hnsEndpoints, "svcName", svcName.String())
klog.V(3).InfoS("Associated endpoints for service", "endpointsInfo", hnsEndpoints, "serviceName", svcName)
if len(svcInfo.hnsID) > 0 {
// This should not happen
@ -1197,11 +1197,11 @@ func (proxier *Proxier) syncProxyRules() {
}
if len(hnsEndpoints) == 0 {
klog.ErrorS(nil, "Endpoint information not available for service, not applying any policy", "svcName", svcName.String())
klog.ErrorS(nil, "Endpoint information not available for service, not applying any policy", "serviceName", svcName)
continue
}
klog.V(4).Infof("Trying to apply Policies for service", "serviceInfo", svcInfo)
klog.V(4).InfoS("Trying to apply Policies for service", "serviceInfo", svcInfo)
var hnsLoadBalancer *loadBalancerInfo
var sourceVip = proxier.sourceVip
if containsPublicIP || containsNodeIP {
@ -1210,7 +1210,7 @@ func (proxier *Proxier) syncProxyRules() {
sessionAffinityClientIP := svcInfo.SessionAffinityType() == v1.ServiceAffinityClientIP
if sessionAffinityClientIP && !proxier.supportedFeatures.SessionAffinity {
klog.InfoS("Session Affinity is not supported on this version of Windows.")
klog.InfoS("Session Affinity is not supported on this version of Windows")
}
hnsLoadBalancer, err := hns.getLoadBalancer(
@ -1326,7 +1326,7 @@ func (proxier *Proxier) syncProxyRules() {
// TODO: these could be made more consistent.
for _, svcIP := range staleServices.UnsortedList() {
// TODO : Check if this is required to cleanup stale services here
klog.V(5).InfoS("Pending delete stale service IP connections", "ip", svcIP)
klog.V(5).InfoS("Pending delete stale service IP connections", "IP", svcIP)
}
// remove stale endpoint refcount entries