Skip to content

Commit

Permalink
chore: renaming gather files (#768)
Browse files Browse the repository at this point in the history
* chore(clusterconfig): rename authentications to gather_authentication

* chore(clusterconfig): rename ceph_cluster to gather_cepth_cluster

* chore(clusterconfig): rename certificate_signing_requests to gather_certificate_signing_requests

* chore(clusterconfig): rename config_maps to gather_config_maps

* chore(clusterconfig): rename container_images to gather_container_images

* chore(clusterconfig): rename container_runtime_configs to gather_container_runtime_configs

* chore(clusterconfig): rename cost_management_metrics_configs to gather_cost_management_metrics_configs

* chore(clusterconfig): rename custom_resource_definitions to gather_custom_resource_definitions

* chore(clusterconfig): rename dvo_metrics to gather_dvo_metrics

* chore(clusterconfig): rename feature_gates to gather_feature_gates

* chore(clusterconfig): rename host_subnets to gather_host_subnets

* chore(clusterconfig): rename image to gather_cluster_image

* chore(clusterconfig): rename image_pruners to gather_image_pruners

* chore(clusterconfig): rename image_registries to gather_cluster_image_registries

* chore(clusterconfig): rename install_plans to gather_install_plans

* chore(clusterconfig): rename jaeger_cr to gather_jaeger_cr

* chore(clusterconfig): rename machine_autoscalers to gather_machine_autoscalers

* chore(clusterconfig): rename machine_config_pools to gather_machine_config_pools

* chore(clusterconfig): rename machine_configs to gather_machine_configs

* chore(clusterconfig): rename machine_healthchecks to gather_machine_health_check

* chore(clusterconfig): rename machine_sets to gather_machine_sets

* chore(clusterconfig): rename machines to gather_machines

* chore(clusterconfig): rename mutatingwebhookconfigurations to gather_mutating_webhook_configurations

* chore(clusterconfig): rename namespaces_with_overlapping_uids to gather_namespaces_with_overlapping_uids

* chore(clusterconfig): rename netnamespace to gather_net_namespace

* chore(clusterconfig): rename node_logs to gather_node_logs

* chore(clusterconfig): rename olm_operators to gather_olm_operators

* chore(clusterconfig): rename openshift_logging to gather_openshift_logging

* chore(clusterconfig): rename openshift_machine_api_events to gather_openshift_machine_api_events

* chore(clusterconfig): rename operators to gather_cluster_operators

* chore(clusterconfig): rename operators_pods_and_events to gather_cluster_operator_pods_and_events

* chore(clusterconfig): rename pod_disruption_budgets to gather_pod_disruption_budgets

* chore(clusterconfig): rename pod_network_connectivity_checks to gather_pod_network_connectivity_checks

* chore(clusterconfig): rename sap_config to gather_sap_config

* chore(clusterconfig): rename sap_datahubs to gather_sap_datahubs

* chore(clusterconfig): rename sap_pods to gather_sap_pods

* chore(clusterconfig): rename scheduler to gather_schedulers

* chore(clusterconfig): rename service_accounts to gather_service_accounts

* chore(clusterconfig): rename storage_cluster to gather_storage_cluster

* chore(clusterconfig): rename support_secret to gather_support_secret

* chore(clusterconfig): rename tsdb_status to gather_prometheus_tsdb_status

* chore(clusterconfig): rename validatingwebhookconfigurations to gather_validating_webhook_configurations

* test(clusterconfig): adjusting method names

* chore(workloads): rename workload_info to gather_workload_info

* docs(gathered-data): update gathered-data docs

* refactor: sort the gatherers for configcluster

* test(clusterconfig): add tests for gather_cluster_feature_gates

* test(clusterconfig): add tests for gather_cluster_authentication

* test(clusterconfig): adds unit test for gather_prometheus_tsdb_status

* fix: adding lost gatherers on merge
  • Loading branch information
Ricardo Lüders authored Jun 30, 2023
1 parent 8f64a40 commit d88e43c
Show file tree
Hide file tree
Showing 86 changed files with 339 additions and 117 deletions.
110 changes: 55 additions & 55 deletions docs/gathered-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -1501,35 +1501,6 @@ Collects logs from pods in `openshift-sdn` namespace with following substrings:
None


## PNCC

Collects a summary of failed `PodNetworkConnectivityChecks` from last 24 hours.

Time of the most recently failed check with each reason and message is recorded.

### API Reference
- podnetworkconnectivitychecks.controlplane.operator.openshift.io/v1alpha1
- https://pkg.go.dev/github.com/openshift/api/operatorcontrolplane/v1alpha1

### Sample data
- [docs/insights-archive-sample/config/podnetworkconnectivitychecks.json](./insights-archive-sample/config/podnetworkconnectivitychecks.json)

### Location in archive
- `config/podnetworkconnectivitychecks.json`

### Config ID
`clusterconfig/pod_network_connectivity_checks`

### Released version
- 4.8.2

### Backported versions
None

### Changes
None


## PodDefinition

Collects pod definition from pods that are
Expand Down Expand Up @@ -1586,6 +1557,61 @@ Collects the cluster's `PodDisruptionBudgets`.
and the limit of gathered records to 100 since 4.14.


## PodNetworkConnectivityChecks

Collects a summary of failed `PodNetworkConnectivityChecks` from last 24 hours.

Time of the most recently failed check with each reason and message is recorded.

### API Reference
- podnetworkconnectivitychecks.controlplane.operator.openshift.io/v1alpha1
- https://pkg.go.dev/github.com/openshift/api/operatorcontrolplane/v1alpha1

### Sample data
- [docs/insights-archive-sample/config/podnetworkconnectivitychecks.json](./insights-archive-sample/config/podnetworkconnectivitychecks.json)

### Location in archive
- `config/podnetworkconnectivitychecks.json`

### Config ID
`clusterconfig/pod_network_connectivity_checks`

### Released version
- 4.8.2

### Backported versions
None

### Changes
None


## PrometheusTSDBStatus

Collects Prometheus TSDB status.

### API Reference
None

### Sample data
- [docs/insights-archive-sample/config/tsdb.json](./insights-archive-sample/config/tsdb.json)

### Location in archive
- `config/tsdb.json`

### Config ID
`clusterconfig/tsdb_status`

### Released version
- 4.10.0

### Backported versions
None

### Changes
None


## SAPConfig

Collects selected security context constraints
Expand Down Expand Up @@ -1879,32 +1905,6 @@ None
None


## TSDBStatus

Collects Prometheus TSDB status.

### API Reference
None

### Sample data
- [docs/insights-archive-sample/config/tsdb.json](./insights-archive-sample/config/tsdb.json)

### Location in archive
- `config/tsdb.json`

### Config ID
`clusterconfig/tsdb_status`

### Released version
- 4.10.0

### Backported versions
None

### Changes
None


## ValidatingWebhookConfigurations

Collects `ValidatingWebhookConfiguration` resources
Expand Down
86 changes: 43 additions & 43 deletions pkg/gatherers/clusterconfig/clusterconfig_gatherer.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,66 +27,66 @@ type Gatherer struct {
type gathererFuncPtr = func(*Gatherer, context.Context) ([]record.Record, []error)

var gatheringFunctions = map[string]gathererFuncPtr{
"pdbs": (*Gatherer).GatherPodDisruptionBudgets,
"metrics": (*Gatherer).GatherMostRecentMetrics,
"dvo_metrics": (*Gatherer).GatherDVOMetrics,
"operators": (*Gatherer).GatherClusterOperators,
"operators_pods_and_events": (*Gatherer).GatherClusterOperatorPodsAndEvents,
"container_images": (*Gatherer).GatherContainerImages,
"nodes": (*Gatherer).GatherNodes,
"config_maps": (*Gatherer).GatherConfigMaps,
"version": (*Gatherer).GatherClusterVersion,
"infrastructures": (*Gatherer).GatherClusterInfrastructure,
"networks": (*Gatherer).GatherClusterNetwork,
"active_alerts": (*Gatherer).GatherActiveAlerts,
"authentication": (*Gatherer).GatherClusterAuthentication,
"image_registries": (*Gatherer).GatherClusterImageRegistry,
"image_pruners": (*Gatherer).GatherClusterImagePruner,
"feature_gates": (*Gatherer).GatherClusterFeatureGates,
"oauths": (*Gatherer).GatherClusterOAuth,
"ingress": (*Gatherer).GatherClusterIngress,
"proxies": (*Gatherer).GatherClusterProxy,
"certificate_signing_requests": (*Gatherer).GatherCertificateSigningRequests,
"ceph_cluster": (*Gatherer).GatherCephCluster,
"config_maps": (*Gatherer).GatherConfigMaps,
"container_images": (*Gatherer).GatherContainerImages,
"container_runtime_configs": (*Gatherer).GatherContainerRuntimeConfig,
"cost_management_metrics_configs": (*Gatherer).GatherCostManagementMetricsConfigs,
"crds": (*Gatherer).GatherCRD,
"dvo_metrics": (*Gatherer).GatherDVOMetrics,
"feature_gates": (*Gatherer).GatherClusterFeatureGates,
"host_subnets": (*Gatherer).GatherHostSubnet,
"machines": (*Gatherer).GatherMachine,
"machine_sets": (*Gatherer).GatherMachineSet,
"image": (*Gatherer).GatherClusterImage,
"image_pruners": (*Gatherer).GatherClusterImagePruner,
"image_registries": (*Gatherer).GatherClusterImageRegistry,
"infrastructures": (*Gatherer).GatherClusterInfrastructure,
"ingress": (*Gatherer).GatherClusterIngress,
"install_plans": (*Gatherer).GatherInstallPlans,
"jaegers": (*Gatherer).GatherJaegerCR,
"kube_controller_manager_logs": (*Gatherer).GatherKubeControllerManagerLogs,
"machine_autoscalers": (*Gatherer).GatherMachineAutoscalers,
"machine_config_pools": (*Gatherer).GatherMachineConfigPool,
"machine_configs": (*Gatherer).GatherMachineConfigs,
"machine_healthchecks": (*Gatherer).GatherMachineHealthCheck,
"machine_sets": (*Gatherer).GatherMachineSet,
"machines": (*Gatherer).GatherMachine,
"metrics": (*Gatherer).GatherMostRecentMetrics,
"monitoring_persistent_volumes": (*Gatherer).GatherMonitoringPVs,
"install_plans": (*Gatherer).GatherInstallPlans,
"service_accounts": (*Gatherer).GatherServiceAccounts,
"machine_config_pools": (*Gatherer).GatherMachineConfigPool,
"container_runtime_configs": (*Gatherer).GatherContainerRuntimeConfig,
"mutating_webhook_configurations": (*Gatherer).GatherMutatingWebhookConfigurations,
"netnamespaces": (*Gatherer).GatherNetNamespace,
"networks": (*Gatherer).GatherClusterNetwork,
"node_logs": (*Gatherer).GatherNodeLogs,
"nodes": (*Gatherer).GatherNodes,
"oauths": (*Gatherer).GatherClusterOAuth,
"olm_operators": (*Gatherer).GatherOLMOperators,
"openshift_apiserver_operator_logs": (*Gatherer).GatherOpenShiftAPIServerOperatorLogs,
"openshift_sdn_logs": (*Gatherer).GatherOpenshiftSDNLogs,
"openshift_sdn_controller_logs": (*Gatherer).GatherOpenshiftSDNControllerLogs,
"openshift_authentication_logs": (*Gatherer).GatherOpenshiftAuthenticationLogs,
"openshift_logging": (*Gatherer).GatherOpenshiftLogging,
"openshift_machine_api_events": (*Gatherer).GatherOpenshiftMachineAPIEvents,
"openshift_sdn_controller_logs": (*Gatherer).GatherOpenshiftSDNControllerLogs,
"openshift_sdn_logs": (*Gatherer).GatherOpenshiftSDNLogs,
"operators": (*Gatherer).GatherClusterOperators,
"operators_pods_and_events": (*Gatherer).GatherClusterOperatorPodsAndEvents,
"overlapping_namespace_uids": (*Gatherer).GatherNamespacesWithOverlappingUIDs,
"pdbs": (*Gatherer).GatherPodDisruptionBudgets,
"pod_network_connectivity_checks": (*Gatherer).GatherPodNetworkConnectivityChecks,
"proxies": (*Gatherer).GatherClusterProxy,
"sap_config": (*Gatherer).GatherSAPConfig,
"sap_datahubs": (*Gatherer).GatherSAPDatahubs,
"sap_license_management_logs": (*Gatherer).GatherSAPVsystemIptablesLogs,
"sap_pods": (*Gatherer).GatherSAPPods,
"sap_datahubs": (*Gatherer).GatherSAPDatahubs,
"olm_operators": (*Gatherer).GatherOLMOperators,
"pod_network_connectivity_checks": (*Gatherer).GatherPNCC,
"machine_autoscalers": (*Gatherer).GatherMachineAutoscalers,
"openshift_logging": (*Gatherer).GatherOpenshiftLogging,
"storage_cluster": (*Gatherer).GatherStorageCluster,
"jaegers": (*Gatherer).GatherJaegerCR,
"validating_webhook_configurations": (*Gatherer).GatherValidatingWebhookConfigurations,
"mutating_webhook_configurations": (*Gatherer).GatherMutatingWebhookConfigurations,
"cost_management_metrics_configs": (*Gatherer).GatherCostManagementMetricsConfigs,
"node_logs": (*Gatherer).GatherNodeLogs,
"tsdb_status": (*Gatherer).GatherTSDBStatus,
"schedulers": (*Gatherer).GatherSchedulers,
"scheduler_logs": (*Gatherer).GatherSchedulerLogs,
"service_accounts": (*Gatherer).GatherServiceAccounts,
"silenced_alerts": (*Gatherer).GatherSilencedAlerts,
"image": (*Gatherer).GatherClusterImage,
"kube_controller_manager_logs": (*Gatherer).GatherKubeControllerManagerLogs,
"overlapping_namespace_uids": (*Gatherer).GatherNamespacesWithOverlappingUIDs,
"storage_cluster": (*Gatherer).GatherStorageCluster,
"support_secret": (*Gatherer).GatherSupportSecret,
"active_alerts": (*Gatherer).GatherActiveAlerts,
"ceph_cluster": (*Gatherer).GatherCephCluster,
"openshift_machine_api_events": (*Gatherer).GatherOpenshiftMachineAPIEvents,
"tsdb_status": (*Gatherer).GatherPrometheusTSDBStatus,
"validating_webhook_configurations": (*Gatherer).GatherValidatingWebhookConfigurations,
"version": (*Gatherer).GatherClusterVersion,
}

func New(
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
certificatesv1api "k8s.io/api/certificates/v1"
)

func Test_CSR(t *testing.T) {
func Test_gatherCertificateSigningRequests(t *testing.T) {
var files = []struct {
dataFile string
expFile string
Expand Down Expand Up @@ -66,7 +66,7 @@ func Test_CSR(t *testing.T) {
}

// Verifies if CSR features will be ignored in package
func Test_CSR_Filters(t *testing.T) {
func Test_gatherCertificateSigningRequestsFilters(t *testing.T) {
var files = []struct {
name string
csr *CSRAnonymizedFeatures
Expand Down
63 changes: 63 additions & 0 deletions pkg/gatherers/clusterconfig/gather_cluster_authentication_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package clusterconfig

import (
"context"
"testing"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

configfake "github.com/openshift/client-go/config/clientset/versioned/fake"

v1 "github.com/openshift/api/config/v1"
"github.com/openshift/insights-operator/pkg/record"
"github.com/stretchr/testify/assert"
)

func Test_gatherClusterAuthentication(t *testing.T) {
tests := []struct {
name string
authentication *v1.Authentication
result []record.Record
errCount int
}{
{
name: "Retrieving authentication returns record of that authentication and no errors",
authentication: &v1.Authentication{
ObjectMeta: metav1.ObjectMeta{
Name: "cluster",
},
},
result: []record.Record{
{
Name: "config/authentication",
Item: record.ResourceMarshaller{
Resource: &v1.Authentication{
ObjectMeta: metav1.ObjectMeta{Name: "cluster"},
},
},
},
},
errCount: 0,
},
{
name: "Retrieving no authentication returns no error/no records",
authentication: &v1.Authentication{},
result: nil,
},
}
for _, testCase := range tests {
tc := testCase
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
// Given
configClient := configfake.NewSimpleClientset(tc.authentication)

// When
got, gotErrs := gatherClusterAuthentication(context.Background(), configClient.ConfigV1())

// Assert
assert.Equal(t, tc.result, got)
assert.Len(t, gotErrs, tc.errCount)
})
}
}
63 changes: 63 additions & 0 deletions pkg/gatherers/clusterconfig/gather_cluster_feature_gates_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package clusterconfig

import (
"context"
"testing"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

v1 "github.com/openshift/api/config/v1"

configfake "github.com/openshift/client-go/config/clientset/versioned/fake"
"github.com/openshift/insights-operator/pkg/record"
"github.com/stretchr/testify/assert"
)

func Test_gatherClusterFeatureGates(t *testing.T) {
tests := []struct {
name string
feature *v1.FeatureGate
result []record.Record
errCount int
}{
{
name: "Retrieving featuregate returns record of that featuregate and no errors",
feature: &v1.FeatureGate{
ObjectMeta: metav1.ObjectMeta{
Name: "cluster",
},
},
result: []record.Record{
{
Name: "config/featuregate",
Item: record.ResourceMarshaller{
Resource: &v1.FeatureGate{
ObjectMeta: metav1.ObjectMeta{Name: "cluster"},
},
},
},
},
errCount: 0,
},
{
name: "Retrieving no featuregate returns no error/no record",
feature: &v1.FeatureGate{},
result: nil,
},
}
for _, testCase := range tests {
tc := testCase
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
// Given
configClient := configfake.NewSimpleClientset(tc.feature)

// When
got, gotErrs := gatherClusterFeatureGates(context.Background(), configClient.ConfigV1())

// Assert
assert.Equal(t, tc.result, got)
assert.Len(t, gotErrs, tc.errCount)
})
}
}
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit d88e43c

Please sign in to comment.