Skip to content

Commit

Permalink
sysdump: Log cilium-cli version and arguments
Browse files Browse the repository at this point in the history
It would be handy to have the cilium-cli version and flags used to
capture the sysdump in cilium-sysdump.log.

Sample outputs:

- No flags:

      % ./cilium sysdump
      🔍 Collecting sysdump with cilium-cli version: v0.11.5-18-gd3a523a1, args: [sysdump]

- With some flags:

      % ./cilium sysdump --hubble-flows-count 10 --hubble-flows-timeout 5s
      🔍 Collecting sysdump with cilium-cli version: v0.11.5-18-gd3a523a1, args: [sysdump --hubble-flows-count 10 --hubble-flows-timeout 5s]

Signed-off-by: Michi Mutsuzaki <[email protected]>
  • Loading branch information
michi-covalent committed May 12, 2022
1 parent 680afc8 commit f733d9d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/cli/cmd/sysdump.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func newCmdSysdump() *cobra.Command {
// Silence klog to avoid displaying "throttling" messages - those are expected.
klog.SetOutput(io.Discard)
// Collect the sysdump.
collector, err := sysdump.NewCollector(k8sClient, sysdumpOptions, time.Now())
collector, err := sysdump.NewCollector(k8sClient, sysdumpOptions, time.Now(), Version)
if err != nil {
return fmt.Errorf("failed to create sysdump collector: %v", err)
}
Expand Down
3 changes: 2 additions & 1 deletion sysdump/sysdump.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ type Collector struct {
}

// NewCollector returns a new sysdump collector.
func NewCollector(k KubernetesClient, o Options, startTime time.Time) (*Collector, error) {
func NewCollector(k KubernetesClient, o Options, startTime time.Time, cliVersion string) (*Collector, error) {
c := Collector{
Client: k,
Options: o,
Expand All @@ -143,6 +143,7 @@ func NewCollector(k KubernetesClient, o Options, startTime time.Time) (*Collecto
return nil, err
}
c.logDebug("Using %v as a temporary directory", c.sysdumpDir)
c.logTask("Collecting sysdump with cilium-cli version: %s, args: %s", cliVersion, os.Args[1:])

// Grab the Kubernetes nodes for the target cluster.
c.logTask("Collecting Kubernetes nodes")
Expand Down

0 comments on commit f733d9d

Please sign in to comment.