diff --git a/sysdump/constants.go b/sysdump/constants.go index 399f5c5e33..7c3163f533 100644 --- a/sysdump/constants.go +++ b/sysdump/constants.go @@ -183,10 +183,3 @@ var ( Version: "v1alpha2", } ) - -var ( - tetragonAgentContainerName = "tetragon" - tetragonBugtoolPrefix = "tetragon-bugtool" - tetragonCliCommand = "tetra" - tetragonTracingPolicy = "tetragontracingpolicy-.yaml" -) diff --git a/sysdump/defaults.go b/sysdump/defaults.go index 567da004f6..12d278fb46 100644 --- a/sysdump/defaults.go +++ b/sysdump/defaults.go @@ -47,6 +47,10 @@ const ( DefaultCNIConfigMapName = "cni-configuration" DefaultTetragonNamespace = "kube-system" DefaultTetragonLabelSelector = "app.kubernetes.io/name=tetragon" + DefaultTetragonAgentContainerName = "tetragon" + DefaultTetragonBugtoolPrefix = "tetragon-bugtool" + DefaultTetragonCLICommand = "tetra" + DefaultTetragonTracingPolicy = "tetragontracingpolicy-.yaml" ) var ( diff --git a/sysdump/sysdump.go b/sysdump/sysdump.go index e7d96a7050..3cf8a1526a 100644 --- a/sysdump/sysdump.go +++ b/sysdump/sysdump.go @@ -1088,7 +1088,9 @@ func (c *Collector) Run() error { if err != nil { return fmt.Errorf("failed to get Tetragon pods: %w", err) } - if err := c.submitTetragonBugtoolTasks(FilterPods(p, c.NodeList)); err != nil { + if err := c.SubmitTetragonBugtoolTasks(FilterPods(p, c.NodeList), + DefaultTetragonAgentContainerName, DefaultTetragonBugtoolPrefix, + DefaultTetragonCLICommand); err != nil { return fmt.Errorf("failed to collect 'tetragon-bugtool': %w", err) } return nil @@ -1147,7 +1149,7 @@ func (c *Collector) Run() error { if err != nil { return fmt.Errorf("failed to collect Tetragon tracing policies: %w", err) } - if err := c.WriteYAML(tetragonTracingPolicy, v); err != nil { + if err := c.WriteYAML(DefaultTetragonTracingPolicy, v); err != nil { return fmt.Errorf("failed to collect Tetragon tracing policies: %w", err) } return nil @@ -1434,7 +1436,8 @@ func (c *Collector) shouldSkipTask(t Task) bool { return c.Options.Quick && !t.Quick } -func (c *Collector) submitTetragonBugtoolTasks(pods []*corev1.Pod) error { +func (c *Collector) SubmitTetragonBugtoolTasks(pods []*corev1.Pod, tetragonAgentContainerName, + tetragonBugtoolPrefix, tetragonCLICommand string) error { for _, p := range pods { p := p workerID := fmt.Sprintf("%s-%s", tetragonBugtoolPrefix, p.Name) @@ -1452,7 +1455,7 @@ func (c *Collector) submitTetragonBugtoolTasks(pods []*corev1.Pod) error { tarGzFile := fmt.Sprintf("%s-%s.tar.gz", tetragonBugtoolPrefix, time.Now().Format(timeFormat)) // Run 'tetra bugtool' in the pod. - command := []string{tetragonCliCommand, "bugtool", "--out", tarGzFile} + command := []string{tetragonCLICommand, "bugtool", "--out", tarGzFile} c.logDebug("Executing 'tetragon-bugtool' command: %v", command) _, e, err := c.Client.ExecInPodWithStderr(ctx, p.Namespace, p.Name, containerName, command)