Skip to content

Commit

Permalink
Fix: svc port doesnt match istio convention (#2101)
Browse files Browse the repository at this point in the history
* fix https port name prefix to match istio naming convention

Signed-off-by: Benedikt Bongartz <[email protected]>

* verify service port names in e2e test

Signed-off-by: Benedikt Bongartz <[email protected]>

Signed-off-by: Benedikt Bongartz <[email protected]>
  • Loading branch information
frzifus authored Nov 3, 2022
1 parent 412329a commit 3101ed1
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 13 deletions.
19 changes: 12 additions & 7 deletions pkg/service/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,36 +96,41 @@ func GetNameForHeadlessCollectorService(jaeger *v1.Jaeger) string {
return util.DNSName(util.Truncate("%s-collector-headless", 63, jaeger.Name))
}

// GetPortNameForGRPC returns the port name for 'grpc'. It may either be http-grpc or https-grpc, based on whether
// GetPortNameForGRPC returns the port name for 'grpc'. It may either be
// tls-grpc-jaeger (secure) or grpc-jaeger (insecure), based on whether
// TLS is enabled for the agent-collector gRPC communication
func GetPortNameForGRPC(jaeger *v1.Jaeger) string {
const (
protoSecure = "tls-grpc-jaeger"
protoInsecure = "grpc-jaeger"
)
if viper.GetString("platform") == v1.FlagPlatformOpenShift {
// we always have TLS certs when running on OpenShift, so, TLS is always enabled
return "grpc-https"
return protoSecure
}

// if we don't have a jaeger provided, it's certainly not TLS...
if nil == jaeger {
return "grpc-http"
return protoInsecure
}

// perhaps the user has provisioned the certs and configured the CR manually?
// for that, we check whether the CLI option `collector.grpc.tls.enabled` was set for the collector
if val, ok := jaeger.Spec.Collector.Options.StringMap()["collector.grpc.tls.enabled"]; ok {
enabled, err := strconv.ParseBool(val)
if err != nil {
return "grpc-http" // not "true", defaults to false
return protoInsecure // not "true", defaults to false
}

if enabled {
return "grpc-https" // explicit true
return protoSecure // explicit true
}

return "grpc-http" // explicit false
return protoInsecure // explicit false
}

// doesn't look like we have TLS enabled
return "grpc-http"
return protoInsecure
}

func getTypeForCollectorService(jaeger *v1.Jaeger) corev1.ServiceType {
Expand Down
12 changes: 6 additions & 6 deletions pkg/service/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ func TestCollectorGRPCPortName(t *testing.T) {
{
"nil",
nil,
"grpc-http",
"grpc-jaeger",
false, // in openshift?
},
{
"no-tls",
&v1.Jaeger{},
"grpc-http",
"grpc-jaeger",
false, // in openshift?
},
{
Expand All @@ -84,7 +84,7 @@ func TestCollectorGRPCPortName(t *testing.T) {
},
},
},
"grpc-http",
"grpc-jaeger",
false, // in openshift?
},
{
Expand All @@ -96,7 +96,7 @@ func TestCollectorGRPCPortName(t *testing.T) {
},
},
},
"grpc-http",
"grpc-jaeger",
false, // in openshift?
},
{
Expand All @@ -108,13 +108,13 @@ func TestCollectorGRPCPortName(t *testing.T) {
},
},
},
"grpc-https",
"tls-grpc-jaeger",
false, // in openshift?
},
{
"in-openshift",
&v1.Jaeger{},
"grpc-https",
"tls-grpc-jaeger",
true, // in openshift?
},
} {
Expand Down
62 changes: 62 additions & 0 deletions tests/e2e/miscellaneous/istio/03-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,65 @@ spec:
- name: myapp
- name: jaeger-agent
- name: istio-proxy
---
apiVersion: v1
kind: Service
metadata:
name: simplest-collector-headless
spec:
ports:
- name: http-zipkin
port: 9411
protocol: TCP
targetPort: 9411
- name: grpc-jaeger
port: 14250
protocol: TCP
targetPort: 14250
- name: http-c-tchan-trft
port: 14267
protocol: TCP
targetPort: 14267
- name: http-c-binary-trft
port: 14268
protocol: TCP
targetPort: 14268
- name: grpc-otlp
port: 4317
protocol: TCP
targetPort: 4317
- name: http-otlp
port: 4318
protocol: TCP
targetPort: 4318
---
apiVersion: v1
kind: Service
metadata:
name: simplest-collector
spec:
ports:
- name: http-zipkin
port: 9411
protocol: TCP
targetPort: 9411
- name: grpc-jaeger
port: 14250
protocol: TCP
targetPort: 14250
- name: http-c-tchan-trft
port: 14267
protocol: TCP
targetPort: 14267
- name: http-c-binary-trft
port: 14268
protocol: TCP
targetPort: 14268
- name: grpc-otlp
port: 4317
protocol: TCP
targetPort: 4317
- name: http-otlp
port: 4318
protocol: TCP
targetPort: 4318

0 comments on commit 3101ed1

Please sign in to comment.