From d4fe58da193a55a04aed1a54583c645c58372a8e Mon Sep 17 00:00:00 2001 From: Roman Perekhod Date: Tue, 15 Oct 2024 16:50:38 +0200 Subject: [PATCH] the server probs added to the several services --- services/audit/pkg/server/debug/server.go | 9 ++++++++- services/clientlog/pkg/server/debug/server.go | 9 ++++++++- services/eventhistory/pkg/server/debug/server.go | 12 ++++++++++-- .../notifications/pkg/server/debug/server.go | 11 ++++++++++- services/search/pkg/server/debug/server.go | 16 +++++++++++++++- services/sse/pkg/server/debug/server.go | 9 ++++++++- services/userlog/pkg/server/debug/server.go | 9 ++++++++- 7 files changed, 67 insertions(+), 8 deletions(-) diff --git a/services/audit/pkg/server/debug/server.go b/services/audit/pkg/server/debug/server.go index 85136a94de8..f1599e0f7b2 100644 --- a/services/audit/pkg/server/debug/server.go +++ b/services/audit/pkg/server/debug/server.go @@ -17,6 +17,13 @@ func Server(opts ...Option) (*http.Server, error) { WithLogger(options.Logger), ) + readyHandler := handlers.NewCheckHandler( + handlers.NewCheckHandlerConfiguration(). + WithLogger(options.Logger). + WithCheck("nats reachability", handlers.NewNatsCheck(options.Config.Events.Cluster)). + WithInheritedChecksFrom(checkHandler.Conf), + ) + return debug.NewService( debug.Logger(options.Logger), debug.Name(options.Config.Service.Name), @@ -26,6 +33,6 @@ func Server(opts ...Option) (*http.Server, error) { debug.Pprof(options.Config.Debug.Pprof), debug.Zpages(options.Config.Debug.Zpages), debug.Health(checkHandler), - debug.Ready(checkHandler), + debug.Ready(readyHandler), ), nil } diff --git a/services/clientlog/pkg/server/debug/server.go b/services/clientlog/pkg/server/debug/server.go index 85136a94de8..f1599e0f7b2 100644 --- a/services/clientlog/pkg/server/debug/server.go +++ b/services/clientlog/pkg/server/debug/server.go @@ -17,6 +17,13 @@ func Server(opts ...Option) (*http.Server, error) { WithLogger(options.Logger), ) + readyHandler := handlers.NewCheckHandler( + handlers.NewCheckHandlerConfiguration(). + WithLogger(options.Logger). + WithCheck("nats reachability", handlers.NewNatsCheck(options.Config.Events.Cluster)). + WithInheritedChecksFrom(checkHandler.Conf), + ) + return debug.NewService( debug.Logger(options.Logger), debug.Name(options.Config.Service.Name), @@ -26,6 +33,6 @@ func Server(opts ...Option) (*http.Server, error) { debug.Pprof(options.Config.Debug.Pprof), debug.Zpages(options.Config.Debug.Zpages), debug.Health(checkHandler), - debug.Ready(checkHandler), + debug.Ready(readyHandler), ), nil } diff --git a/services/eventhistory/pkg/server/debug/server.go b/services/eventhistory/pkg/server/debug/server.go index 85136a94de8..e2bb0946626 100644 --- a/services/eventhistory/pkg/server/debug/server.go +++ b/services/eventhistory/pkg/server/debug/server.go @@ -14,7 +14,15 @@ func Server(opts ...Option) (*http.Server, error) { checkHandler := handlers.NewCheckHandler( handlers.NewCheckHandlerConfiguration(). - WithLogger(options.Logger), + WithLogger(options.Logger). + WithCheck("grpc reachability", handlers.NewGRPCCheck(options.Config.GRPC.Addr)), + ) + + readyHandler := handlers.NewCheckHandler( + handlers.NewCheckHandlerConfiguration(). + WithLogger(options.Logger). + WithCheck("nats reachability", handlers.NewNatsCheck(options.Config.Events.Cluster)). + WithInheritedChecksFrom(checkHandler.Conf), ) return debug.NewService( @@ -26,6 +34,6 @@ func Server(opts ...Option) (*http.Server, error) { debug.Pprof(options.Config.Debug.Pprof), debug.Zpages(options.Config.Debug.Zpages), debug.Health(checkHandler), - debug.Ready(checkHandler), + debug.Ready(readyHandler), ), nil } diff --git a/services/notifications/pkg/server/debug/server.go b/services/notifications/pkg/server/debug/server.go index 85136a94de8..8a71ca3cdd0 100644 --- a/services/notifications/pkg/server/debug/server.go +++ b/services/notifications/pkg/server/debug/server.go @@ -2,6 +2,7 @@ package debug import ( "net/http" + "strconv" "github.com/owncloud/ocis/v2/ocis-pkg/handlers" "github.com/owncloud/ocis/v2/ocis-pkg/service/debug" @@ -17,6 +18,14 @@ func Server(opts ...Option) (*http.Server, error) { WithLogger(options.Logger), ) + readyHandler := handlers.NewCheckHandler( + handlers.NewCheckHandlerConfiguration(). + WithLogger(options.Logger). + WithCheck("nats reachability", handlers.NewNatsCheck(options.Config.Notifications.Events.Cluster)). + WithCheck("smtp-check", handlers.NewTCPCheck(options.Config.Notifications.SMTP.Host+":"+strconv.Itoa(options.Config.Notifications.SMTP.Port))). + WithInheritedChecksFrom(checkHandler.Conf), + ) + return debug.NewService( debug.Logger(options.Logger), debug.Name(options.Config.Service.Name), @@ -26,6 +35,6 @@ func Server(opts ...Option) (*http.Server, error) { debug.Pprof(options.Config.Debug.Pprof), debug.Zpages(options.Config.Debug.Zpages), debug.Health(checkHandler), - debug.Ready(checkHandler), + debug.Ready(readyHandler), ), nil } diff --git a/services/search/pkg/server/debug/server.go b/services/search/pkg/server/debug/server.go index dc12c2b4b23..6d7bbd4740f 100644 --- a/services/search/pkg/server/debug/server.go +++ b/services/search/pkg/server/debug/server.go @@ -1,6 +1,7 @@ package debug import ( + "context" "net/http" "github.com/owncloud/ocis/v2/ocis-pkg/handlers" @@ -18,6 +19,19 @@ func Server(opts ...Option) (*http.Server, error) { WithCheck("grpc reachability", handlers.NewGRPCCheck(options.Config.GRPC.Addr)), ) + readyHandler := handlers.NewCheckHandler( + handlers.NewCheckHandlerConfiguration(). + WithLogger(options.Logger). + WithCheck("nats reachability", handlers.NewNatsCheck(options.Config.Events.Cluster)). + WithCheck("tika-check", func(ctx context.Context) error { + if options.Config.Extractor.Type == "tika" { + return handlers.NewTCPCheck(options.Config.Extractor.Tika.TikaURL)(ctx) + } + return nil + }). + WithInheritedChecksFrom(checkHandler.Conf), + ) + return debug.NewService( debug.Logger(options.Logger), debug.Name(options.Config.Service.Name), @@ -27,6 +41,6 @@ func Server(opts ...Option) (*http.Server, error) { debug.Pprof(options.Config.Debug.Pprof), debug.Zpages(options.Config.Debug.Zpages), debug.Health(checkHandler), - debug.Ready(checkHandler), + debug.Ready(readyHandler), ), nil } diff --git a/services/sse/pkg/server/debug/server.go b/services/sse/pkg/server/debug/server.go index 8d1462a72ac..de871207661 100644 --- a/services/sse/pkg/server/debug/server.go +++ b/services/sse/pkg/server/debug/server.go @@ -18,6 +18,13 @@ func Server(opts ...Option) (*http.Server, error) { WithCheck("web reachability", handlers.NewHTTPCheck(options.Config.HTTP.Addr)), ) + readyHandler := handlers.NewCheckHandler( + handlers.NewCheckHandlerConfiguration(). + WithLogger(options.Logger). + WithCheck("nats reachability", handlers.NewNatsCheck(options.Config.Events.Cluster)). + WithInheritedChecksFrom(checkHandler.Conf), + ) + return debug.NewService( debug.Logger(options.Logger), debug.Name(options.Config.Service.Name), @@ -27,6 +34,6 @@ func Server(opts ...Option) (*http.Server, error) { debug.Pprof(options.Config.Debug.Pprof), debug.Zpages(options.Config.Debug.Zpages), debug.Health(checkHandler), - debug.Ready(checkHandler), + debug.Ready(readyHandler), ), nil } diff --git a/services/userlog/pkg/server/debug/server.go b/services/userlog/pkg/server/debug/server.go index 8d1462a72ac..de871207661 100644 --- a/services/userlog/pkg/server/debug/server.go +++ b/services/userlog/pkg/server/debug/server.go @@ -18,6 +18,13 @@ func Server(opts ...Option) (*http.Server, error) { WithCheck("web reachability", handlers.NewHTTPCheck(options.Config.HTTP.Addr)), ) + readyHandler := handlers.NewCheckHandler( + handlers.NewCheckHandlerConfiguration(). + WithLogger(options.Logger). + WithCheck("nats reachability", handlers.NewNatsCheck(options.Config.Events.Cluster)). + WithInheritedChecksFrom(checkHandler.Conf), + ) + return debug.NewService( debug.Logger(options.Logger), debug.Name(options.Config.Service.Name), @@ -27,6 +34,6 @@ func Server(opts ...Option) (*http.Server, error) { debug.Pprof(options.Config.Debug.Pprof), debug.Zpages(options.Config.Debug.Zpages), debug.Health(checkHandler), - debug.Ready(checkHandler), + debug.Ready(readyHandler), ), nil }