Skip to content

Commit

Permalink
Remove explicitly setting agent's reporter type (#1168)
Browse files Browse the repository at this point in the history
Tchannel reporter has been removed in 1.18.0
The GRPC reporter was set as default in 1.11.0

Signed-off-by: Pavol Loffay <[email protected]>
  • Loading branch information
pavolloffay authored Aug 25, 2020
1 parent b2fcc57 commit 78ecb22
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 37 deletions.
1 change: 0 additions & 1 deletion deploy/examples/statefulset-manual-sidecar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,3 @@ spec:
protocol: TCP
args:
- --reporter.grpc.host-port=dns:///jaeger-collector-headless.example-ns:14250
- --reporter.type=grpc
1 change: 0 additions & 1 deletion deploy/examples/tracegen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ spec:
image: jaegertracing/jaeger-agent:1.17
args:
- --reporter.grpc.host-port=dns:///simple-prod-collector-headless.default:14250
- --reporter.type=grpc
env:
- name: POD_NAME
valueFrom:
Expand Down
12 changes: 4 additions & 8 deletions pkg/deployment/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,14 @@ func (a *Agent) Get() *appsv1.DaemonSet {

args := append(a.jaeger.Spec.Agent.Options.ToArgs())

if len(util.FindItem("--reporter.type=", args)) == 0 {
args = append(args, "--reporter.type=grpc")

// we only add the grpc host if we are adding the reporter type and there's no explicit value yet
if len(util.FindItem("--reporter.grpc.host-port=", args)) == 0 {
args = append(args, fmt.Sprintf("--reporter.grpc.host-port=dns:///%s.%s:14250", service.GetNameForHeadlessCollectorService(a.jaeger), a.jaeger.Namespace))
}
// we only add the grpc host if we are adding the reporter type and there's no explicit value yet
if len(util.FindItem("--reporter.grpc.host-port=", args)) == 0 {
args = append(args, fmt.Sprintf("--reporter.grpc.host-port=dns:///%s.%s:14250", service.GetNameForHeadlessCollectorService(a.jaeger), a.jaeger.Namespace))
}

// Enable tls by default for openshift platform
if viper.GetString("platform") == v1.FlagPlatformOpenShift {
if len(util.FindItem("--reporter.type=grpc", args)) > 0 && len(util.FindItem("--reporter.grpc.tls=true", args)) == 0 {
if len(util.FindItem("--reporter.grpc.tls=true", args)) == 0 {
args = append(args, "--reporter.grpc.tls.enabled=true")
args = append(args, fmt.Sprintf("--reporter.grpc.tls.ca=%s", ca.ServiceCAPath))
args = append(args, fmt.Sprintf("--reporter.grpc.tls.server-name=%s.%s.svc.cluster.local", service.GetNameForHeadlessCollectorService(a.jaeger), a.jaeger.Namespace))
Expand Down
14 changes: 5 additions & 9 deletions pkg/deployment/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,29 +175,26 @@ func TestAgentOrderOfArguments(t *testing.T) {
dep := a.Get()

assert.Len(t, dep.Spec.Template.Spec.Containers, 1)
assert.Len(t, dep.Spec.Template.Spec.Containers[0].Args, 5)
assert.Len(t, dep.Spec.Template.Spec.Containers[0].Args, 4)
assert.True(t, strings.HasPrefix(dep.Spec.Template.Spec.Containers[0].Args[0], "--a-option"))
assert.True(t, strings.HasPrefix(dep.Spec.Template.Spec.Containers[0].Args[1], "--b-option"))
assert.True(t, strings.HasPrefix(dep.Spec.Template.Spec.Containers[0].Args[2], "--c-option"))

// the following are added automatically
assert.True(t, strings.HasPrefix(dep.Spec.Template.Spec.Containers[0].Args[3], "--reporter.grpc.host-port"))
assert.True(t, strings.HasPrefix(dep.Spec.Template.Spec.Containers[0].Args[4], "--reporter.type"))
}

func TestAgentOverrideReporterType(t *testing.T) {
func TestAgentCustomReporterPort(t *testing.T) {
jaeger := v1.NewJaeger(types.NamespacedName{Name: "my-instance"})
jaeger.Spec.Agent.Strategy = "daemonset"
jaeger.Spec.Agent.Options = v1.NewOptions(map[string]interface{}{
"reporter.type": "thrift",
"reporter.thrift.host-port": "collector:14267",
"reporter.grpc.host-port": "collector:5000",
})

a := NewAgent(jaeger)
dep := a.Get()

assert.Equal(t, "--reporter.thrift.host-port=collector:14267", dep.Spec.Template.Spec.Containers[0].Args[0])
assert.Equal(t, "--reporter.type=thrift", dep.Spec.Template.Spec.Containers[0].Args[1])
assert.Equal(t, "--reporter.grpc.host-port=collector:5000", dep.Spec.Template.Spec.Containers[0].Args[0])
}

func TestAgentArgumentsOpenshiftTLS(t *testing.T) {
Expand All @@ -217,11 +214,10 @@ func TestAgentArgumentsOpenshiftTLS(t *testing.T) {
dep := a.Get()

assert.Len(t, dep.Spec.Template.Spec.Containers, 1)
assert.Len(t, dep.Spec.Template.Spec.Containers[0].Args, 6)
assert.Len(t, dep.Spec.Template.Spec.Containers[0].Args, 5)
assert.Greater(t, len(util.FindItem("--a-option=a-value", dep.Spec.Template.Spec.Containers[0].Args)), 0)

// the following are added automatically
assert.Greater(t, len(util.FindItem("--reporter.type=grpc", dep.Spec.Template.Spec.Containers[0].Args)), 0)
assert.Greater(t, len(util.FindItem("--reporter.grpc.host-port=dns:///my-instance-collector-headless.test:14250", dep.Spec.Template.Spec.Containers[0].Args)), 0)
assert.Greater(t, len(util.FindItem("--reporter.grpc.tls.enabled=true", dep.Spec.Template.Spec.Containers[0].Args)), 0)
assert.Greater(t, len(util.FindItem("--reporter.grpc.tls.ca="+ca.ServiceCAPath, dep.Spec.Template.Spec.Containers[0].Args)), 0)
Expand Down
12 changes: 4 additions & 8 deletions pkg/inject/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,18 +167,14 @@ func getJaeger(name string, jaegers *v1.JaegerList) *v1.Jaeger {
func container(jaeger *v1.Jaeger, dep *appsv1.Deployment) corev1.Container {
args := append(jaeger.Spec.Agent.Options.ToArgs())

if len(util.FindItem("--reporter.type=", args)) == 0 {
args = append(args, "--reporter.type=grpc")

// we only add the grpc host if we are adding the reporter type and there's no explicit value yet
if len(util.FindItem("--reporter.grpc.host-port=", args)) == 0 {
args = append(args, fmt.Sprintf("--reporter.grpc.host-port=dns:///%s.%s.svc:14250", service.GetNameForHeadlessCollectorService(jaeger), jaeger.Namespace))
}
// we only add the grpc host if we are adding the reporter type and there's no explicit value yet
if len(util.FindItem("--reporter.grpc.host-port=", args)) == 0 {
args = append(args, fmt.Sprintf("--reporter.grpc.host-port=dns:///%s.%s.svc:14250", service.GetNameForHeadlessCollectorService(jaeger), jaeger.Namespace))
}

// Enable tls by default for openshift platform
if viper.GetString("platform") == v1.FlagPlatformOpenShift {
if len(util.FindItem("--reporter.type=grpc", args)) > 0 && len(util.FindItem("--reporter.grpc.tls.enabled=true", args)) == 0 {
if len(util.FindItem("--reporter.grpc.tls.enabled=true", args)) == 0 {
args = append(args, "--reporter.grpc.tls.enabled=true")
args = append(args, fmt.Sprintf("--reporter.grpc.tls.ca=%s", ca.ServiceCAPath))
}
Expand Down
16 changes: 6 additions & 10 deletions pkg/inject/sidecar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,13 +502,12 @@ func TestSidecarOrderOfArguments(t *testing.T) {
dep = Sidecar(jaeger, dep)

assert.Len(t, dep.Spec.Template.Spec.Containers, 2)
assert.Len(t, dep.Spec.Template.Spec.Containers[1].Args, 6)
assert.Len(t, dep.Spec.Template.Spec.Containers[1].Args, 5)
containsOptionWithPrefix(t, dep.Spec.Template.Spec.Containers[1].Args, "--a-option")
containsOptionWithPrefix(t, dep.Spec.Template.Spec.Containers[1].Args, "--b-option")
containsOptionWithPrefix(t, dep.Spec.Template.Spec.Containers[1].Args, "--c-option")
containsOptionWithPrefix(t, dep.Spec.Template.Spec.Containers[1].Args, "--jaeger.tags")
containsOptionWithPrefix(t, dep.Spec.Template.Spec.Containers[1].Args, "--reporter.grpc.host-port")
containsOptionWithPrefix(t, dep.Spec.Template.Spec.Containers[1].Args, "--reporter.type")
agentTags := agentTags(dep.Spec.Template.Spec.Containers[1].Args)
assert.Contains(t, agentTags, "container.name=only_container")
}
Expand All @@ -528,20 +527,18 @@ func TestSidecarExplicitTags(t *testing.T) {
assert.Equal(t, []string{"key=val"}, agentTags)
}

func TestSidecarOverrideReporter(t *testing.T) {
func TestSidecarCustomReporterPort(t *testing.T) {
jaeger := v1.NewJaeger(types.NamespacedName{Name: "my-instance"})
jaeger.Spec.Agent.Options = v1.NewOptions(map[string]interface{}{
"reporter.type": "thrift",
"reporter.thrift.host-port": "collector:14267",
"reporter.grpc.host-port": "collector:5000",
})

dep := dep(map[string]string{}, map[string]string{})
dep = Sidecar(jaeger, dep)

assert.Len(t, dep.Spec.Template.Spec.Containers, 2)
assert.Len(t, dep.Spec.Template.Spec.Containers[1].Args, 3)
assert.Contains(t, dep.Spec.Template.Spec.Containers[1].Args, "--reporter.thrift.host-port=collector:14267")
assert.Contains(t, dep.Spec.Template.Spec.Containers[1].Args, "--reporter.type=thrift")
assert.Len(t, dep.Spec.Template.Spec.Containers[1].Args, 2)
assert.Contains(t, dep.Spec.Template.Spec.Containers[1].Args, "--reporter.grpc.host-port=collector:5000")
}

func TestSidecarAgentResources(t *testing.T) {
Expand Down Expand Up @@ -762,10 +759,9 @@ func TestSidecarArgumentsOpenshiftTLS(t *testing.T) {
dep = Sidecar(jaeger, dep)

assert.Len(t, dep.Spec.Template.Spec.Containers, 2)
assert.Len(t, dep.Spec.Template.Spec.Containers[1].Args, 6)
assert.Len(t, dep.Spec.Template.Spec.Containers[1].Args, 5)
assert.Greater(t, len(util.FindItem("--a-option=a-value", dep.Spec.Template.Spec.Containers[1].Args)), 0)
assert.Greater(t, len(util.FindItem("--jaeger.tags", dep.Spec.Template.Spec.Containers[1].Args)), 0)
assert.Greater(t, len(util.FindItem("--reporter.type=grpc", dep.Spec.Template.Spec.Containers[1].Args)), 0)
assert.Greater(t, len(util.FindItem("--reporter.grpc.host-port=dns:///my-instance-collector-headless.test.svc:14250", dep.Spec.Template.Spec.Containers[1].Args)), 0)
assert.Greater(t, len(util.FindItem("--reporter.grpc.tls.enabled=true", dep.Spec.Template.Spec.Containers[1].Args)), 0)
assert.Greater(t, len(util.FindItem("--reporter.grpc.tls.ca="+ca.ServiceCAPath, dep.Spec.Template.Spec.Containers[1].Args)), 0)
Expand Down

0 comments on commit 78ecb22

Please sign in to comment.