From fec4640b5ac36db1b7c549e9c5a493a9182b14cb Mon Sep 17 00:00:00 2001 From: Alex Ababii Date: Tue, 11 Aug 2026 11:15:31 +0200 Subject: [PATCH] eventhistory: debug service always enabled --- pkg/shared/errors.go | 8 +++++++ services/eventhistory/pkg/command/server.go | 24 ++++++++----------- services/eventhistory/pkg/config/config.go | 4 ++-- services/eventhistory/pkg/config/debug.go | 9 ++++--- .../eventhistory/pkg/config/parser/parse.go | 6 ++--- 5 files changed, 26 insertions(+), 25 deletions(-) diff --git a/pkg/shared/errors.go b/pkg/shared/errors.go index cb0f487c3a..6052402a06 100644 --- a/pkg/shared/errors.go +++ b/pkg/shared/errors.go @@ -101,3 +101,11 @@ func MissingURLSigningSecret(service string) error { "the config/corresponding environment variable).", service, defaults.BaseConfigPath()) } + +func AllComponentsDisabledError(service string) error { + return fmt.Errorf("All request handlers and event consumers are disabled for %s; at least one component must be enabled."+ + "Make sure your %s config contains the proper values "+ + "(e.g. by using 'opencloud init --diff' and applying the patch or setting a value manually in "+ + "the config/corresponding environment variable).", + service, defaults.BaseConfigPath()) +} diff --git a/services/eventhistory/pkg/command/server.go b/services/eventhistory/pkg/command/server.go index 43b90a6722..48e489d685 100644 --- a/services/eventhistory/pkg/command/server.go +++ b/services/eventhistory/pkg/command/server.go @@ -109,22 +109,18 @@ func Server(cfg *config.Config) *cobra.Command { logger.Info().Msg("gRPC server disabled, not starting gRPC service") } - if !cfg.Debug.Disabled { - debugServer, err := debug.Server( - debug.Logger(logger), - debug.Context(ctx), - debug.Config(cfg), - ) - if err != nil { - logger.Info().Err(err).Str("server", "debug").Msg("Failed to initialize server") - return err - } - - gr.Add(runner.NewGolangHttpServerRunner(cfg.Service.Name+".debug", debugServer)) - } else { - logger.Info().Msg("debug server disabled") + debugServer, err := debug.Server( + debug.Logger(logger), + debug.Context(ctx), + debug.Config(cfg), + ) + if err != nil { + logger.Info().Err(err).Str("server", "debug").Msg("Failed to initialize server") + return err } + gr.Add(runner.NewGolangHttpServerRunner(cfg.Service.Name+".debug", debugServer)) + grResults := gr.Run(ctx) // return the first non-nil error found in the results diff --git a/services/eventhistory/pkg/config/config.go b/services/eventhistory/pkg/config/config.go index 261ccbcee3..9c8908e47d 100644 --- a/services/eventhistory/pkg/config/config.go +++ b/services/eventhistory/pkg/config/config.go @@ -32,7 +32,7 @@ type GRPCConfig struct { Addr string `yaml:"addr" env:"EVENTHISTORY_GRPC_ADDR" desc:"The bind address of the GRPC service." introductionVersion:"1.0.0"` Namespace string `yaml:"-"` TLS *shared.GRPCServiceTLS `yaml:"tls"` - Disabled bool `yaml:"disabled" env:"EVENTHISTORY_GRPC_DISABLED" desc:"Disables the GRPC service. Set this to true if the service should only handle events." introductionVersion:"4.0.0"` + Disabled bool `yaml:"disabled" env:"EVENTHISTORY_GRPC_DISABLED" desc:"Disables the GRPC service. Set this to true if the service should only handle events." introductionVersion:"%NEXT%"` } // Store configures the store to use @@ -58,5 +58,5 @@ type Events struct { EnableTLS bool `yaml:"enable_tls" env:"OC_EVENTS_ENABLE_TLS;EVENTHISTORY_EVENTS_ENABLE_TLS" desc:"Enable TLS for the connection to the events broker. The events broker is the OpenCloud service which receives and delivers events between the services." introductionVersion:"1.0.0"` AuthUsername string `yaml:"username" env:"OC_EVENTS_AUTH_USERNAME;EVENTHISTORY_EVENTS_AUTH_USERNAME" desc:"The username to authenticate with the events broker. The events broker is the OpenCloud service which receives and delivers events between the services." introductionVersion:"1.0.0"` AuthPassword string `yaml:"password" env:"OC_EVENTS_AUTH_PASSWORD;EVENTHISTORY_EVENTS_AUTH_PASSWORD" desc:"The password to authenticate with the events broker. The events broker is the OpenCloud service which receives and delivers events between the services." introductionVersion:"1.0.0"` - Disabled bool `yaml:"disabled" env:"EVENTHISTORY_EVENTS_DISABLED" desc:"Disables listening for events. Set this to true if the service should only handle GRPC requests." introductionVersion:"4.0.0"` + Disabled bool `yaml:"disabled" env:"EVENTHISTORY_EVENTS_DISABLED" desc:"Disables listening for events. Set this to true if the service should only handle GRPC requests." introductionVersion:"%NEXT%"` } diff --git a/services/eventhistory/pkg/config/debug.go b/services/eventhistory/pkg/config/debug.go index 5fa054ee04..3cf611756a 100644 --- a/services/eventhistory/pkg/config/debug.go +++ b/services/eventhistory/pkg/config/debug.go @@ -2,9 +2,8 @@ package config // Debug defines the available debug configuration. type Debug struct { - Addr string `yaml:"addr" env:"EVENTHISTORY_DEBUG_ADDR" desc:"Bind address of the debug server, where metrics, health, config and debug endpoints will be exposed." introductionVersion:"1.0.0"` - Token string `yaml:"token" env:"EVENTHISTORY_DEBUG_TOKEN" desc:"Token to secure the metrics endpoint." introductionVersion:"1.0.0"` - Pprof bool `yaml:"pprof" env:"EVENTHISTORY_DEBUG_PPROF" desc:"Enables pprof, which can be used for profiling." introductionVersion:"1.0.0"` - Zpages bool `yaml:"zpages" env:"EVENTHISTORY_DEBUG_ZPAGES" desc:"Enables zpages, which can be used for collecting and viewing in-memory traces." introductionVersion:"1.0.0"` - Disabled bool `yaml:"disabled" env:"EVENTHISTORY_DEBUG_DISABLED" desc:"Disables the debug server, including the /metrics, /healthz and /readyz endpoints." introductionVersion:"4.0.0"` + Addr string `yaml:"addr" env:"EVENTHISTORY_DEBUG_ADDR" desc:"Bind address of the debug server, where metrics, health, config and debug endpoints will be exposed." introductionVersion:"1.0.0"` + Token string `yaml:"token" env:"EVENTHISTORY_DEBUG_TOKEN" desc:"Token to secure the metrics endpoint." introductionVersion:"1.0.0"` + Pprof bool `yaml:"pprof" env:"EVENTHISTORY_DEBUG_PPROF" desc:"Enables pprof, which can be used for profiling." introductionVersion:"1.0.0"` + Zpages bool `yaml:"zpages" env:"EVENTHISTORY_DEBUG_ZPAGES" desc:"Enables zpages, which can be used for collecting and viewing in-memory traces." introductionVersion:"1.0.0"` } diff --git a/services/eventhistory/pkg/config/parser/parse.go b/services/eventhistory/pkg/config/parser/parse.go index 8c21db9fea..01d224e33e 100644 --- a/services/eventhistory/pkg/config/parser/parse.go +++ b/services/eventhistory/pkg/config/parser/parse.go @@ -4,6 +4,7 @@ import ( "errors" occfg "github.com/opencloud-eu/opencloud/pkg/config" + "github.com/opencloud-eu/opencloud/pkg/shared" "github.com/opencloud-eu/opencloud/services/eventhistory/pkg/config" "github.com/opencloud-eu/opencloud/services/eventhistory/pkg/config/defaults" @@ -34,11 +35,8 @@ func ParseConfig(cfg *config.Config) error { // Validate validates the config func Validate(cfg *config.Config) error { - // this need to be discussed, I put it here for now because I belive we need to ensure that the service is doing - // at least something, if we have events and grpc disabled that means that the service is doing actually nothing - // which can be a siletlly ignorred and cause issues in the future if cfg.Events.Disabled && cfg.GRPC.Disabled { - return errors.New("both events and gRPC are disabled; at least one must be enabled") + return shared.AllComponentsDisabledError(cfg.Service.Name) } return nil