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

[query] Change HTTP and TLS server configurations to use OTEL configurations #6023

Merged
merged 11 commits into from
Sep 28, 2024
Prev Previous commit
Next Next commit
Remove Redundant QueryOptionsBase Type
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
  • Loading branch information
mahadzaryab1 committed Sep 27, 2024
commit fd54aa694ca842c00588d4e69e4654f6ef9dfb17
2 changes: 1 addition & 1 deletion cmd/jaeger/internal/extension/jaegerquery/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var _ component.ConfigValidator = (*Config)(nil)

// Config represents the configuration for jaeger-query,
type Config struct {
queryApp.QueryOptionsBase `mapstructure:",squash"`
queryApp.QueryOptions `mapstructure:",squash"`
// Storage holds configuration related to the various data stores that are to be queried.
Storage Storage `mapstructure:"storage"`
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/jaeger/internal/extension/jaegerquery/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func NewFactory() extension.Factory {

func createDefaultConfig() component.Config {
return &Config{
QueryOptionsBase: app.QueryOptionsBase{
QueryOptions: app.QueryOptions{
HTTP: confighttp.ServerConfig{
Endpoint: ports.PortToHostPort(ports.QueryHTTP),
},
Expand Down
7 changes: 2 additions & 5 deletions cmd/jaeger/internal/extension/jaegerquery/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,8 @@ func (s *server) createMetricReader(host component.Host) (metricsstore.Reader, e
}

func (s *server) makeQueryOptions() *queryApp.QueryOptions {
mahadzaryab1 marked this conversation as resolved.
Show resolved Hide resolved
return &queryApp.QueryOptions{
QueryOptionsBase: s.config.QueryOptionsBase,

// TODO handle TLS
}
// TODO handle TLS
mahadzaryab1 marked this conversation as resolved.
Show resolved Hide resolved
return &s.config.QueryOptions
}

func (s *server) Shutdown(ctx context.Context) error {
Expand Down
20 changes: 2 additions & 18 deletions cmd/query/app/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ type UIConfig struct {
LogAccess bool `mapstructure:"log_access" valid:"optional"`
}

// QueryOptionsBase holds configuration for query service shared with jaeger-v2
type QueryOptionsBase struct {
// QueryOptions holds configuration for query service shared with jaeger-v2
type QueryOptions struct {
// BasePath is the base path for all HTTP routes.
BasePath string `mapstructure:"base_path"`
// UIConfig contains configuration related to the Jaeger UIConfig.
Expand All @@ -80,22 +80,6 @@ type QueryOptionsBase struct {
GRPC configgrpc.ServerConfig `mapstructure:"grpc"`
}

// QueryOptions holds configuration for query service
type QueryOptions struct {
QueryOptionsBase

// // AdditionalHeaders
// AdditionalHeaders http.Header
// // HTTPHostPort is the host:port address that the query service listens in on for http requests
// HTTPHostPort string
// // GRPCHostPort is the host:port address that the query service listens in on for gRPC requests
// GRPCHostPort string
// // TLSGRPC configures secure transport (Consumer to Query service GRPC API)
// TLSGRPC tlscfg.Options
// // TLSHTTP configures secure transport (Consumer to Query service HTTP API)
// TLSHTTP tlscfg.Options
}

// AddFlags adds flags for QueryOptions
func AddFlags(flagSet *flag.FlagSet) {
flagSet.Var(&config.StringSlice{}, queryAdditionalHeaders, `Additional HTTP response headers. Can be specified multiple times. Format: "Key: Value"`)
Expand Down
164 changes: 69 additions & 95 deletions cmd/query/app/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ func initTelSet(logger *zap.Logger, tracerProvider *jtracer.JTracer, hc *healthc
func TestServerError(t *testing.T) {
srv := &Server{
queryOptions: &QueryOptions{
QueryOptionsBase: QueryOptionsBase{
HTTP: confighttp.ServerConfig{Endpoint: ":-1"},
},
HTTP: confighttp.ServerConfig{Endpoint: ":-1"},
},
}
require.Error(t, srv.Start())
Expand All @@ -73,10 +71,8 @@ func TestCreateTLSServerSinglePortError(t *testing.T) {
telset := initTelSet(zaptest.NewLogger(t), jtracer.NoOp(), healthcheck.New())
_, err := NewServer(&querysvc.QueryService{}, nil,
&QueryOptions{
QueryOptionsBase: QueryOptionsBase{
HTTP: confighttp.ServerConfig{Endpoint: ":8080", TLSSetting: &tlsCfg},
GRPC: configgrpc.ServerConfig{NetAddr: confignet.AddrConfig{Endpoint: ":8080"}, TLSSetting: &tlsCfg},
},
HTTP: confighttp.ServerConfig{Endpoint: ":8080", TLSSetting: &tlsCfg},
GRPC: configgrpc.ServerConfig{NetAddr: confignet.AddrConfig{Endpoint: ":8080"}, TLSSetting: &tlsCfg},
},
tenancy.NewManager(&tenancy.Options{}), telset)
require.Error(t, err)
Expand All @@ -93,10 +89,8 @@ func TestCreateTLSGrpcServerError(t *testing.T) {
telset := initTelSet(zaptest.NewLogger(t), jtracer.NoOp(), healthcheck.New())
_, err := NewServer(&querysvc.QueryService{}, nil,
&QueryOptions{
QueryOptionsBase: QueryOptionsBase{
HTTP: confighttp.ServerConfig{Endpoint: ":8080"},
GRPC: configgrpc.ServerConfig{NetAddr: confignet.AddrConfig{Endpoint: ":8081"}, TLSSetting: &tlsCfg},
},
HTTP: confighttp.ServerConfig{Endpoint: ":8080"},
GRPC: configgrpc.ServerConfig{NetAddr: confignet.AddrConfig{Endpoint: ":8081"}, TLSSetting: &tlsCfg},
},
tenancy.NewManager(&tenancy.Options{}), telset)
require.Error(t, err)
Expand All @@ -113,10 +107,8 @@ func TestCreateTLSHttpServerError(t *testing.T) {
telset := initTelSet(zaptest.NewLogger(t), jtracer.NoOp(), healthcheck.New())
_, err := NewServer(&querysvc.QueryService{}, nil,
&QueryOptions{
QueryOptionsBase: QueryOptionsBase{
HTTP: confighttp.ServerConfig{Endpoint: ":8080", TLSSetting: &tlsCfg},
GRPC: configgrpc.ServerConfig{NetAddr: confignet.AddrConfig{Endpoint: ":8081"}},
},
HTTP: confighttp.ServerConfig{Endpoint: ":8080", TLSSetting: &tlsCfg},
GRPC: configgrpc.ServerConfig{NetAddr: confignet.AddrConfig{Endpoint: ":8081"}},
}, tenancy.NewManager(&tenancy.Options{}), telset)
require.Error(t, err)
}
Expand Down Expand Up @@ -377,18 +369,16 @@ func TestServerHTTPTLS(t *testing.T) {
}

serverOptions := &QueryOptions{
QueryOptionsBase: QueryOptionsBase{
BearerTokenPropagation: true,
HTTP: confighttp.ServerConfig{
Endpoint: ":0",
TLSSetting: test.TLS,
},
GRPC: configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: ":0",
},
TLSSetting: tlsGrpc,
BearerTokenPropagation: true,
HTTP: confighttp.ServerConfig{
Endpoint: ":0",
TLSSetting: test.TLS,
},
GRPC: configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: ":0",
},
TLSSetting: tlsGrpc,
},
}
flagsSvc := flags.NewService(ports.QueryAdminHTTP)
Expand Down Expand Up @@ -516,18 +506,16 @@ func TestServerGRPCTLS(t *testing.T) {
tlsHttp = enabledTLSCfg
}
serverOptions := &QueryOptions{
QueryOptionsBase: QueryOptionsBase{
BearerTokenPropagation: true,
HTTP: confighttp.ServerConfig{
Endpoint: ":0",
TLSSetting: tlsHttp,
},
GRPC: configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: ":0",
},
TLSSetting: test.TLS,
BearerTokenPropagation: true,
HTTP: confighttp.ServerConfig{
Endpoint: ":0",
TLSSetting: tlsHttp,
},
GRPC: configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: ":0",
},
TLSSetting: test.TLS,
},
}
flagsSvc := flags.NewService(ports.QueryAdminHTTP)
Expand Down Expand Up @@ -579,15 +567,13 @@ func TestServerBadHostPort(t *testing.T) {
telset := initTelSet(zaptest.NewLogger(t), jtracer.NoOp(), healthcheck.New())
_, err := NewServer(&querysvc.QueryService{}, nil,
&QueryOptions{
QueryOptionsBase: QueryOptionsBase{
BearerTokenPropagation: true,
HTTP: confighttp.ServerConfig{
Endpoint: "8080", // bad string, not :port
},
GRPC: configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: "127.0.0.1:8081",
},
BearerTokenPropagation: true,
HTTP: confighttp.ServerConfig{
Endpoint: "8080", // bad string, not :port
},
GRPC: configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: "127.0.0.1:8081",
},
},
},
Expand All @@ -597,15 +583,13 @@ func TestServerBadHostPort(t *testing.T) {

_, err = NewServer(&querysvc.QueryService{}, nil,
&QueryOptions{
QueryOptionsBase: QueryOptionsBase{
BearerTokenPropagation: true,
HTTP: confighttp.ServerConfig{
Endpoint: "127.0.0.1:8081",
},
GRPC: configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: "9123", // bad string, not :port
},
BearerTokenPropagation: true,
HTTP: confighttp.ServerConfig{
Endpoint: "127.0.0.1:8081",
},
GRPC: configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: "9123", // bad string, not :port
},
},
},
Expand Down Expand Up @@ -635,15 +619,13 @@ func TestServerInUseHostPort(t *testing.T) {
&querysvc.QueryService{},
nil,
&QueryOptions{
QueryOptionsBase: QueryOptionsBase{
BearerTokenPropagation: true,
HTTP: confighttp.ServerConfig{
Endpoint: tc.httpHostPort,
},
GRPC: configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: tc.grpcHostPort,
},
BearerTokenPropagation: true,
HTTP: confighttp.ServerConfig{
Endpoint: tc.httpHostPort,
},
GRPC: configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: tc.grpcHostPort,
},
},
},
Expand All @@ -665,16 +647,14 @@ func TestServerSinglePort(t *testing.T) {
telset := initTelSet(flagsSvc.Logger, jtracer.NoOp(), flagsSvc.HC())
server, err := NewServer(querySvc.qs, nil,
&QueryOptions{
QueryOptionsBase: QueryOptionsBase{
BearerTokenPropagation: true,
HTTP: confighttp.ServerConfig{
BearerTokenPropagation: true,
HTTP: confighttp.ServerConfig{
Endpoint: hostPort,
},
GRPC: configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: hostPort,
},
GRPC: configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: hostPort,
},
},
},
},
tenancy.NewManager(&tenancy.Options{}),
Expand Down Expand Up @@ -712,15 +692,13 @@ func TestServerGracefulExit(t *testing.T) {
telset := initTelSet(flagsSvc.Logger, jtracer.NoOp(), flagsSvc.HC())
server, err := NewServer(querySvc.qs, nil,
&QueryOptions{
QueryOptionsBase: QueryOptionsBase{
HTTP: confighttp.ServerConfig{
HTTP: confighttp.ServerConfig{
Endpoint: hostPort,
},
GRPC: configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: hostPort,
},
GRPC: configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: hostPort,
},
},
},
},
tenancy.NewManager(&tenancy.Options{}), telset)
Expand Down Expand Up @@ -756,15 +734,13 @@ func TestServerHandlesPortZero(t *testing.T) {
telset := initTelSet(flagsSvc.Logger, jtracer.NoOp(), flagsSvc.HC())
server, err := NewServer(querySvc, nil,
&QueryOptions{
QueryOptionsBase: QueryOptionsBase{
HTTP: confighttp.ServerConfig{
HTTP: confighttp.ServerConfig{
Endpoint: ":0",
},
GRPC: configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: ":0",
},
GRPC: configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: ":0",
},
},
},
},
tenancy.NewManager(&tenancy.Options{}),
Expand Down Expand Up @@ -807,17 +783,15 @@ func TestServerHTTPTenancy(t *testing.T) {
}

serverOptions := &QueryOptions{
QueryOptionsBase: QueryOptionsBase{
Tenancy: tenancy.Options{
Enabled: true,
}, HTTP: confighttp.ServerConfig{
Tenancy: tenancy.Options{
Enabled: true,
}, HTTP: confighttp.ServerConfig{
Endpoint: ":8080",
},
GRPC: configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: ":8080",
},
GRPC: configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: ":8080",
},
},
},
}
tenancyMgr := tenancy.NewManager(&serverOptions.Tenancy)
Expand Down
18 changes: 7 additions & 11 deletions cmd/query/app/static_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ func TestRegisterStaticHandlerPanic(t *testing.T) {
mux.NewRouter(),
logger,
&QueryOptions{
QueryOptionsBase: QueryOptionsBase{
UIConfig: UIConfig{
AssetsPath: "/foo/bar",
},
UIConfig: UIConfig{
AssetsPath: "/foo/bar",
},
},
querysvc.StorageCapabilities{ArchiveStorage: false},
Expand Down Expand Up @@ -111,14 +109,12 @@ func TestRegisterStaticHandler(t *testing.T) {
r = r.PathPrefix(testCase.basePath).Subrouter()
}
closer := RegisterStaticHandler(r, logger, &QueryOptions{
QueryOptionsBase: QueryOptionsBase{
UIConfig: UIConfig{
ConfigFile: testCase.UIConfigPath,
AssetsPath: "fixture",
LogAccess: testCase.logAccess,
},
BasePath: testCase.basePath,
UIConfig: UIConfig{
ConfigFile: testCase.UIConfigPath,
AssetsPath: "fixture",
LogAccess: testCase.logAccess,
},
BasePath: testCase.basePath,
},
querysvc.StorageCapabilities{ArchiveStorage: testCase.archiveStorage},
)
Expand Down
14 changes: 6 additions & 8 deletions cmd/query/app/token_propagation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,14 @@ func runQueryService(t *testing.T, esURL string) *Server {
}
server, err := NewServer(querySvc, nil,
&QueryOptions{
QueryOptionsBase: QueryOptionsBase{
BearerTokenPropagation: true,
HTTP: confighttp.ServerConfig{
BearerTokenPropagation: true,
HTTP: confighttp.ServerConfig{
Endpoint: ":0",
},
GRPC: configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: ":0",
},
GRPC: configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: ":0",
},
},
},
},
tenancy.NewManager(&tenancy.Options{}),
Expand Down