Merge pull request #98939 from yangjunmyfm192085/run-test16
Structured Logging migration: modify dockershim and network part logs of kubelet.
This commit is contained in:
@@ -123,7 +123,7 @@ func (c *Configurer) formDNSSearchFitsLimits(composedSearch []string, pod *v1.Po
|
||||
if limitsExceeded {
|
||||
log := fmt.Sprintf("Search Line limits were exceeded, some search paths have been omitted, the applied search line is: %s", strings.Join(composedSearch, " "))
|
||||
c.recorder.Event(pod, v1.EventTypeWarning, "DNSConfigForming", log)
|
||||
klog.Error(log)
|
||||
klog.ErrorS(nil, "eventlog", log)
|
||||
}
|
||||
return composedSearch
|
||||
}
|
||||
@@ -133,7 +133,7 @@ func (c *Configurer) formDNSNameserversFitsLimits(nameservers []string, pod *v1.
|
||||
nameservers = nameservers[0:validation.MaxDNSNameservers]
|
||||
log := fmt.Sprintf("Nameserver limits were exceeded, some nameservers have been omitted, the applied nameserver line is: %s", strings.Join(nameservers, " "))
|
||||
c.recorder.Event(pod, v1.EventTypeWarning, "DNSConfigForming", log)
|
||||
klog.Error(log)
|
||||
klog.ErrorS(nil, "eventlog", log)
|
||||
}
|
||||
return nameservers
|
||||
}
|
||||
@@ -161,7 +161,7 @@ func (c *Configurer) CheckLimitsForResolvConf() {
|
||||
f, err := os.Open(c.ResolverConfig)
|
||||
if err != nil {
|
||||
c.recorder.Event(c.nodeRef, v1.EventTypeWarning, "CheckLimitsForResolvConf", err.Error())
|
||||
klog.V(4).Infof("Check limits for resolv.conf failed at file open: %v", err)
|
||||
klog.V(4).InfoS("Check limits for resolv.conf failed at file open", "err", err)
|
||||
return
|
||||
}
|
||||
defer f.Close()
|
||||
@@ -169,7 +169,7 @@ func (c *Configurer) CheckLimitsForResolvConf() {
|
||||
_, hostSearch, _, err := parseResolvConf(f)
|
||||
if err != nil {
|
||||
c.recorder.Event(c.nodeRef, v1.EventTypeWarning, "CheckLimitsForResolvConf", err.Error())
|
||||
klog.V(4).Infof("Check limits for resolv.conf failed at parse resolv.conf: %v", err)
|
||||
klog.V(4).InfoS("Check limits for resolv.conf failed at parse resolv.conf", "err", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -182,14 +182,14 @@ func (c *Configurer) CheckLimitsForResolvConf() {
|
||||
if len(hostSearch) > domainCountLimit {
|
||||
log := fmt.Sprintf("Resolv.conf file '%s' contains search line consisting of more than %d domains!", c.ResolverConfig, domainCountLimit)
|
||||
c.recorder.Event(c.nodeRef, v1.EventTypeWarning, "CheckLimitsForResolvConf", log)
|
||||
klog.V(4).Infof("Check limits for resolv.conf failed: %s", log)
|
||||
klog.V(4).InfoS("Check limits for resolv.conf failed", "eventlog", log)
|
||||
return
|
||||
}
|
||||
|
||||
if len(strings.Join(hostSearch, " ")) > validation.MaxDNSSearchListChars {
|
||||
log := fmt.Sprintf("Resolv.conf file '%s' contains search line which length is more than allowed %d chars!", c.ResolverConfig, validation.MaxDNSSearchListChars)
|
||||
c.recorder.Event(c.nodeRef, v1.EventTypeWarning, "CheckLimitsForResolvConf", log)
|
||||
klog.V(4).Infof("Check limits for resolv.conf failed: %s", log)
|
||||
klog.V(4).InfoS("Check limits for resolv.conf failed", "eventlog", log)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -337,7 +337,7 @@ func (c *Configurer) GetPodDNS(pod *v1.Pod) (*runtimeapi.DNSConfig, error) {
|
||||
|
||||
dnsType, err := getPodDNSType(pod)
|
||||
if err != nil {
|
||||
klog.Errorf("Failed to get DNS type for pod %q: %v. Falling back to DNSClusterFirst policy.", format.Pod(pod), err)
|
||||
klog.ErrorS(err, "Failed to get DNS type for pod. Falling back to DNSClusterFirst policy.", "pod", klog.KObj(pod))
|
||||
dnsType = podDNSCluster
|
||||
}
|
||||
switch dnsType {
|
||||
@@ -404,12 +404,12 @@ func (c *Configurer) SetupDNSinContainerizedMounter(mounterPath string) {
|
||||
if c.ResolverConfig != "" {
|
||||
f, err := os.Open(c.ResolverConfig)
|
||||
if err != nil {
|
||||
klog.Error("Could not open resolverConf file")
|
||||
klog.ErrorS(err, "Could not open resolverConf file")
|
||||
} else {
|
||||
defer f.Close()
|
||||
_, hostSearch, _, err := parseResolvConf(f)
|
||||
if err != nil {
|
||||
klog.Errorf("Error for parsing the resolv.conf file: %v", err)
|
||||
klog.ErrorS(err, "Error for parsing the resolv.conf file")
|
||||
} else {
|
||||
dnsString = dnsString + "search"
|
||||
for _, search := range hostSearch {
|
||||
@@ -420,6 +420,6 @@ func (c *Configurer) SetupDNSinContainerizedMounter(mounterPath string) {
|
||||
}
|
||||
}
|
||||
if err := ioutil.WriteFile(resolvePath, []byte(dnsString), 0600); err != nil {
|
||||
klog.Errorf("Could not write dns nameserver in file %s, with error %v", resolvePath, err)
|
||||
klog.ErrorS(err, "Could not write dns nameserver in the file", "path", resolvePath)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user