mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-18 16:21:13 +00:00
podlogs: include node name in prefix
This is useful for logs from daemonset pods because for those it is often relevant which node they ran on because they interact with resources or other pods on the host. To keep the log prefix short, it gets limited to a maximum length of 10 characters.
This commit is contained in:
parent
3ed0f1bec1
commit
0ec85320cf
@ -133,7 +133,11 @@ func CopyAllLogs(ctx context.Context, cs clientset.Interface, ns string, to LogO
|
||||
var prefix string
|
||||
if to.LogWriter != nil {
|
||||
out = to.LogWriter
|
||||
prefix = name + ": "
|
||||
nodeName := pod.Spec.NodeName
|
||||
if len(nodeName) > 10 {
|
||||
nodeName = nodeName[0:4] + ".." + nodeName[len(nodeName)-4:]
|
||||
}
|
||||
prefix = name + "@" + nodeName + ": "
|
||||
} else {
|
||||
var err error
|
||||
filename := to.LogPathPrefix + pod.ObjectMeta.Name + "-" + c.Name + ".log"
|
||||
|
Loading…
Reference in New Issue
Block a user