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

Separate Ports for GRPC and HTTP requests in Query Server #2387

Merged
merged 13 commits into from
Sep 11, 2020
Merged

Separate Ports for GRPC and HTTP requests in Query Server #2387

merged 13 commits into from
Sep 11, 2020

Conversation

rjs211
Copy link
Contributor

@rjs211 rjs211 commented Aug 13, 2020

Which problem is this PR solving?

Short description of the changes

  • separate the HTTP port and gRPC port for query server
  • TODO: define default port for gRPC and http is set

Signed-off-by: rjs211 <srivatsa211@gmail.com>
Signed-off-by: rjs211 <srivatsa211@gmail.com>
@rjs211 rjs211 requested a review from a team as a code owner August 13, 2020 05:03
@rjs211 rjs211 requested a review from objectiser August 13, 2020 05:03
@codecov
Copy link

codecov bot commented Aug 13, 2020

Codecov Report

Merging #2387 into master will decrease coverage by 0.03%.
The diff coverage is 95.65%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2387      +/-   ##
==========================================
- Coverage   95.57%   95.54%   -0.04%     
==========================================
  Files         208      208              
  Lines       10690    10741      +51     
==========================================
+ Hits        10217    10262      +45     
- Misses        401      404       +3     
- Partials       72       75       +3     
Impacted Files Coverage Δ
ports/ports.go 100.00% <ø> (ø)
cmd/query/app/server.go 89.14% <94.44%> (-4.19%) ⬇️
cmd/query/app/flags.go 100.00% <100.00%> (ø)
...lugin/sampling/strategystore/adaptive/processor.go 100.00% <0.00%> (+0.79%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5508165...dfe0c00. Read the comment docs.

@rjs211
Copy link
Contributor Author

rjs211 commented Aug 13, 2020

Is there any convention for defining new ports and port Numbers? (Need to add a default port of gRPC requests) query.grpc-server.host-port

@jpkrohling
Copy link
Contributor

For ports that are highly related, just use the next integer for the new port, if it's free. Like: 16686 for query-http and 16687 for query-grpc.

@rjs211
Copy link
Contributor Author

rjs211 commented Aug 13, 2020

I am going with 16685 for query-grpc (new port) and 16686 for query-http (existing port )( 16687 is already in use by query-admin)

@objectiser
Copy link
Contributor

@rjs211 @jpkrohling Wouldn't this be a breaking change then? Shouldn't the default value for both of the new flags be 16686, with the logic as suggested by Yuri - so that by default (with no flags) it will use cmux. So if users want them on separate ports, they will then decide which port numbers they want to use.

@rjs211
Copy link
Contributor Author

rjs211 commented Aug 13, 2020

@objectiser

The actual assignment is as follows:

  1. The values of {query.host-port , query.port, query.http-server.host-port, query.grpc-server.host-port } are initalized form the viper (including default values. At the end of this point, grpc and http flags have different default values )
  2. if neither of {query.host-port , query.port} is explicitly set and atleast one of {query.http-server.host-port, query.grpc-server.host-port} is set explicitly, then the current option with different values of http and grpc ports is returned.
  3. else (this includes no ports defined set case as well UPDATE: No ports "set" ), both query.http-server.host-port and query.grpc-server.host-port is assigned the value of {query.host-port , query.port} whichever is defined.

for now, default values of query.http-server.host-port or query.grpc-server.host-port are used in case of the second point (when one of them is defined).

This will be more significant when the usage of TLS is enabled for either or both of grpc and http (once http TLS is supported by #2337 ) and the use of two separate ports will be forced on the user (as explained by issue #2377 ).

@objectiser
Copy link
Contributor

@rjs211 Understand the reasons for having separate ports when TLS is being configured, but from the sounds of (1):

The values of {query.host-port , query.port, query.http-server.host-port, query.grpc-server.host-port } are initalized form the viper (including default values. At the end of this point, grpc and http flags have different default values )

the default behaviour (i.e. where no flags are defined) will be that grpc and http query ports are different. Therefore this is a breaking change?

@rjs211
Copy link
Contributor Author

rjs211 commented Aug 13, 2020

the case of No ports set or no flags set is (3). In that case, the value of query.host-port would be defined (it may not be explicitly set, in which case, it will hold default value). The conditional in (2) would fail if no ports / flags are set. Sorry, I got confused between set and defined.

@jpkrohling
Copy link
Contributor

Looks like we are all on the same page, but just to be clear: we should not have breaking changes.

Signed-off-by: rjs211 <srivatsa211@gmail.com>
Signed-off-by: rjs211 <srivatsa211@gmail.com>
Copy link
Contributor

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do a couple of manual tests, and there are a couple of minor things to change, but in general, LGTM.

cmd/query/app/flags.go Outdated Show resolved Hide resolved
cmd/query/app/flags.go Outdated Show resolved Hide resolved
cmd/query/app/flags_test.go Show resolved Hide resolved
cmd/query/app/flags_test.go Show resolved Hide resolved
cmd/query/app/server_test.go Outdated Show resolved Hide resolved
cmd/query/app/server_test.go Outdated Show resolved Hide resolved
cmd/query/app/server_test.go Outdated Show resolved Hide resolved
cmd/query/app/server_test.go Outdated Show resolved Hide resolved
cmd/query/app/flags.go Outdated Show resolved Hide resolved
@jpkrohling
Copy link
Contributor

For the manual test, I build a simple Go application that lists the services from a target Query server, and I can confirm that the gRPC changes from this PR works:

package main

import (
	"context"
	"flag"
	"fmt"

	"github.com/jaegertracing/jaeger/proto-gen/api_v2"
	_ "github.com/jaegertracing/jaeger/proto-gen/api_v2"
	"go.uber.org/zap"
	"google.golang.org/grpc"
)

func main() {
	logger, err := zap.NewDevelopment()
	if err != nil {
		fmt.Println(err)
		return
	}

	hostPort := flag.String("host-port", "localhost:16686", "the host-port to use when connecting to the remote Jaeger Query server")
	flag.Parse()

	fmt.Printf("Using host-port: %s\n", *hostPort)

	conn, err := grpc.Dial(*hostPort, grpc.WithInsecure())
	if err != nil {
		logger.Error("failed to connect to the collector", zap.Error(err))
	}
	defer conn.Close()

	client := api_v2.NewQueryServiceClient(conn)

	req := api_v2.GetServicesRequest{}
	resp, err := client.GetServices(context.Background(), &req)
	if err != nil {
		logger.Error("failed to get list of services", zap.Error(err))
		return
	}

	if len(resp.Services) == 0 {
		fmt.Println("No services at the target server.")
		return
	}

	fmt.Println("Available services at the target server:")
	for _, svc := range resp.Services {
		fmt.Printf("- %s\n", svc)
	}
}

cmd/query/app/flags.go Outdated Show resolved Hide resolved
ports/ports.go Outdated Show resolved Hide resolved
Signed-off-by: rjs211 <srivatsa211@gmail.com>

1. Added test cases for `HostPortToPort` method
2. Modified Depricated warning to reasonable date
Copy link
Contributor

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@jpkrohling
Copy link
Contributor

Anyone else wants to re-review? @yurishkuro ?

Copy link
Contributor

@albertteoh albertteoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good to me! Mostly minor comments.

cmd/query/app/flags.go Outdated Show resolved Hide resolved
cmd/query/app/flags.go Outdated Show resolved Hide resolved
ports/ports.go Outdated Show resolved Hide resolved
cmd/query/app/server.go Outdated Show resolved Hide resolved
cmd/query/app/server.go Outdated Show resolved Hide resolved
cmd/query/app/flags.go Outdated Show resolved Hide resolved
ports/ports_test.go Outdated Show resolved Hide resolved
cmd/query/app/flags.go Outdated Show resolved Hide resolved
ports/ports.go Outdated Show resolved Hide resolved
Signed-off-by: rjs211 <srivatsa211@gmail.com>
@albertteoh
Copy link
Contributor

@rjs211 please increase the patch code coverage.

Signed-off-by: rjs211 <srivatsa211@gmail.com>
Copy link
Contributor

@albertteoh albertteoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rjs211! LGTM

@jpkrohling jpkrohling merged commit 393e04d into jaegertracing:master Sep 11, 2020
@jpkrohling
Copy link
Contributor

Wonderful work, @rjs211! Thank you for your contribution!

@rjs211
Copy link
Contributor Author

rjs211 commented Sep 11, 2020

@jpkrohling @albertteoh @objectiser @yurishkuro Thank you very much for your guidance and patience. This is my first code contribution to opensource. Hope to contribute further.

@pavolloffay
Copy link
Member

pavolloffay commented Sep 16, 2020

This PR introduced warning message in OTEL all-in-one:

2020-09-16T16:18:41.492+0200	WARN	app/flags.go:111	Use of query.port and query.host-port is deprecated.  Use query.http-server.host-port and query.grpc-server.host-port instead
github.com/jaegertracing/jaeger/cmd/query/app.(*QueryOptions).InitPortsConfigFromViper
	/home/ploffay/projects/jaegertracing/jaeger/cmd/query/app/flags.go:111
github.com/jaegertracing/jaeger/cmd/query/app.(*QueryOptions).InitFromViper
	/home/ploffay/projects/jaegertracing/jaeger/cmd/query/app/flags.go:120
main.startQuery
	/home/ploffay/projects/jaegertracing/jaeger/cmd/opentelemetry/cmd/all-in-one/main.go:194
main.main
	/home/ploffay/projects/jaegertracing/jaeger/cmd/opentelemetry/cmd/all-in-one/main.go:152
runtime.main
	/home/ploffay/bin/go/src/runtime/proc.go:203

@rjs211
Copy link
Contributor Author

rjs211 commented Sep 16, 2020

I logged the warning intentionally as per my understanding of #2377 (comment) . Should have I not done that?

@pavolloffay
Copy link
Member

I have submitted a PR to fix it #2479

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Separate GRPC and HTTP ports for Query gRPC with TLS doesn't work with cmux in mixed mode
6 participants