From e562835c49ab21c97b8a0394787648a429266640 Mon Sep 17 00:00:00 2001 From: Haoyu Sun Date: Wed, 15 Feb 2023 15:35:50 +0100 Subject: [PATCH] add toggle netlink implementation of netclass collector in Node Exporter. --- CHANGELOG.md | 1 + Documentation/api.md | 1 + .../nodeexportercollectornetclassconfig.adoc | 2 ++ pkg/manifests/config.go | 3 ++- pkg/manifests/manifests.go | 3 +++ pkg/manifests/manifests_test.go | 14 ++++++++++++++ pkg/manifests/types.go | 2 ++ 7 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3160c3fbb7..b054df506a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - [#1876](https://github.com/openshift/cluster-monitoring-operator/pull/1876) Add nodeExporter.collectors.tcpstat settings. - [#1888](https://github.com/openshift/cluster-monitoring-operator/pull/1888) Add nodeExporter.collectors.netdev settings. - [#1893](https://github.com/openshift/cluster-monitoring-operator/pull/1893) Add nodeExporter.collectors.netclass settings. +- [#1894](https://github.com/openshift/cluster-monitoring-operator/pull/1894) Add toggle netlink implementation of netclass collector in Node Exporter. ## 4.12 diff --git a/Documentation/api.md b/Documentation/api.md index 70accffbab..647ca46add 100644 --- a/Documentation/api.md +++ b/Documentation/api.md @@ -224,6 +224,7 @@ The `NodeExporterCollectorNetClassConfig` resource works as an on/off switch for | Property | Type | Description | | -------- | ---- | ----------- | | enabled | bool | A Boolean flag that enables or disables the `netclass` collector. | +| netlinkImpl | bool | A Boolean flag that activate the netlink implementation of the `netclass` collector. | [Back to TOC](#table-of-contents) diff --git a/Documentation/openshiftdocs/modules/nodeexportercollectornetclassconfig.adoc b/Documentation/openshiftdocs/modules/nodeexportercollectornetclassconfig.adoc index f54f112883..1403cb34de 100644 --- a/Documentation/openshiftdocs/modules/nodeexportercollectornetclassconfig.adoc +++ b/Documentation/openshiftdocs/modules/nodeexportercollectornetclassconfig.adoc @@ -20,6 +20,8 @@ Appears in: link:nodeexportercollectorconfig.adoc[NodeExporterCollectorConfig] | Property | Type | Description |enabled|bool|A Boolean flag that enables or disables the `netclass` collector. +|netlinkImpl|bool|A Boolean flag that activate the netlink implementation of the `netclass` collector. + |=== link:../index.adoc[Back to TOC] diff --git a/pkg/manifests/config.go b/pkg/manifests/config.go index 879a6e1a07..053e5ae1fa 100644 --- a/pkg/manifests/config.go +++ b/pkg/manifests/config.go @@ -208,7 +208,8 @@ func defaultClusterMonitoringConfiguration() ClusterMonitoringConfiguration { Enabled: true, }, NetClass: NodeExporterCollectorNetClassConfig{ - Enabled: true, + Enabled: true, + NetlinkImpl: true, }, }, }, diff --git a/pkg/manifests/manifests.go b/pkg/manifests/manifests.go index 8388cbb00c..126d431836 100644 --- a/pkg/manifests/manifests.go +++ b/pkg/manifests/manifests.go @@ -824,6 +824,9 @@ func (f *Factory) updateNodeExporterArgs(args []string) []string { if f.config.ClusterMonitoringConfiguration.NodeExporterConfig.Collectors.NetClass.Enabled { args = setArg(args, "--collector.netclass", "") + if f.config.ClusterMonitoringConfiguration.NodeExporterConfig.Collectors.NetClass.NetlinkImpl { + args = setArg(args, "--collector.netclass.netlink", "") + } } else { args = setArg(args, "--no-collector.netclass", "") } diff --git a/pkg/manifests/manifests_test.go b/pkg/manifests/manifests_test.go index 0780c8bf6f..5a8a3838a7 100644 --- a/pkg/manifests/manifests_test.go +++ b/pkg/manifests/manifests_test.go @@ -2838,6 +2838,7 @@ func TestNodeExporterCollectorSettings(t *testing.T) { "--no-collector.tcpstat", "--collector.netdev", "--collector.netclass", + "--collector.netclass.netlink", }, argsAbsent: []string{"--collector.cpufreq", "--collector.tcpstat", @@ -2889,6 +2890,19 @@ nodeExporter: argsPresent: []string{"--no-collector.netclass"}, argsAbsent: []string{"--collector.netclass"}, }, + { + name: "disable netlink mode in netclass collector", + config: ` +nodeExporter: + collectors: + netclass: + enabled: true + netlinkImpl: false +`, + argsPresent: []string{"--collector.netclass"}, + argsAbsent: []string{"--no-collector.netclass", + "--collector.netclass.netlink"}, + }, } for _, test := range tests { diff --git a/pkg/manifests/types.go b/pkg/manifests/types.go index db6535c6e9..93b56df197 100644 --- a/pkg/manifests/types.go +++ b/pkg/manifests/types.go @@ -343,6 +343,8 @@ type NodeExporterCollectorNetDevConfig struct { type NodeExporterCollectorNetClassConfig struct { // A Boolean flag that enables or disables the `netclass` collector. Enabled bool `json:"enabled,omitempty"` + // A Boolean flag that activate the netlink implementation of the `netclass` collector. + NetlinkImpl bool `json:"netlinkImpl,omitempty"` } // The `UserWorkloadConfiguration` resource defines the settings