Commit 395186b
cilium-cli: Fix CNI config file collection in sysdump
The SubmitCniConflistSubtask function was failing when listing CNI
config files because strings.SplitSeq can yield empty strings from
trailing newlines in the 'ls' command output. When an empty filename
is passed to path.Join with the directory path, it returns just the
directory path, and attempting to 'cat' a directory results in an error:
failed to copy CNI config file "" from directory "/etc/cni/net.d/":
command terminated with exit code 1: "/usr/bin/cat: /etc/cni/net.d: Is a directory"
This fix adds a check to skip empty filenames before attempting to
copy CNI config files, preventing the error while still collecting
all valid CNI configuration files.
Additionally, use 'ls -1' to ensure one file per line output regardless
of terminal width, which is important when multiple CNI config files
exist in the directory.
Fixes: cilium#41833
Signed-off-by: Ashwin Pillai <pillaiashwin96@gmail.com>1 parent 0532a11 commit 395186b
1 file changed
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2569 | 2569 | | |
2570 | 2570 | | |
2571 | 2571 | | |
| 2572 | + | |
2572 | 2573 | | |
2573 | 2574 | | |
2574 | 2575 | | |
2575 | 2576 | | |
2576 | 2577 | | |
2577 | 2578 | | |
| 2579 | + | |
| 2580 | + | |
| 2581 | + | |
| 2582 | + | |
2578 | 2583 | | |
2579 | 2584 | | |
2580 | 2585 | | |
| |||
0 commit comments