Skip to content

Commit

Permalink
Fix: Actually validate config struct (#3837)
Browse files Browse the repository at this point in the history
We seem to have not linked up the validation for a few components.
  • Loading branch information
simonswine authored Jan 14, 2025
1 parent 0584b60 commit 68c28f5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pkg/objstore/client/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ func (cfg *StorageBackendConfig) RegisterFlagsWithPrefix(prefix string, f *flag.
}

func (cfg *StorageBackendConfig) Validate() error {
if cfg.Backend == None {
return nil
}

if !lo.Contains(cfg.supportedBackends(), cfg.Backend) {
return ErrUnsupportedStorageBackend
}
Expand Down
36 changes: 35 additions & 1 deletion pkg/phlare/phlare.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,44 @@ func (c *Config) Validate() error {
if len(c.Target) == 0 {
return errors.New("no modules specified")
}

if err := c.Frontend.Validate(); err != nil {
return err
}

if err := c.Worker.Validate(util.Logger); err != nil {
return err
}

if err := c.LimitsConfig.Validate(); err != nil {
return err
}

if err := c.QueryScheduler.Validate(); err != nil {
return err
}

if err := c.Ingester.Validate(); err != nil {
return err
}

if err := c.StoreGateway.Validate(c.LimitsConfig); err != nil {
return err
}

if err := c.OverridesExporter.Validate(); err != nil {
return err
}

if err := c.Compactor.Validate(c.PhlareDB.MaxBlockDuration); err != nil {
return err
}
return c.Ingester.Validate()

if err := c.Storage.Bucket.Validate(); err != nil {
return err
}

return nil
}

func (c *Config) ApplyDynamicConfig() cfg.Source {
Expand Down

0 comments on commit 68c28f5

Please sign in to comment.