From bf54bcc29ce452782dd4bb5d9d699fd586e9bab5 Mon Sep 17 00:00:00 2001 From: Edward Welch Date: Wed, 3 Apr 2024 20:48:08 +0000 Subject: [PATCH] try to better clarify when there are multiple errors Signed-off-by: Edward Welch --- pkg/loki/loki.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pkg/loki/loki.go b/pkg/loki/loki.go index 3e366f6a3cde3..00640d57337c3 100644 --- a/pkg/loki/loki.go +++ b/pkg/loki/loki.go @@ -274,7 +274,7 @@ func (c *Config) Validate() error { } } - var combinedErrors error + var errs []error // Schema version 13 is required to use structured metadata p := config.ActivePeriodConfig(c.SchemaConfig.Configs) @@ -283,14 +283,21 @@ func (c *Config) Validate() error { return err } if c.LimitsConfig.AllowStructuredMetadata && version < 13 { - combinedErrors = stdlib_errors.Join(combinedErrors, fmt.Errorf("CONFIG ERROR: schema v13 is required to store Structured Metadata and use native OTLP ingestion, your schema version is %s. Set `allow_structured_metadata: false` in the `limits_config` section or set the command line argument `-validation.allow-structured-metadata=false` and restart Loki. Then proceed to update to schema v13 or newer before re-enabling this config, search for 'Storage Schema' in the docs for the schema update procedure", c.SchemaConfig.Configs[p].Schema)) + errs = append(errs, fmt.Errorf("CONFIG ERROR: schema v13 is required to store Structured Metadata and use native OTLP ingestion, your schema version is %s. Set `allow_structured_metadata: false` in the `limits_config` section or set the command line argument `-validation.allow-structured-metadata=false` and restart Loki. Then proceed to update to schema v13 or newer before re-enabling this config, search for 'Storage Schema' in the docs for the schema update procedure", c.SchemaConfig.Configs[p].Schema)) } // TSDB index is required to use structured metadata if c.SchemaConfig.Configs[p].IndexType != config.TSDBType { - combinedErrors = stdlib_errors.Join(combinedErrors, fmt.Errorf("CONFIG ERROR: `tsdb` index type is required to store Structured Metadata and use native OTLP ingestion, your index type is `%s` (defined in the `store` parameter of the schema_config). Set `allow_structured_metadata: false` in the `limits_config` section or set the command line argument `-validation.allow-structured-metadata=false` and restart Loki. Then proceed to update the schema to use index type `tsdb` before re-enabling this config, search for 'Storage Schema' in the docs for the schema update procedure", c.SchemaConfig.Configs[p].IndexType)) + errs = append(errs, fmt.Errorf("CONFIG ERROR: `tsdb` index type is required to store Structured Metadata and use native OTLP ingestion, your index type is `%s` (defined in the `store` parameter of the schema_config). Set `allow_structured_metadata: false` in the `limits_config` section or set the command line argument `-validation.allow-structured-metadata=false` and restart Loki. Then proceed to update the schema to use index type `tsdb` before re-enabling this config, search for 'Storage Schema' in the docs for the schema update procedure", c.SchemaConfig.Configs[p].IndexType)) } - return combinedErrors + if len(errs) > 1 { + errs = append([]error{fmt.Errorf("MULTIPLE CONFIG ERRORS FOUND, PLEASE READ CAREFULLY")}, errs...) + return stdlib_errors.Join(errs...) + } else if len(errs) == 1 { + return errs[0] + } + + return nil } func (c *Config) isModuleEnabled(m string) bool {