Skip to content

Commit

Permalink
try to better clarify when there are multiple errors
Browse files Browse the repository at this point in the history
Signed-off-by: Edward Welch <[email protected]>
  • Loading branch information
slim-bean committed Apr 3, 2024
1 parent 53403c1 commit bf54bcc
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions pkg/loki/loki.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand Down

0 comments on commit bf54bcc

Please sign in to comment.