Skip to content

Commit 2e6175f

Browse files
authored
gather new insights-config CM & add warning for deprecated support secret (#878)
1 parent 54b8396 commit 2e6175f

File tree

5 files changed

+58
-1
lines changed

5 files changed

+58
-1
lines changed

docs/gathered-data.md

+2
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,8 @@ for details).
620620
4.13.0+
621621
- `gateway-mode-config` config map from `openshift-network-operator`
622622
namespace since 4.14.0+
623+
- `insights-config` config map from `openshift-insights` namespace
624+
since 4.15.0+
623625

624626
### Anonymization
625627
If the content of a `ConfigMap` contains a parseable PEM structure (like a certificate), it removes the inside of
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"dataReporting": {
3+
"uploadEndpoint": "https://console.redhat.com/api/ingress/v1/upload",
4+
"obfuscation": [
5+
"workload_names"
6+
]
7+
},
8+
"alerting": {
9+
"disabled": "true"
10+
},
11+
"sca": {
12+
"disabled": "true"
13+
},
14+
"clusterTransfer": {},
15+
"proxy": {
16+
"httpProxy": "xxxxxxxxxxxxxxxx",
17+
"httpsProxy": "xxxxxxxxxxxxxxxxxxxxxxxx",
18+
"noProxy": "xxxxxxxxxxxxxxxxxxxx"
19+
}
20+
}

pkg/config/configobserver/secretconfigobserver.go

+1
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ func (c *Controller) updateConfig(ctx context.Context) error {
169169
if secret == nil {
170170
c.setSecretConfig(nil)
171171
} else {
172+
klog.Warning(`USING THE "SUPPORT" SECRET FOR OPERATOR CONFIGURATION IS DEPRECATED. PLEASE REFER TO THE OCP DOCUMENTATION FOR UPDATES.`) // nolint:lll
172173
nextConfig, err := LoadConfigFromSecret(secret)
173174
if err != nil {
174175
return err

pkg/controller/status/gatherer_status.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func createGathererConditions(gfr *gather.GathererFunctionReport) []metav1.Condi
6969

7070
if gfr.Panic != nil {
7171
con.Reason = GatherPanicReason
72-
con.Message = gfr.Panic.(string)
72+
con.Message = fmt.Sprintf("%s", gfr.Panic)
7373
}
7474

7575
if gfr.RecordsCount > 0 {

pkg/gatherers/clusterconfig/gather_config_maps.go

+34
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ import (
1212
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
1313
"sigs.k8s.io/yaml"
1414

15+
"github.com/openshift/insights-operator/pkg/config"
1516
"github.com/openshift/insights-operator/pkg/record"
17+
"github.com/openshift/insights-operator/pkg/utils/anonymize"
1618
)
1719

1820
// GatherConfigMaps Collects all `ConfigMaps` from the `openshift-config`
@@ -52,6 +54,8 @@ import (
5254
// 4.13.0+
5355
// - `gateway-mode-config` config map from `openshift-network-operator`
5456
// namespace since 4.14.0+
57+
// - `insights-config` config map from `openshift-insights` namespace
58+
// since 4.15.0+
5559
//
5660
// ### Anonymization
5761
// If the content of a `ConfigMap` contains a parseable PEM structure (like a certificate), it removes the inside of
@@ -77,6 +81,10 @@ func (g *Gatherer) GatherConfigMaps(ctx context.Context) ([]record.Record, []err
7781
records = append(records, gateayModeConf...)
7882
errs = append(errs, networkErrs...)
7983

84+
insightsConfg, insightsErr := gatherInsightsConfigCM(ctx, coreClient)
85+
records = append(records, insightsConfg...)
86+
errs = append(errs, insightsErr...)
87+
8088
clusterConfigV1Rec, clusterConfigV1Errs := gatherClusterConfigV1(ctx, coreClient)
8189
records = append(records, clusterConfigV1Rec...)
8290
errs = append(errs, clusterConfigV1Errs...)
@@ -132,6 +140,32 @@ func gatherConfigMap(ctx context.Context, coreClient corev1client.CoreV1Interfac
132140
return records, nil
133141
}
134142

143+
func gatherInsightsConfigCM(ctx context.Context, coreClient corev1client.CoreV1Interface) ([]record.Record, []error) {
144+
cm, err := coreClient.ConfigMaps("openshift-insights").Get(ctx, "insights-config", metav1.GetOptions{})
145+
if err != nil {
146+
return nil, []error{err}
147+
}
148+
insightsConfig := &config.InsightsConfigurationSerialized{}
149+
cfg := cm.Data["config.yaml"]
150+
err = yaml.Unmarshal([]byte(cfg), insightsConfig)
151+
if err != nil {
152+
return nil, []error{err}
153+
}
154+
return []record.Record{
155+
{
156+
Name: fmt.Sprintf("config/configmaps/%s/%s/%s", cm.Namespace, cm.Name, "config"),
157+
Item: record.JSONMarshaller{Object: anonymizeInsightsConfig(insightsConfig)},
158+
},
159+
}, nil
160+
}
161+
162+
func anonymizeInsightsConfig(conf *config.InsightsConfigurationSerialized) *config.InsightsConfigurationSerialized {
163+
conf.Proxy.HTTPProxy = anonymize.String(conf.Proxy.HTTPProxy)
164+
conf.Proxy.HTTPSProxy = anonymize.String(conf.Proxy.HTTPSProxy)
165+
conf.Proxy.NoProxy = anonymize.String(conf.Proxy.NoProxy)
166+
return conf
167+
}
168+
135169
// ConfigMapAnonymizer implements serialization of configmap
136170
// and potentially anonymizes if it is a certificate
137171
type ConfigMapAnonymizer struct {

0 commit comments

Comments
 (0)