Skip to content

Commit

Permalink
use new admin port flag
Browse files Browse the repository at this point in the history
will check the new flag for retrieving admin port and if not
available will use the old one instead

Signed-off-by: johanavril <[email protected]>
  • Loading branch information
johanavril committed Oct 29, 2020
1 parent fda5695 commit 80ee898
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 6 deletions.
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
29 changes: 29 additions & 0 deletions pkg/util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 80ee898

Please sign in to comment.