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

[Backport 7.61.x] [NDM] Do not always log error on SNMP Autodiscovery unmarshal failure #32436

Open
wants to merge 1 commit into
base: 7.61.x
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion pkg/config/autodiscovery/autodiscovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
package autodiscovery

import (
"errors"

"github.com/DataDog/datadog-agent/comp/core/autodiscovery/providers"
"github.com/DataDog/datadog-agent/comp/core/autodiscovery/providers/names"
"github.com/DataDog/datadog-agent/pkg/config/env"
Expand Down Expand Up @@ -77,7 +79,7 @@ func DiscoverComponentsFromConfig() ([]pkgconfigsetup.ConfigurationProviders, []
// Auto-activate autodiscovery without listeners: - snmp
snmpConfig, err := snmplistener.NewListenerConfig()

if err != nil {
if err != nil && !errors.Is(err, snmplistener.ErrNoConfigGiven) {
log.Errorf("Error unmarshalling snmp listener config. Error: %v", err)
} else if len(snmpConfig.Configs) > 0 {
detectedListeners = append(detectedListeners, pkgconfigsetup.Listeners{Name: "snmp"})
Expand Down
5 changes: 4 additions & 1 deletion pkg/snmp/snmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ type intOrBoolPtr interface {
*int | *bool
}

// ErrNoConfigGiven is returned when the SNMP listener config was not found
var ErrNoConfigGiven = errors.New("no config given for snmp_listener")

// NewListenerConfig parses configuration and returns a built ListenerConfig
func NewListenerConfig() (ListenerConfig, error) {
var snmpConfig ListenerConfig
Expand All @@ -114,7 +117,7 @@ func NewListenerConfig() (ListenerConfig, error) {
return snmpConfig, err
}
} else {
return snmpConfig, errors.New("no config given for snmp_listener")
return snmpConfig, ErrNoConfigGiven
}

if snmpConfig.AllowedFailures == 0 && snmpConfig.AllowedFailuresLegacy != 0 {
Expand Down
Loading