Skip to content
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
16 changes: 1 addition & 15 deletions cmd/query/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,6 @@ func createHTTPServer(
staticHandlerCloser: staticHandlerCloser,
}

// TODO why doesn't OTEL helper do that already?
Copy link
Member

Choose a reason for hiding this comment

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

hehe, my intuition was right at the time :-)

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
}

Expand Down Expand Up @@ -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))
Expand Down
10 changes: 7 additions & 3 deletions cmd/query/app/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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())
})
Comment on lines +125 to +129
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this error will now be thrown at start when we initialize the listener rather than when we create the server

}

var testCases = []struct {
Expand Down
Loading