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 gRPC flags for OpenShift when 'reporter.grpc.host-port' is defined #1584

Merged
merged 4 commits into from
Oct 20, 2021
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
4 changes: 4 additions & 0 deletions pkg/config/tls/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ func Update(jaeger *v1.Jaeger, commonSpec *v1.JaegerCommonSpec, options *[]strin
return
}

if len(util.FindItem("--reporter.grpc.host-port=", *options)) != 0 {
return
}

volume := corev1.Volume{
Name: configurationVolumeName(jaeger),
VolumeSource: corev1.VolumeSource{
Expand Down
15 changes: 15 additions & 0 deletions pkg/config/tls/tls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,18 @@ func TestUpdateWithTLSSecret(t *testing.T) {
assert.Equal(t, "--collector.grpc.tls.cert=/etc/tls-config/tls.crt", options[1])
assert.Equal(t, "--collector.grpc.tls.key=/etc/tls-config/tls.key", options[2])
}

func TestIgnoreDefaultTLSSecretWhenGrpcHostPortIsSet(t *testing.T) {
jaeger := v1.NewJaeger(types.NamespacedName{Name: "TestIgnoreDefaultTLSSecretWhenGrpcHostPortIsSet"})
viper.Set("platform", v1.FlagPlatformOpenShift)

commonSpec := v1.JaegerCommonSpec{}
options := []string{}
options = append(options, "--reporter.grpc.host-port=my.host-port.com")

Update(jaeger, &commonSpec, &options)
assert.Len(t, commonSpec.Volumes, 0)
assert.Len(t, commonSpec.VolumeMounts, 0)
assert.Len(t, options, 1)
assert.Equal(t, "--reporter.grpc.host-port=my.host-port.com", options[0])
}
3 changes: 2 additions & 1 deletion pkg/deployment/all_in_one.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ func (a *AllInOne) Get() *appsv1.Deployment {
// even though the agent is in the same process as the collector, they communicate via gRPC, and the collector has TLS enabled,
// as it might receive connections from external agents
if viper.GetString("platform") == v1.FlagPlatformOpenShift {
if len(util.FindItem("--reporter.grpc.tls.enabled=", options)) == 0 {
if len(util.FindItem("--reporter.grpc.host-port=", options)) == 0 &&
len(util.FindItem("--reporter.grpc.tls.enabled=", options)) == 0 {
options = append(options, "--reporter.grpc.tls.enabled=true")
options = append(options, fmt.Sprintf("--reporter.grpc.tls.ca=%s", ca.ServiceCAPath))
options = append(options, fmt.Sprintf("--reporter.grpc.tls.server-name=%s.%s.svc.cluster.local", service.GetNameForHeadlessCollectorService(a.jaeger), a.jaeger.Namespace))
Expand Down
16 changes: 16 additions & 0 deletions pkg/deployment/all_in_one_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,22 @@ func TestAllInOneArgumentsOpenshiftTLS(t *testing.T) {
"--collector.grpc.tls.enabled=true",
},
},
{
name: "Do not implicitly enable TLS when grpc.host-port is provided",
options: v1.NewOptions(map[string]interface{}{
"a-option": "a-value",
"reporter.grpc.host-port": "my.host-port.com",
}),
expectedArgs: []string{
"--a-option=a-value",
"--reporter.grpc.host-port=my.host-port.com",
"--sampling.strategies-file",
},
nonExpectedArgs: []string{
"--reporter.grpc.tls.enabled=true",
"--collector.grpc.tls.enabled=true",
},
},
} {
jaeger := v1.NewJaeger(types.NamespacedName{Name: "my-instance"})
jaeger.Spec.AllInOne.Options = tt.options
Expand Down