-
Notifications
You must be signed in to change notification settings - Fork 98
/
Copy pathclusterconfig_gatherer.go
129 lines (117 loc) · 6.62 KB
/
clusterconfig_gatherer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package clusterconfig
import (
"context"
"k8s.io/client-go/rest"
"github.com/openshift/insights-operator/pkg/anonymization"
"github.com/openshift/insights-operator/pkg/config"
"github.com/openshift/insights-operator/pkg/config/configobserver"
"github.com/openshift/insights-operator/pkg/gatherers"
"github.com/openshift/insights-operator/pkg/record"
)
// Gatherer is an object storing config and having all the gathering functions
type Gatherer struct {
gatherKubeConfig *rest.Config
gatherProtoKubeConfig *rest.Config
metricsGatherKubeConfig *rest.Config
alertsGatherKubeConfig *rest.Config
anonymizer *anonymization.Anonymizer
configAggregator configobserver.Interface
}
// gathererFuncPtr is a type for pointers to functions of Gatherer
type gathererFuncPtr = func(*Gatherer, context.Context) ([]record.Record, []error)
var gatheringFunctions = map[string]gathererFuncPtr{
"active_alerts": (*Gatherer).GatherActiveAlerts,
"aggregated_monitoring_cr_names": (*Gatherer).GatherAggregatedMonitoringCRNames,
"authentication": (*Gatherer).GatherClusterAuthentication,
"certificate_signing_requests": (*Gatherer).GatherCertificateSigningRequests,
"ceph_cluster": (*Gatherer).GatherCephCluster,
"cluster_apiserver": (*Gatherer).GatherClusterAPIServer,
"clusterroles": (*Gatherer).GatherClusterRoles,
"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,
"image": (*Gatherer).GatherClusterImage,
"image_pruners": (*Gatherer).GatherClusterImagePruner,
"image_registries": (*Gatherer).GatherClusterImageRegistry,
"infrastructures": (*Gatherer).GatherClusterInfrastructure,
"ingress": (*Gatherer).GatherClusterIngress,
"ingress_certificates": (*Gatherer).GatherClusterIngressCertificates,
"install_plans": (*Gatherer).GatherInstallPlans,
"jaegers": (*Gatherer).GatherJaegerCR,
"lokistack": (*Gatherer).GatherLokiStack,
"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,
"mutating_webhook_configurations": (*Gatherer).GatherMutatingWebhookConfigurations,
"networks": (*Gatherer).GatherClusterNetwork,
"node_logs": (*Gatherer).GatherNodeLogs,
"nodes": (*Gatherer).GatherNodes,
"nodenetworkconfigurationpolicies": (*Gatherer).GatherNodeNetworkConfigurationPolicy,
"nodenetworkstates": (*Gatherer).GatherNodeNetworkState,
"oauths": (*Gatherer).GatherClusterOAuth,
"olm_operators": (*Gatherer).GatherOLMOperators,
"openshift_logging": (*Gatherer).GatherOpenshiftLogging,
"openshift_machine_api_events": (*Gatherer).GatherOpenshiftMachineAPIEvents,
"openstack_controlplanes": (*Gatherer).GatherOpenstackControlplanes,
"openstack_dataplanedeployments": (*Gatherer).GatherOpenstackDataplaneDeployments,
"openstack_dataplanenodesets": (*Gatherer).GatherOpenstackDataplaneNodeSets,
"openstack_version": (*Gatherer).GatherOpenstackVersions,
"operators": (*Gatherer).GatherClusterOperators,
"operators_pods_and_events": (*Gatherer).GatherClusterOperatorPodsAndEvents,
"overlapping_namespace_uids": (*Gatherer).GatherNamespacesWithOverlappingUIDs,
"pdbs": (*Gatherer).GatherPodDisruptionBudgets,
"pod_network_connectivity_checks": (*Gatherer).GatherPodNetworkConnectivityChecks,
"number_of_pods_and_netnamespaces_with_sdn_annotations": (*Gatherer).GatherNumberOfPodsAndNetnamespacesWithSDNAnnotations,
"proxies": (*Gatherer).GatherClusterProxy,
"sap_config": (*Gatherer).GatherSAPConfig,
"sap_datahubs": (*Gatherer).GatherSAPDatahubs,
"sap_pods": (*Gatherer).GatherSAPPods,
"schedulers": (*Gatherer).GatherSchedulers,
"service_accounts": (*Gatherer).GatherServiceAccounts,
"silenced_alerts": (*Gatherer).GatherSilencedAlerts,
"storage_classes": (*Gatherer).GatherStorageClasses,
"storage_cluster": (*Gatherer).GatherStorageCluster,
"support_secret": (*Gatherer).GatherSupportSecret,
"tsdb_status": (*Gatherer).GatherPrometheusTSDBStatus,
"validating_webhook_configurations": (*Gatherer).GatherValidatingWebhookConfigurations,
"version": (*Gatherer).GatherClusterVersion,
}
func New(
gatherKubeConfig, gatherProtoKubeConfig, metricsGatherKubeConfig, alertsGatherKubeConfig *rest.Config,
anonymizer *anonymization.Anonymizer, configObserver configobserver.Interface,
) *Gatherer {
return &Gatherer{
gatherKubeConfig: gatherKubeConfig,
gatherProtoKubeConfig: gatherProtoKubeConfig,
metricsGatherKubeConfig: metricsGatherKubeConfig,
alertsGatherKubeConfig: alertsGatherKubeConfig,
anonymizer: anonymizer,
configAggregator: configObserver,
}
}
func (g *Gatherer) GetName() string {
return "clusterconfig"
}
func (g *Gatherer) GetGatheringFunctions(context.Context) (map[string]gatherers.GatheringClosure, error) {
result := make(map[string]gatherers.GatheringClosure)
for funcName, function := range gatheringFunctions {
result[funcName] = gatherers.GatheringClosure{
Run: func(ctx context.Context) ([]record.Record, []error) {
return function(g, ctx)
},
}
}
return result, nil
}
func (g *Gatherer) config() *config.InsightsConfiguration {
return g.configAggregator.Config()
}