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

Explicitly set Service Port Protocol for Jaeger Receivers #117

Merged
merged 4 commits into from
Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
8 changes: 8 additions & 0 deletions pkg/collector/parser/receiver_jaeger.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,27 @@ func (j *JaegerReceiverParser) Ports() ([]corev1.ServicePort, error) {
for _, protocol := range []struct {
name string
defaultPort int32
protocol corev1.Protocol
}{
{
name: "grpc",
defaultPort: defaultGRPCPort,
protocol: corev1.ProtocolTCP,
},
{
name: "thrift_http",
defaultPort: defaultThriftHTTPPort,
protocol: corev1.ProtocolTCP,
},
{
name: "thrift_compact",
defaultPort: defaultThriftCompactPort,
protocol: corev1.ProtocolUDP,
},
{
name: "thrift_binary",
defaultPort: defaultThriftBinaryPort,
protocol: corev1.ProtocolUDP,
},
} {
// do we have the protocol specified at all?
Expand All @@ -87,6 +92,9 @@ func (j *JaegerReceiverParser) Ports() ([]corev1.ServicePort, error) {
}
}

// set the appropriate TCP/UDP protocol for this kind of receiver protocol
protocolPort.Protocol = protocol.protocol
KingJ marked this conversation as resolved.
Show resolved Hide resolved

// at this point, we *have* a port specified, add it to the list of ports
ports = append(ports, *protocolPort)
}
Expand Down
13 changes: 9 additions & 4 deletions pkg/collector/parser/receiver_jaeger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

"github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"
)

func TestJaegerSelfRegisters(t *testing.T) {
Expand Down Expand Up @@ -34,6 +35,7 @@ func TestJaegerMinimalConfiguration(t *testing.T) {
assert.NoError(t, err)
assert.Len(t, ports, 1)
assert.EqualValues(t, 14250, ports[0].Port)
assert.EqualValues(t, corev1.ProtocolTCP, ports[0].Protocol)
}

func TestJaegerPortsOverridden(t *testing.T) {
Expand All @@ -53,6 +55,7 @@ func TestJaegerPortsOverridden(t *testing.T) {
assert.NoError(t, err)
assert.Len(t, ports, 1)
assert.EqualValues(t, 1234, ports[0].Port)
assert.EqualValues(t, corev1.ProtocolTCP, ports[0].Protocol)
}

func TestJaegerExposeDefaultPorts(t *testing.T) {
Expand All @@ -69,11 +72,12 @@ func TestJaegerExposeDefaultPorts(t *testing.T) {
expectedResults := map[string]struct {
portNumber int32
seen bool
protocol corev1.Protocol
}{
"jaeger-grpc": {portNumber: 14250},
"jaeger-thrift-http": {portNumber: 14268},
"jaeger-thrift-compact": {portNumber: 6831},
"jaeger-thrift-binary": {portNumber: 6832},
"jaeger-grpc": {portNumber: 14250, protocol: corev1.ProtocolTCP},
"jaeger-thrift-http": {portNumber: 14268, protocol: corev1.ProtocolTCP},
"jaeger-thrift-compact": {portNumber: 6831, protocol: corev1.ProtocolUDP},
"jaeger-thrift-binary": {portNumber: 6832, protocol: corev1.ProtocolUDP},
}

// test
Expand All @@ -88,6 +92,7 @@ func TestJaegerExposeDefaultPorts(t *testing.T) {
r.seen = true
expectedResults[port.Name] = r
assert.EqualValues(t, r.portNumber, port.Port)
assert.EqualValues(t, r.protocol, port.Protocol)
}
for k, v := range expectedResults {
assert.True(t, v.seen, "the port %s wasn't included in the service ports", k)
Expand Down