mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #83896 from mars1024/modify/cni_log
modify error output in cniNetworkPlugin
This commit is contained in:
commit
3202bc1044
@ -191,7 +191,7 @@ func getDefaultCNINetwork(confDir string, binDirs []string) (*cniNetwork, error)
|
||||
}
|
||||
}
|
||||
if len(confList.Plugins) == 0 {
|
||||
klog.Warningf("CNI config list %s has no networks, skipping", confFile)
|
||||
klog.Warningf("CNI config list %s has no networks, skipping", string(confList.Bytes[:maxStringLengthInLog(len(confList.Bytes))]))
|
||||
continue
|
||||
}
|
||||
|
||||
@ -199,7 +199,7 @@ func getDefaultCNINetwork(confDir string, binDirs []string) (*cniNetwork, error)
|
||||
// all plugins of this config exist on disk
|
||||
caps, err := cniConfig.ValidateNetworkList(context.TODO(), confList)
|
||||
if err != nil {
|
||||
klog.Warningf("Error validating CNI config %v: %v", confList, err)
|
||||
klog.Warningf("Error validating CNI config list %s: %v", string(confList.Bytes[:maxStringLengthInLog(len(confList.Bytes))]), err)
|
||||
continue
|
||||
}
|
||||
|
||||
@ -462,3 +462,13 @@ func (plugin *cniNetworkPlugin) buildCNIRuntimeConf(podName string, podNs string
|
||||
|
||||
return rt, nil
|
||||
}
|
||||
|
||||
func maxStringLengthInLog(length int) int {
|
||||
// we allow no more than 4096-length strings to be logged
|
||||
const maxStringLength = 4096
|
||||
|
||||
if length < maxStringLength {
|
||||
return length
|
||||
}
|
||||
return maxStringLength
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user