exit vmagent if there is config syntax error in scrape_config_files when -promscrape.config.strictParse=true (#5560)

This commit is contained in:
Hui Wang 2024-01-16 17:30:02 +08:00 committed by Aliaksandr Valialkin
parent 343176438e
commit 2f40ed3aac
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB
2 changed files with 16 additions and 6 deletions

View file

@ -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: [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: [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): 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: [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). * 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).

View file

@ -438,7 +438,7 @@ func loadConfig(path string) (*Config, error) {
return &c, nil return &c, nil
} }
func mustLoadScrapeConfigFiles(baseDir string, scrapeConfigFiles []string) []*ScrapeConfig { func mustLoadScrapeConfigFiles(baseDir string, scrapeConfigFiles []string, isStrict bool) ([]*ScrapeConfig, error) {
var scrapeConfigs []*ScrapeConfig var scrapeConfigs []*ScrapeConfig
for _, filePath := range scrapeConfigFiles { for _, filePath := range scrapeConfigFiles {
filePath := fs.GetFilepath(baseDir, filePath) filePath := fs.GetFilepath(baseDir, filePath)
@ -464,14 +464,20 @@ func mustLoadScrapeConfigFiles(baseDir string, scrapeConfigFiles []string) []*Sc
continue continue
} }
var scs []*ScrapeConfig var scs []*ScrapeConfig
if isStrict {
if err = yaml.UnmarshalStrict(data, &scs); err != nil { 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) logger.Errorf("skipping %q at `scrape_config_files` because of failure to parse it: %s", path, err)
continue continue
} }
}
scrapeConfigs = append(scrapeConfigs, scs...) scrapeConfigs = append(scrapeConfigs, scs...)
} }
} }
return scrapeConfigs return scrapeConfigs, nil
} }
// IsDryRun returns true if -promscrape.config.dryRun command-line flag is set // 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) cfg.baseDir = filepath.Dir(absPath)
// Load cfg.ScrapeConfigFiles into c.ScrapeConfigs // 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.ScrapeConfigFiles = nil
cfg.ScrapeConfigs = append(cfg.ScrapeConfigs, scs...) cfg.ScrapeConfigs = append(cfg.ScrapeConfigs, scs...)