mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
exit vmagent if there is config syntax error in scrape_config_files
when -promscrape.config.strictParse=true
(#5560)
This commit is contained in:
parent
d0e4190969
commit
3ac44baebe
2 changed files with 16 additions and 6 deletions
|
@ -56,6 +56,7 @@ The sandbox cluster installation is running under the constant load generated by
|
|||
* BUGFIX: [MetricsQL](https://docs.victoriametrics.com/MetricsQL.html): properly handle queries, which wrap [rollup functions](https://docs.victoriametrics.com/MetricsQL.html#rollup-functions) with multiple arguments without explicitly specified lookbehind window in square brackets into [aggregate functions](https://docs.victoriametrics.com/MetricsQL.html#aggregate-functions). For example, `sum(quantile_over_time(0.5, process_resident_memory_bytes))` was resulting to `expecting at least 2 args to ...; got 1 args` error. Thanks to @atykhyy for [the pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/5414).
|
||||
* BUGFIX: [vmctl](https://docs.victoriametrics.com/vmctl.html): retry on import errors in `vm-native` mode. Before, retries happened only on writes into a network connection between source and destination. But errors returned by server after all the data was transmitted were logged, but not retried.
|
||||
* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): properly assume role with [AWS IRSA authorization](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html). Previously role chaining was not supported. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3822) for details.
|
||||
* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): exit if there is config syntax error in [`scrape_config_files`](https://docs.victoriametrics.com/vmagent.html#loading-scrape-configs-from-multiple-files) when `-promscrape.config.strictParse=true`. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5508).
|
||||
* BUGFIX: [vmui](https://docs.victoriametrics.com/#vmui): fix a link for the statistic inaccuracy explanation in the cardinality explorer tool. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5460).
|
||||
* BUGFIX: all: fix potential panic during components shutdown when [metrics push](https://docs.victoriametrics.com/#push-metrics) is configured. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5548). Thanks to @zhdd99 for the [pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/5549).
|
||||
|
||||
|
|
|
@ -438,7 +438,7 @@ func loadConfig(path string) (*Config, error) {
|
|||
return &c, nil
|
||||
}
|
||||
|
||||
func mustLoadScrapeConfigFiles(baseDir string, scrapeConfigFiles []string) []*ScrapeConfig {
|
||||
func mustLoadScrapeConfigFiles(baseDir string, scrapeConfigFiles []string, isStrict bool) ([]*ScrapeConfig, error) {
|
||||
var scrapeConfigs []*ScrapeConfig
|
||||
for _, filePath := range scrapeConfigFiles {
|
||||
filePath := fs.GetFilepath(baseDir, filePath)
|
||||
|
@ -464,14 +464,20 @@ func mustLoadScrapeConfigFiles(baseDir string, scrapeConfigFiles []string) []*Sc
|
|||
continue
|
||||
}
|
||||
var scs []*ScrapeConfig
|
||||
if err = yaml.UnmarshalStrict(data, &scs); err != nil {
|
||||
logger.Errorf("skipping %q at `scrape_config_files` because of failure to parse it: %s", path, err)
|
||||
continue
|
||||
if isStrict {
|
||||
if err = yaml.UnmarshalStrict(data, &scs); err != nil {
|
||||
return nil, fmt.Errorf("cannot unmarshal data from `scrape_config_files` %s: %w; pass -promscrape.config.strictParse=false command-line flag for ignoring unknown fields in yaml config", path, err)
|
||||
}
|
||||
} else {
|
||||
if err = yaml.Unmarshal(data, &scs); err != nil {
|
||||
logger.Errorf("skipping %q at `scrape_config_files` because of failure to parse it: %s", path, err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
scrapeConfigs = append(scrapeConfigs, scs...)
|
||||
}
|
||||
}
|
||||
return scrapeConfigs
|
||||
return scrapeConfigs, nil
|
||||
}
|
||||
|
||||
// IsDryRun returns true if -promscrape.config.dryRun command-line flag is set
|
||||
|
@ -492,7 +498,10 @@ func (cfg *Config) parseData(data []byte, path string) error {
|
|||
cfg.baseDir = filepath.Dir(absPath)
|
||||
|
||||
// Load cfg.ScrapeConfigFiles into c.ScrapeConfigs
|
||||
scs := mustLoadScrapeConfigFiles(cfg.baseDir, cfg.ScrapeConfigFiles)
|
||||
scs, err := mustLoadScrapeConfigFiles(cfg.baseDir, cfg.ScrapeConfigFiles, *strictParse)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cfg.ScrapeConfigFiles = nil
|
||||
cfg.ScrapeConfigs = append(cfg.ScrapeConfigs, scs...)
|
||||
|
||||
|
|
Loading…
Reference in a new issue