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

[FIX]: adds case to handle kubeletstats reciever to ignore endpoint #558

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
6 changes: 6 additions & 0 deletions pkg/collector/parser/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ func singlePortFromConfigEndpoint(logger logr.Logger, name string, config map[in
case name == "tcplog" || name == "udplog":
endpoint = getAddressFromConfig(logger, name, listenAddressKey, config)

// ignore kubeletstats receiver as it holds the field key endpoint, and it
// is a scraper, we only expose endpoint through k8s service objects for
// receivers that aren't scrapers.
case name == "kubeletstats":
return nil

default:
endpoint = getAddressFromConfig(logger, name, endpointKey, config)
}
Expand Down
15 changes: 15 additions & 0 deletions pkg/collector/parser/receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,21 @@ func TestReceiverFailsWhenPortIsntString(t *testing.T) {
assert.Nil(t, p)
}

func TestIgnorekubeletstatsEndpoint(t *testing.T) {
// ignore "kubeletstats" receiver endpoint field, this is special case
// as this receiver gets parsed by generic receiver parser
builder := NewGenericReceiverParser(logger, "kubeletstats", map[interface{}]interface{}{
"endpoint": "0.0.0.0:9000",
})

// test
ports, err := builder.Ports()

// verify
assert.NoError(t, err)
assert.Len(t, ports, 0)
}

func TestReceiverFallbackWhenNotRegistered(t *testing.T) {
// test
p := For(logger, "myreceiver", map[interface{}]interface{}{})
Expand Down