Skip to content

Commit 0ec8532

Browse files
committed
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.
1 parent 3ed0f1b commit 0ec8532

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

test/e2e/framework/podlogs/podlogs.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,11 @@ func CopyAllLogs(ctx context.Context, cs clientset.Interface, ns string, to LogO
133133
var prefix string
134134
if to.LogWriter != nil {
135135
out = to.LogWriter
136-
prefix = name + ": "
136+
nodeName := pod.Spec.NodeName
137+
if len(nodeName) > 10 {
138+
nodeName = nodeName[0:4] + ".." + nodeName[len(nodeName)-4:]
139+
}
140+
prefix = name + "@" + nodeName + ": "
137141
} else {
138142
var err error
139143
filename := to.LogPathPrefix + pod.ObjectMeta.Name + "-" + c.Name + ".log"

0 commit comments

Comments
 (0)