diff --git a/docs/sources/shared/configuration.md b/docs/sources/shared/configuration.md index df40267e9ae8..5cd5ec255e9b 100644 --- a/docs/sources/shared/configuration.md +++ b/docs/sources/shared/configuration.md @@ -2237,19 +2237,19 @@ The `frontend_worker` configures the worker - running within the Loki querier - [id: | default = ""] # Configures the querier gRPC client used to communicate with the -# query-frontend. Shouldn't be used in conjunction with 'grpc_client_config'. +# query-frontend. This can't be used in conjunction with 'grpc_client_config'. # The CLI flags prefix for this block configuration is: # querier.frontend-grpc-client [query_frontend_grpc_client: ] # Configures the querier gRPC client used to communicate with the query-frontend -# and with the query-scheduler if 'query_scheduler_grpc_client' isn't defined. -# This shouldn't be used if 'query_frontend_grpc_client' is defined. +# and with the query-scheduler. This can't be used in conjunction with +# 'query_frontend_grpc_client' or 'query_scheduler_grpc_client'. # The CLI flags prefix for this block configuration is: querier.frontend-client [grpc_client_config: ] # Configures the querier gRPC client used to communicate with the -# query-scheduler. If not defined, 'grpc_client_config' is used instead. +# query-scheduler. This can't be used in conjunction with 'grpc_client_config'. # The CLI flags prefix for this block configuration is: # querier.scheduler-grpc-client [query_scheduler_grpc_client: ] diff --git a/pkg/loki/config_wrapper.go b/pkg/loki/config_wrapper.go index 2a4789fb9e60..4c8da5de23ae 100644 --- a/pkg/loki/config_wrapper.go +++ b/pkg/loki/config_wrapper.go @@ -689,21 +689,17 @@ func applyChunkRetain(cfg, defaults *ConfigWrapper) { } func applyCommonQuerierWorkerGRPCConfig(cfg, defaults *ConfigWrapper) error { - if !reflect.DeepEqual(cfg.Worker.OldQueryFrontendGRPCClientConfig, defaults.Worker.OldQueryFrontendGRPCClientConfig) { - // User is using the old grpc configuration. - - if reflect.DeepEqual(cfg.Worker.NewQueryFrontendGRPCClientConfig, defaults.Worker.NewQueryFrontendGRPCClientConfig) { - // User is using the old grpc configuration only, we can just copy it to the new grpc client struct. - cfg.Worker.NewQueryFrontendGRPCClientConfig = cfg.Worker.OldQueryFrontendGRPCClientConfig - } else { - // User is using both, old and new way of configuring the grpc client, so we throw an error. - return fmt.Errorf("both `grpc_client_config` and `query_frontend_grpc_client` are set at the same time. Please use only one of them") - } + usingNewFrontendCfg := !reflect.DeepEqual(cfg.Worker.NewQueryFrontendGRPCClientConfig, defaults.Worker.NewQueryFrontendGRPCClientConfig) + usingNewSchedulerCfg := !reflect.DeepEqual(cfg.Worker.QuerySchedulerGRPCClientConfig, defaults.Worker.QuerySchedulerGRPCClientConfig) + usingOldFrontendCfg := !reflect.DeepEqual(cfg.Worker.OldQueryFrontendGRPCClientConfig, defaults.Worker.OldQueryFrontendGRPCClientConfig) - if reflect.DeepEqual(cfg.Worker.QuerySchedulerGRPCClientConfig, defaults.Worker.QuerySchedulerGRPCClientConfig) { - // Since the scheduler grpc client is not set, we can just copy the old query frontend grpc client to the scheduler grpc client. - cfg.Worker.QuerySchedulerGRPCClientConfig = cfg.Worker.OldQueryFrontendGRPCClientConfig + if usingOldFrontendCfg { + if usingNewFrontendCfg || usingNewSchedulerCfg { + return fmt.Errorf("both `grpc_client_config` and (`query_frontend_grpc_client` or `query_scheduler_grpc_client`) are set at the same time. Please use only `query_frontend_grpc_client` and `query_scheduler_grpc_client`") } + cfg.Worker.NewQueryFrontendGRPCClientConfig = cfg.Worker.OldQueryFrontendGRPCClientConfig + cfg.Worker.QuerySchedulerGRPCClientConfig = cfg.Worker.OldQueryFrontendGRPCClientConfig } + return nil } diff --git a/pkg/querier/worker/worker.go b/pkg/querier/worker/worker.go index 7d7b46dc814f..0c13bdd6df9d 100644 --- a/pkg/querier/worker/worker.go +++ b/pkg/querier/worker/worker.go @@ -30,10 +30,10 @@ type Config struct { QuerierID string `yaml:"id"` - NewQueryFrontendGRPCClientConfig grpcclient.Config `yaml:"query_frontend_grpc_client" doc:"description=Configures the querier gRPC client used to communicate with the query-frontend. Shouldn't be used in conjunction with 'grpc_client_config'."` - OldQueryFrontendGRPCClientConfig grpcclient.Config `yaml:"grpc_client_config" doc:"description=Configures the querier gRPC client used to communicate with the query-frontend and with the query-scheduler if 'query_scheduler_grpc_client' isn't defined. This shouldn't be used if 'query_frontend_grpc_client' is defined."` + NewQueryFrontendGRPCClientConfig grpcclient.Config `yaml:"query_frontend_grpc_client" doc:"description=Configures the querier gRPC client used to communicate with the query-frontend. This can't be used in conjunction with 'grpc_client_config'."` + OldQueryFrontendGRPCClientConfig grpcclient.Config `yaml:"grpc_client_config" doc:"description=Configures the querier gRPC client used to communicate with the query-frontend and with the query-scheduler. This can't be used in conjunction with 'query_frontend_grpc_client' or 'query_scheduler_grpc_client'."` - QuerySchedulerGRPCClientConfig grpcclient.Config `yaml:"query_scheduler_grpc_client" doc:"description=Configures the querier gRPC client used to communicate with the query-scheduler. If not defined, 'grpc_client_config' is used instead."` + QuerySchedulerGRPCClientConfig grpcclient.Config `yaml:"query_scheduler_grpc_client" doc:"description=Configures the querier gRPC client used to communicate with the query-scheduler. This can't be used in conjunction with 'grpc_client_config'."` } func (cfg *Config) RegisterFlags(f *flag.FlagSet) {