Fix Progress Callback for Support Bundle Collection (#781)

fix progress callback for support bundle and revert collector title changes
This commit is contained in:
Diamon Wiggins
2022-10-14 12:29:59 -04:00
committed by GitHub
parent 9b37b98a93
commit e85d1bb473
21 changed files with 102 additions and 20 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ type CollectClusterInfo struct {
}
func (c *CollectClusterInfo) Title() string {
return collectorTitleOrDefault(c.Collector.CollectorMeta, "Cluster Info")
return getCollectorName(c)
}
func (c *CollectClusterInfo) IsExcluded() (bool, error) {
+1 -1
View File
@@ -43,7 +43,7 @@ type CollectClusterResources struct {
}
func (c *CollectClusterResources) Title() string {
return collectorTitleOrDefault(c.Collector.CollectorMeta, "Cluster Resources")
return getCollectorName(c)
}
func (c *CollectClusterResources) IsExcluded() (bool, error) {
+1 -1
View File
@@ -19,7 +19,7 @@ type CollectCollectd struct {
}
func (c *CollectCollectd) Title() string {
return collectorTitleOrDefault(c.Collector.CollectorMeta, "CollectD")
return getCollectorName(c)
}
func (c *CollectCollectd) IsExcluded() (bool, error) {
+82
View File
@@ -2,7 +2,9 @@ package collect
import (
"context"
"fmt"
"strconv"
"strings"
"time"
"github.com/pkg/errors"
@@ -107,3 +109,83 @@ func collectorTitleOrDefault(meta troubleshootv1beta2.CollectorMeta, defaultTitl
}
return defaultTitle
}
func getCollectorName(c interface{}) string {
var collector, name, selector string
switch v := c.(type) {
case *CollectClusterInfo:
collector = "cluster-info"
case *CollectClusterResources:
collector = "cluster-resources"
case *CollectSecret:
collector = "secret"
name = v.Collector.CollectorName
selector = strings.Join(v.Collector.Selector, ",")
case *CollectConfigMap:
collector = "configmap"
name = v.Collector.CollectorName
selector = strings.Join(v.Collector.Selector, ",")
case *CollectLogs:
collector = "logs"
name = v.Collector.CollectorName
selector = strings.Join(v.Collector.Selector, ",")
case *CollectRun:
collector = "run"
name = v.Collector.CollectorName
case *CollectRunPod:
collector = "run-pod"
name = v.Collector.CollectorName
case *CollectExec:
collector = "exec"
name = v.Collector.CollectorName
selector = strings.Join(v.Collector.Selector, ",")
case *CollectData:
collector = "data"
name = v.Collector.CollectorName
case *CollectCopy:
collector = "copy"
name = v.Collector.CollectorName
selector = strings.Join(v.Collector.Selector, ",")
case *CollectCopyFromHost:
collector = "copy-from-host"
name = v.Collector.CollectorName
case *CollectHTTP:
collector = "http"
name = v.Collector.CollectorName
case *CollectPostgres:
collector = "postgres"
name = v.Collector.CollectorName
case *CollectMysql:
collector = "mysql"
name = v.Collector.CollectorName
case *CollectRedis:
collector = "redis"
name = v.Collector.CollectorName
case *CollectCollectd:
collector = "collectd"
name = v.Collector.CollectorName
case *CollectCeph:
collector = "ceph"
name = v.Collector.CollectorName
case *CollectLonghorn:
collector = "longhorn"
name = v.Collector.CollectorName
case *CollectRegistry:
collector = "registry-images"
name = v.Collector.CollectorName
case *CollectSysctl:
collector = "sysctl"
name = v.Collector.Name
default:
collector = "<none>"
}
if name != "" {
return fmt.Sprintf("%s/%s", collector, name)
}
if selector != "" {
return fmt.Sprintf("%s/%s", collector, selector)
}
return collector
}
+1 -1
View File
@@ -38,7 +38,7 @@ type CollectConfigMap struct {
}
func (c *CollectConfigMap) Title() string {
return collectorTitleOrDefault(c.Collector.CollectorMeta, "ConfigMap")
return getCollectorName(c)
}
func (c *CollectConfigMap) IsExcluded() (bool, error) {
+1 -1
View File
@@ -31,7 +31,7 @@ type CollectCopy struct {
}
func (c *CollectCopy) Title() string {
return collectorTitleOrDefault(c.Collector.CollectorMeta, "Copy")
return getCollectorName(c)
}
func (c *CollectCopy) IsExcluded() (bool, error) {
+1 -1
View File
@@ -37,7 +37,7 @@ type CollectCopyFromHost struct {
}
func (c *CollectCopyFromHost) Title() string {
return collectorTitleOrDefault(c.Collector.CollectorMeta, "Copy from Host")
return getCollectorName(c)
}
func (c *CollectCopyFromHost) IsExcluded() (bool, error) {
+1 -1
View File
@@ -21,7 +21,7 @@ type CollectData struct {
}
func (c *CollectData) Title() string {
return collectorTitleOrDefault(c.Collector.CollectorMeta, "Data")
return getCollectorName(c)
}
func (c *CollectData) IsExcluded() (bool, error) {
+1 -1
View File
@@ -27,7 +27,7 @@ type CollectExec struct {
}
func (c *CollectExec) Title() string {
return collectorTitleOrDefault(c.Collector.CollectorMeta, "Exec")
return getCollectorName(c)
}
func (c *CollectExec) IsExcluded() (bool, error) {
+1 -1
View File
@@ -45,7 +45,7 @@ type CollectHTTP struct {
}
func (c *CollectHTTP) Title() string {
return collectorTitleOrDefault(c.Collector.CollectorMeta, "HTTP")
return getCollectorName(c)
}
func (c *CollectHTTP) IsExcluded() (bool, error) {
+1 -1
View File
@@ -28,7 +28,7 @@ type CollectLogs struct {
}
func (c *CollectLogs) Title() string {
return collectorTitleOrDefault(c.Collector.CollectorMeta, "Logs")
return getCollectorName(c)
}
func (c *CollectLogs) IsExcluded() (bool, error) {
+1 -1
View File
@@ -40,7 +40,7 @@ type CollectLonghorn struct {
}
func (c *CollectLonghorn) Title() string {
return collectorTitleOrDefault(c.Collector.CollectorMeta, "Longhorn")
return getCollectorName(c)
}
func (c *CollectLonghorn) IsExcluded() (bool, error) {
+1 -1
View File
@@ -25,7 +25,7 @@ type CollectMysql struct {
}
func (c *CollectMysql) Title() string {
return collectorTitleOrDefault(c.Collector.CollectorMeta, "Mysql")
return getCollectorName(c)
}
func (c *CollectMysql) IsExcluded() (bool, error) {
+1 -1
View File
@@ -26,7 +26,7 @@ type CollectPostgres struct {
}
func (c *CollectPostgres) Title() string {
return collectorTitleOrDefault(c.Collector.CollectorMeta, "Postgres")
return getCollectorName(c)
}
func (c *CollectPostgres) IsExcluded() (bool, error) {
+1 -1
View File
@@ -25,7 +25,7 @@ type CollectRedis struct {
}
func (c *CollectRedis) Title() string {
return collectorTitleOrDefault(c.Collector.CollectorMeta, "Cluster Info")
return getCollectorName(c)
}
func (c *CollectRedis) IsExcluded() (bool, error) {
+1 -1
View File
@@ -48,7 +48,7 @@ type CollectRegistry struct {
}
func (c *CollectRegistry) Title() string {
return collectorTitleOrDefault(c.Collector.CollectorMeta, "Registry Images")
return getCollectorName(c)
}
func (c *CollectRegistry) IsExcluded() (bool, error) {
+1 -1
View File
@@ -20,7 +20,7 @@ type CollectRun struct {
}
func (c *CollectRun) Title() string {
return collectorTitleOrDefault(c.Collector.CollectorMeta, "Run")
return getCollectorName(c)
}
func (c *CollectRun) IsExcluded() (bool, error) {
+1 -1
View File
@@ -33,7 +33,7 @@ type CollectRunPod struct {
}
func (c *CollectRunPod) Title() string {
return collectorTitleOrDefault(c.Collector.CollectorMeta, "Run Pod")
return getCollectorName(c)
}
func (c *CollectRunPod) IsExcluded() (bool, error) {
+1 -1
View File
@@ -37,7 +37,7 @@ type CollectSecret struct {
}
func (c *CollectSecret) Title() string {
return collectorTitleOrDefault(c.Collector.CollectorMeta, "Secret")
return getCollectorName(c)
}
func (c *CollectSecret) IsExcluded() (bool, error) {
+1 -1
View File
@@ -27,7 +27,7 @@ type CollectSysctl struct {
}
func (c *CollectSysctl) Title() string {
return collectorTitleOrDefault(c.Collector.CollectorMeta, "Sysctl")
return getCollectorName(c)
}
func (c *CollectSysctl) IsExcluded() (bool, error) {
+1 -1
View File
@@ -131,7 +131,7 @@ func runCollectors(collectors []*troubleshootv1beta2.Collect, additionalRedactor
}
}
opts.ProgressChan <- fmt.Sprintf("[%s] Running collector...", collector.Title())
opts.CollectorProgressCallback(opts.ProgressChan, collector.Title())
result, err := collector.Collect(opts.ProgressChan)
if err != nil {
opts.ProgressChan <- errors.Errorf("failed to run collector: %s: %v", collector.Title(), err)