Skip to content

Conversation

giorio94
Copy link
Member

Currently, hubble flows collection in sysdumps relies on the timeout command to set an upper bound on the maximum retrieval time. This is mostly due to historical reasons, as hubble flows used to be collected using the --follow flag. Yet, that is no longer the case since [1], even though the timeout was kept as a safety measure.

Let's slightly rework this logic to specify the timeout via the context, rather than relying on the timeout command, to avoid requiring it to be present in the target Cilium agent image. We don't use the so-called kill context here, because that would set tty, which in turn coalescences the stdout and stderr streams together [2], which is undesired.

While being there, let's also drop the bash indirection, and directly invoke the hubble binary.

[1]: cfc594f ("sysdump: don't specify --follow while collecting hubble flows")
[2]:

// StreamWithContext initiates the transport of the standard shell streams. It will
// transport any non-nil stream to a remote system, and return an error if a problem
// occurs. If tty is set, the stderr stream is not used (raw TTY manages stdout and
// stderr over the stdout stream).
// The context controls the entire lifetime of stream execution.
StreamWithContext(ctx context.Context, options StreamOptions) error

Currently, hubble flows collection in sysdumps relies on the timeout
command to set an upper bound on the maximum retrieval time. This is
mostly due to historical reasons, as hubble flows used to be collected
using the --follow flag. Yet, that is no longer the case since [1],
even though the timeout was kept as a safety measure.

Let's slightly rework this logic to specify the timeout via the context,
rather than relying on the timeout command, to avoid requiring it to
be present in the target Cilium agent image. We don't use the so-called
kill context here, because that would set tty, which in turn coalescences
the stdout and stderr streams together [2], which is undesired.

While being there, let's also drop the bash indirection, and directly
invoke the hubble binary.

[1]: cfc594f ("sysdump: don't specify --follow while collecting hubble flows")
[2]: https://github.com/cilium/cilium/blob/21a15af2b0a951ba09432337de6aba2e8e6c0da3/vendor/k8s.io/client-go/tools/remotecommand/remotecommand.go#L44-L49

Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
@giorio94 giorio94 added release-note/misc This PR makes changes that have no direct user impact. cilium-cli This PR contains changes related with cilium-cli labels Apr 17, 2025
@giorio94 giorio94 requested a review from a team as a code owner April 17, 2025 09:50
@giorio94 giorio94 requested a review from nathanjsweet April 17, 2025 09:50
@giorio94
Copy link
Member Author

/test

@github-actions github-actions bot added the cilium-cli-exclusive This PR only impacts cilium-cli binary label Apr 17, 2025
@giorio94 giorio94 enabled auto-merge April 17, 2025 14:37
@giorio94 giorio94 added this pull request to the merge queue Apr 17, 2025
@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Apr 17, 2025
Merged via the queue into cilium:main with commit 987e240 Apr 17, 2025
73 checks passed
@giorio94 giorio94 deleted the mio/sysdump-hubble-flows branch April 17, 2025 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cilium-cli This PR contains changes related with cilium-cli cilium-cli-exclusive This PR only impacts cilium-cli binary ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants