diff --git a/pkg/deployment/agent.go b/pkg/deployment/agent.go index 629e39c056..c6b90da394 100644 --- a/pkg/deployment/agent.go +++ b/pkg/deployment/agent.go @@ -58,7 +58,7 @@ func (a *Agent) Get() *appsv1.DaemonSet { configRest := util.GetPort("--http-server.host-port=", args, 5778) jgCompactTrft := util.GetPort("--processor.jaeger-compact.server-host-port=", args, 6831) jgBinaryTrft := util.GetPort("--processor.jaeger-binary.server-host-port=", args, 6832) - adminPort := util.GetPort("--admin-http-port=", args, 14271) + adminPort := util.GetAdminPort(args, 14271) trueVar := true falseVar := false diff --git a/pkg/deployment/all_in_one.go b/pkg/deployment/all_in_one.go index 561e421277..290062475e 100644 --- a/pkg/deployment/all_in_one.go +++ b/pkg/deployment/all_in_one.go @@ -42,7 +42,7 @@ func (a *AllInOne) Get() *appsv1.Deployment { args := append(a.jaeger.Spec.AllInOne.Options.ToArgs()) - adminPort := util.GetPort("--admin-http-port=", args, 14269) + adminPort := util.GetAdminPort(args, 14269) baseCommonSpec := v1.JaegerCommonSpec{ Annotations: map[string]string{ diff --git a/pkg/deployment/collector.go b/pkg/deployment/collector.go index 918a5c9fb9..44121f6b44 100644 --- a/pkg/deployment/collector.go +++ b/pkg/deployment/collector.go @@ -43,7 +43,7 @@ func (c *Collector) Get() *appsv1.Deployment { args := append(c.jaeger.Spec.Collector.Options.ToArgs()) - adminPort := util.GetPort("--admin-http-port=", args, 14269) + adminPort := util.GetAdminPort(args, 14269) baseCommonSpec := v1.JaegerCommonSpec{ Annotations: map[string]string{ diff --git a/pkg/deployment/ingester.go b/pkg/deployment/ingester.go index c11eea7cf6..0b7890b1af 100644 --- a/pkg/deployment/ingester.go +++ b/pkg/deployment/ingester.go @@ -49,7 +49,7 @@ func (i *Ingester) Get() *appsv1.Deployment { args := append(i.jaeger.Spec.Ingester.Options.ToArgs()) - adminPort := util.GetPort("--admin-http-port=", args, 14270) + adminPort := util.GetAdminPort(args, 14270) baseCommonSpec := v1.JaegerCommonSpec{ Annotations: map[string]string{ diff --git a/pkg/deployment/query.go b/pkg/deployment/query.go index a94b4bf4b0..16d117a69c 100644 --- a/pkg/deployment/query.go +++ b/pkg/deployment/query.go @@ -38,7 +38,7 @@ func (q *Query) Get() *appsv1.Deployment { args := append(q.jaeger.Spec.Query.Options.ToArgs()) - adminPort := util.GetPort("--admin-http-port=", args, 16687) + adminPort := util.GetAdminPort(args, 16687) baseCommonSpec := v1.JaegerCommonSpec{ Annotations: map[string]string{ diff --git a/pkg/inject/sidecar.go b/pkg/inject/sidecar.go index faee9e54af..f356073f8e 100644 --- a/pkg/inject/sidecar.go +++ b/pkg/inject/sidecar.go @@ -184,7 +184,7 @@ func container(jaeger *v1.Jaeger, dep *appsv1.Deployment) corev1.Container { configRest := util.GetPort("--http-server.host-port=", args, 5778) jgCompactTrft := util.GetPort("--processor.jaeger-compact.server-host-port=", args, 6831) jgBinaryTrft := util.GetPort("--processor.jaeger-binary.server-host-port=", args, 6832) - adminPort := util.GetPort("--admin-http-port=", args, 14271) + adminPort := util.GetAdminPort(args, 14271) if len(util.FindItem("--jaeger.tags=", args)) == 0 { agentTags := fmt.Sprintf("%s=%s,%s=%s,%s=%s,%s=%s,%s=%s", diff --git a/pkg/util/util.go b/pkg/util/util.go index a9b0a55c3e..d1b5bd4cf9 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -225,6 +225,19 @@ func GetPort(arg string, args []string, port int32) int32 { return port } +// GetAdminPort returns a port, either from supplied default port, or extracted from supplied arg value. +// If new admin port flag exists, it will extracted from the new flag, otherwise will try to extract +// from deprecated flag. +func GetAdminPort(args []string, port int32) int32 { + if portArg := FindItem("--admin.http.host-port=", args); len(portArg) > 0 { + port = GetPort("--admin.http.host-port=", args, port) + } else { + port = GetPort("--admin-http-port=", args, port) + } + + return port +} + // InitObjectMeta will set the required default settings to // kubernetes objects metadata if is required. func InitObjectMeta(obj metav1.Object) { diff --git a/pkg/util/util_test.go b/pkg/util/util_test.go index 5af76ba80d..0e0cf8e936 100644 --- a/pkg/util/util_test.go +++ b/pkg/util/util_test.go @@ -353,6 +353,35 @@ func TestGetPortSpecified(t *testing.T) { assert.Equal(t, int32(6831), GetPort("--processor.jaeger-compact.server-host-port=", args, 1234)) } +func TestGetAdminPortDefault(t *testing.T) { + opts := v1.NewOptions(map[string]interface{}{}) + + args := opts.ToArgs() + + assert.Equal(t, int32(1234), GetAdminPort(args, 1234)) +} + +func TestGetAdminPortDeprecatedFlagSpecified(t *testing.T) { + opts := v1.NewOptions(map[string]interface{}{ + "admin-http-port": ":1111", + }) + + args := opts.ToArgs() + + assert.Equal(t, int32(1111), GetAdminPort(args, 1234)) +} + +func TestGetAdminPortNewFlagSpecified(t *testing.T) { + opts := v1.NewOptions(map[string]interface{}{ + "admin-http-port": ":1111", + "admin.http.host-port": ":2222", + }) + + args := opts.ToArgs() + + assert.Equal(t, int32(2222), GetAdminPort(args, 1234)) +} + func TestInitObjectMeta(t *testing.T) { tests := map[string]struct { obj metav1.Object