diff --git a/docs/gathered-data.md b/docs/gathered-data.md index 1ba666edc..0a93fa132 100644 --- a/docs/gathered-data.md +++ b/docs/gathered-data.md @@ -773,8 +773,16 @@ None ## HelmInfo -Collects summarized info about the helm usage on a cluster -in a generic fashion +Collects statistics about resources deployed via HelmChart, counting only the resources +with `app.kubernetes.io/managed-by=Helm` and `helm.sh/chart` labels. The data is then summarized +and grouped by hashed namespace. + +Resource types included: +- ReplicaSets +- DaemonSets +- StatefulSets +- Services +- Deployments ### API Reference None diff --git a/pkg/gatherers/workloads/gather_helm_info.go b/pkg/gatherers/workloads/gather_helm_info.go index 13ab6f583..e5de3f5bf 100644 --- a/pkg/gatherers/workloads/gather_helm_info.go +++ b/pkg/gatherers/workloads/gather_helm_info.go @@ -20,8 +20,16 @@ import ( const labelChartNameKey = "helm.sh/chart" -// GatherHelmInfo Collects summarized info about the helm usage on a cluster -// in a generic fashion +// GatherHelmInfo Collects statistics about resources deployed via HelmChart, counting only the resources +// with `app.kubernetes.io/managed-by=Helm` and `helm.sh/chart` labels. The data is then summarized +// and grouped by hashed namespace. +// +// Resource types included: +// - ReplicaSets +// - DaemonSets +// - StatefulSets +// - Services +// - Deployments // // ### API Reference // None @@ -84,7 +92,7 @@ func gatherHelmInfo( // Anonymize the namespace to make it unique identifier hash, err := createHash(item.GetNamespace()) if err != nil { - klog.Errorf("unable to hash the namespace '%s': %v", labels[labelChartNameKey], err) + klog.Errorf("unable to hash the namespace '%s': %v", item.GetNamespace(), err) continue } diff --git a/pkg/gatherers/workloads/types_test.go b/pkg/gatherers/workloads/types_test.go index 9360ff188..c02f2821c 100644 --- a/pkg/gatherers/workloads/types_test.go +++ b/pkg/gatherers/workloads/types_test.go @@ -88,8 +88,6 @@ func TestAddItem(t *testing.T) { for _, testCase := range tests { tt := testCase t.Run(tt.name, func(t *testing.T) { - t.Parallel() - helmList := newHelmChartInfoList() for namespace, resources := range tt.info { for resource, charts := range resources { @@ -99,7 +97,12 @@ func TestAddItem(t *testing.T) { } } - assert.Equal(t, tt.expectedList, helmList.Namespaces, "expected '%v', got '%v'", tt.expectedList, helmList.Namespaces) + // check equality of elements in slices, ignoring order + for namespace, expectedCharts := range tt.expectedList { + actualCharts, ok := helmList.Namespaces[namespace] + assert.True(t, ok, "expected namespace '%s' not found", namespace) + assert.ElementsMatch(t, expectedCharts, actualCharts, "unexpected charts for namespace '%s'", namespace) + } }) } }