Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NO-JIRA: gather new insights-config CM & add warning for deprecated support se… #878

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/gathered-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,8 @@ for details).
4.13.0+
- `gateway-mode-config` config map from `openshift-network-operator`
namespace since 4.14.0+
- `insights-config` config map from `openshift-insights` namespace
since 4.15.0+

### Anonymization
If the content of a `ConfigMap` contains a parseable PEM structure (like a certificate), it removes the inside of
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"dataReporting": {
"uploadEndpoint": "https://console.redhat.com/api/ingress/v1/upload",
"obfuscation": [
"workload_names"
]
},
"alerting": {
"disabled": "true"
},
"sca": {
"disabled": "true"
},
"clusterTransfer": {},
"proxy": {
"httpProxy": "xxxxxxxxxxxxxxxx",
"httpsProxy": "xxxxxxxxxxxxxxxxxxxxxxxx",
"noProxy": "xxxxxxxxxxxxxxxxxxxx"
}
}
1 change: 1 addition & 0 deletions pkg/config/configobserver/secretconfigobserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ func (c *Controller) updateConfig(ctx context.Context) error {
if secret == nil {
c.setSecretConfig(nil)
} else {
klog.Warning(`USING THE "SUPPORT" SECRET FOR OPERATOR CONFIGURATION IS DEPRECATED. PLEASE REFER TO THE OCP DOCUMENTATION FOR UPDATES.`) // nolint:lll
nextConfig, err := LoadConfigFromSecret(secret)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/status/gatherer_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func createGathererConditions(gfr *gather.GathererFunctionReport) []metav1.Condi

if gfr.Panic != nil {
con.Reason = GatherPanicReason
con.Message = gfr.Panic.(string)
con.Message = fmt.Sprintf("%s", gfr.Panic)
}

if gfr.RecordsCount > 0 {
Expand Down
34 changes: 34 additions & 0 deletions pkg/gatherers/clusterconfig/gather_config_maps.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import (
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
"sigs.k8s.io/yaml"

"github.com/openshift/insights-operator/pkg/config"
"github.com/openshift/insights-operator/pkg/record"
"github.com/openshift/insights-operator/pkg/utils/anonymize"
)

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

insightsConfg, insightsErr := gatherInsightsConfigCM(ctx, coreClient)
records = append(records, insightsConfg...)
errs = append(errs, insightsErr...)

clusterConfigV1Rec, clusterConfigV1Errs := gatherClusterConfigV1(ctx, coreClient)
records = append(records, clusterConfigV1Rec...)
errs = append(errs, clusterConfigV1Errs...)
Expand Down Expand Up @@ -132,6 +140,32 @@ func gatherConfigMap(ctx context.Context, coreClient corev1client.CoreV1Interfac
return records, nil
}

func gatherInsightsConfigCM(ctx context.Context, coreClient corev1client.CoreV1Interface) ([]record.Record, []error) {
cm, err := coreClient.ConfigMaps("openshift-insights").Get(ctx, "insights-config", metav1.GetOptions{})
if err != nil {
return nil, []error{err}
}
insightsConfig := &config.InsightsConfigurationSerialized{}
cfg := cm.Data["config.yaml"]
err = yaml.Unmarshal([]byte(cfg), insightsConfig)
if err != nil {
return nil, []error{err}
}
return []record.Record{
{
Name: fmt.Sprintf("config/configmaps/%s/%s/%s", cm.Namespace, cm.Name, "config"),
Item: record.JSONMarshaller{Object: anonymizeInsightsConfig(insightsConfig)},
},
}, nil
}

func anonymizeInsightsConfig(conf *config.InsightsConfigurationSerialized) *config.InsightsConfigurationSerialized {
conf.Proxy.HTTPProxy = anonymize.String(conf.Proxy.HTTPProxy)
conf.Proxy.HTTPSProxy = anonymize.String(conf.Proxy.HTTPSProxy)
conf.Proxy.NoProxy = anonymize.String(conf.Proxy.NoProxy)
return conf
}

// ConfigMapAnonymizer implements serialization of configmap
// and potentially anonymizes if it is a certificate
type ConfigMapAnonymizer struct {
Expand Down