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

Use New Admin Port Flag #1281

Merged
merged 1 commit into from
Oct 29, 2020
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
2 changes: 1 addition & 1 deletion pkg/deployment/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/deployment/all_in_one.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion pkg/deployment/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion pkg/deployment/ingester.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion pkg/deployment/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion pkg/inject/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 13 additions & 0 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
36 changes: 36 additions & 0 deletions pkg/util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,42 @@ func TestGetPortSpecified(t *testing.T) {
assert.Equal(t, int32(6831), GetPort("--processor.jaeger-compact.server-host-port=", args, 1234))
}

func TestGetAdminPort(t *testing.T) {
tests := map[string]struct {
opts v1.Options
defaultPort int32
expectedPort int32
}{
"Use default port when no admin port flag provided": {
opts: v1.NewOptions(map[string]interface{}{}),
defaultPort: 1234,
expectedPort: 1234,
},
"Use deprecated flag when new flag not provided and deprecated flag provided": {
opts: v1.NewOptions(map[string]interface{}{
"admin-http-port": ":1111",
}),
defaultPort: 1234,
expectedPort: 1111,
},
"Use new flag when provided": {
opts: v1.NewOptions(map[string]interface{}{
"admin-http-port": ":1111",
"admin.http.host-port": ":2222",
}),
defaultPort: 1234,
expectedPort: 2222,
},
}

for name, test := range tests {
t.Run(name, func(t *testing.T) {
args := test.opts.ToArgs()
assert.Equal(t, test.expectedPort, GetAdminPort(args, test.defaultPort))
})
}
}

func TestInitObjectMeta(t *testing.T) {
tests := map[string]struct {
obj metav1.Object
Expand Down