diff --git a/cmd/query/app/server.go b/cmd/query/app/server.go index 70dcecd86f4..8e971a6eb3e 100644 --- a/cmd/query/app/server.go +++ b/cmd/query/app/server.go @@ -228,15 +228,6 @@ func createHTTPServer( staticHandlerCloser: staticHandlerCloser, } - // TODO why doesn't OTEL helper do that already? - if queryOpts.HTTP.TLSSetting != nil { - tlsCfg, err := queryOpts.HTTP.TLSSetting.LoadTLSConfig(ctx) // This checks if the certificates are correctly provided - if err != nil { - return nil, errors.Join(err, staticHandlerCloser.Close()) - } - server.TLSConfig = tlsCfg - } - return server, nil } @@ -327,12 +318,7 @@ func (s *Server) Start(ctx context.Context) error { go func() { defer s.bgFinished.Done() s.Logger.Info("Starting HTTP server", zap.Int("port", httpPort), zap.String("addr", s.queryOptions.HTTP.Endpoint)) - var err error - if s.queryOptions.HTTP.TLSSetting != nil { - err = s.httpServer.ServeTLS(s.httpConn, "", "") - } else { - err = s.httpServer.Serve(s.httpConn) - } + err := s.httpServer.Serve(s.httpConn) if err != nil && !errors.Is(err, http.ErrServerClosed) && !errors.Is(err, cmux.ErrListenerClosed) && !errors.Is(err, cmux.ErrServerClosed) { s.Logger.Error("Could not start HTTP server", zap.Error(err)) s.ReportStatus(componentstatus.NewFatalErrorEvent(err)) diff --git a/cmd/query/app/server_test.go b/cmd/query/app/server_test.go index 1bbc9993724..8b925cc9a18 100644 --- a/cmd/query/app/server_test.go +++ b/cmd/query/app/server_test.go @@ -108,7 +108,7 @@ func TestCreateTLSGrpcServerError(t *testing.T) { require.Error(t, err) } -func TestCreateTLSHttpServerError(t *testing.T) { +func TestStartTLSHttpServerError(t *testing.T) { tlsCfg := configtls.ServerConfig{ ClientCAFile: "invalid/path", Config: configtls.Config{ @@ -117,12 +117,16 @@ func TestCreateTLSHttpServerError(t *testing.T) { }, } telset := initTelSet(zaptest.NewLogger(t), jtracer.NoOp(), healthcheck.New()) - _, err := NewServer(context.Background(), &querysvc.QueryService{}, nil, + s, err := NewServer(context.Background(), &querysvc.QueryService{}, nil, &QueryOptions{ HTTP: confighttp.ServerConfig{Endpoint: ":8080", TLSSetting: &tlsCfg}, GRPC: configgrpc.ServerConfig{NetAddr: confignet.AddrConfig{Endpoint: ":8081", Transport: confignet.TransportTypeTCP}}, }, tenancy.NewManager(&tenancy.Options{}), telset) - require.Error(t, err) + require.NoError(t, err) + require.Error(t, s.Start(context.Background())) + t.Cleanup(func() { + require.NoError(t, s.Close()) + }) } var testCases = []struct {