Skip to content

Commit

Permalink
Logcli: load remote schema before validation (grafana#7258)
Browse files Browse the repository at this point in the history
The --remote-schema option didn't work as validation would be called
before the remote schema was loaded. An error about a missing schema
section is the result. This was tested by running against a remote
bucket containing a schemaconfig.yaml file with a local config file that
does not contain a schema config section.

Signed-off-by: Michel Hollands <michel.hollands@grafana.com>
  • Loading branch information
MichelHollands authored and changhyuni committed Nov 8, 2022
1 parent ae18e44 commit ebea090
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions pkg/logcli/query/query.go
Expand Up @@ -190,21 +190,8 @@ func (q *Query) DoLocalQuery(out output.LogOutput, statistics bool, orgID string
return err
}

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

limits, err := validation.NewOverrides(conf.LimitsConfig, nil)
if err != nil {
return err
}
cm := storage.NewClientMetrics()
conf.StorageConfig.BoltDBShipperConfig.Mode = indexshipper.ModeReadOnly
conf.StorageConfig.BoltDBShipperConfig.IndexGatewayClientConfig.Disabled = true

schema := conf.SchemaConfig
if useRemoteSchema {
cm := storage.NewClientMetrics()
client, err := GetObjectClient(conf, cm)
if err != nil {
return err
Expand All @@ -215,10 +202,21 @@ func (q *Query) DoLocalQuery(out output.LogOutput, statistics bool, orgID string
return err
}

schema = *loadedSchema
conf.SchemaConfig = *loadedSchema
}

querier, err := storage.NewStore(conf.StorageConfig, conf.ChunkStoreConfig, schema, limits, cm, prometheus.DefaultRegisterer, util_log.Logger)
if err := conf.Validate(); err != nil {
return err
}

limits, err := validation.NewOverrides(conf.LimitsConfig, nil)
if err != nil {
return err
}
conf.StorageConfig.BoltDBShipperConfig.Mode = indexshipper.ModeReadOnly
conf.StorageConfig.BoltDBShipperConfig.IndexGatewayClientConfig.Disabled = true

querier, err := storage.NewStore(conf.StorageConfig, conf.ChunkStoreConfig, conf.SchemaConfig, limits, cm, prometheus.DefaultRegisterer, util_log.Logger)
if err != nil {
return err
}
Expand Down

0 comments on commit ebea090

Please sign in to comment.