Skip to content

Commit

Permalink
sysdump: Check both stdout and stderr for bugtool archive name
Browse files Browse the repository at this point in the history
Cilium v1.8 writes the archive name to stdout.

Signed-off-by: Michi Mutsuzaki <[email protected]>
  • Loading branch information
michi-covalent authored and tklauser committed Nov 9, 2021
1 parent 1ab3bbd commit 9e0c942
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sysdump/sysdump.go
Original file line number Diff line number Diff line change
Expand Up @@ -889,14 +889,15 @@ func (c *Collector) submitBugtoolTasks(ctx context.Context, pods []*corev1.Pod,
// Run 'cilium-bugtool' in the pod.
command := append([]string{ciliumBugtoolCommand}, c.Options.CiliumBugtoolFlags...)
c.logDebug("Executing cilium-bugtool command: %v", command)
_, e, err := c.Client.ExecInPodWithStderr(ctx, p.Namespace, p.Name, containerName, command)
o, e, err := c.Client.ExecInPodWithStderr(ctx, p.Namespace, p.Name, containerName, command)
if err != nil {
return fmt.Errorf("failed to collect 'cilium-bugtool' output for %q in namespace %q: %w: %s", p.Name, p.Namespace, err, e.String())
}
// Capture the path to the resulting archive.
m := ciliumBugtoolFileNameRegex.FindStringSubmatch(e.String())
outString := o.String() + e.String()
m := ciliumBugtoolFileNameRegex.FindStringSubmatch(outString)
if len(m) != 2 || len(m[1]) == 0 {
return fmt.Errorf("failed to collect 'cilium-bugtool' output for %q in namespace %q: output doesn't contain archive name", p.Name, p.Namespace)
return fmt.Errorf("failed to collect 'cilium-bugtool' output for %q in namespace %q: output doesn't contain archive name: %s", p.Name, p.Namespace, outString)
}
// Grab the resulting archive's contents from the pod.
b, err := c.Client.ExecInPod(ctx, p.Namespace, p.Name, containerName, []string{"cat", m[1]})
Expand Down

0 comments on commit 9e0c942

Please sign in to comment.