Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/record: Add stop condition flags #607

Merged
merged 2 commits into from
Aug 11, 2021

Conversation

gandro
Copy link
Member

@gandro gandro commented Aug 11, 2021

This adds three new flags to the hubble record subcommand:

  • packet-limit: Stops the recording after a specified number of
    packets have been recorded.
  • bytes-limit: Stops the recording after a specified number of
    bytes have been recorded.
  • time-limit: Stops the recording after a specified duration
    has elapsed.

The first limit to hit will stop the recording. If none of the three
flags are specified, then the recording needs to be stopped manually.

These flags are only supported by Cilium master at the moment, see
cilium/cilium#16473 for the API implementation.

@gandro gandro added the release-note/minor This PR introduces functionality that users may find relevant to operating Hubble. label Aug 11, 2021
@gandro gandro requested a review from a team August 11, 2021 17:53
@gandro gandro requested a review from a team as a code owner August 11, 2021 17:53
@gandro gandro requested review from joamaki and rolinh and removed request for a team August 11, 2021 17:53
Copy link
Collaborator

@michi-covalent michi-covalent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

This pulls in the Hubble API definitions from
cilium/cilium#16473

Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
This adds three new flags to the `hubble record` subcommand:

 - `packet-limit`: Stops the recording after a specified number of
   packets have been recorded.
 - `bytes-limit`: Stops the recording after a specified number of
   bytes have been recorded.
 - `time-limit`: Stops the recording after a specified duration
   has elapsed.

The first limit to hit will stop the recording. If none of the three
flags are specified, then the recording needs to be stopped manually.

Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
@gandro gandro force-pushed the pr/gandro/recorder-stop-condition branch from e2245b3 to 6722b09 Compare August 11, 2021 18:00
@@ -80,6 +86,10 @@ protocols are TCP, UDP and ANY.`,
recorderFlags.StringVar(&fileSinkPrefix, "file-prefix", "hubble", "File prefix of the resulting pcap file")
recorderFlags.Uint32Var(&maxCaptureLength, "max-capture-len", 0, "Sets the maximum capture length (zero for full capture)")

recorderFlags.Uint64Var(&packetLimit, "packet-limit", 0, "Sets a limit on how many packets to capture on each node")
recorderFlags.Uint64Var(&bytesLimit, "bytes-limit", 0, "Sets a limit on how many bytes to capture on each node")
recorderFlags.DurationVar(&timeLimit, "time-limit", 0, "Sets a limit on how long to capture on each node")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this do the relative nifty things like 10s, 5m etc?

Copy link
Member Author

@gandro gandro Aug 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. This is using the same mechanism as --since

Duration flags accept any input valid for time.ParseDuration.
https://pkg.go.dev/flag

@michi-covalent michi-covalent merged commit dd15fbd into master Aug 11, 2021
@michi-covalent michi-covalent deleted the pr/gandro/recorder-stop-condition branch August 11, 2021 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/minor This PR introduces functionality that users may find relevant to operating Hubble.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants