From 879bba11ba496db2d6bc204c02989443faaac52b Mon Sep 17 00:00:00 2001 From: Nikolay Date: Wed, 27 Nov 2024 13:51:48 +0100 Subject: [PATCH] app/vmauth: adds dryRun flag for config validation This flag only validates configuration file pointed by `auth.config` flag. Related issue: https://github.com/VictoriaMetrics/VictoriaMetrics/issues/7505 Signed-off-by: f41gh7 --- app/vmauth/main.go | 11 +++++++++++ docs/changelog/CHANGELOG.md | 2 ++ docs/vmauth.md | 2 ++ 3 files changed, 15 insertions(+) diff --git a/app/vmauth/main.go b/app/vmauth/main.go index 7f18d7798..16ea0db1e 100644 --- a/app/vmauth/main.go +++ b/app/vmauth/main.go @@ -61,6 +61,7 @@ var ( "See https://docs.victoriametrics.com/vmauth/#backend-tls-setup") backendTLSServerName = flag.String("backend.TLSServerName", "", "Optional TLS ServerName, which must be sent to HTTPS backend. "+ "See https://docs.victoriametrics.com/vmauth/#backend-tls-setup") + dryRun = flag.Bool("dryRun", false, "Whether to check only config files without running vmauth. The auth configuration file is validated. The -auth.config flag must be specified.") ) func main() { @@ -71,6 +72,16 @@ func main() { buildinfo.Init() logger.Init() + if *dryRun { + if len(*authConfigPath) == 0 { + logger.Fatalf("missing required `-auth.config` command-line flag") + } + if _, err := reloadAuthConfig(); err != nil { + logger.Fatalf("failed to parse %q: %s", *authConfigPath, err) + } + return + } + listenAddrs := *httpListenAddrs if len(listenAddrs) == 0 { listenAddrs = []string{":8427"} diff --git a/docs/changelog/CHANGELOG.md b/docs/changelog/CHANGELOG.md index 5e824cfc6..a57bbe268 100644 --- a/docs/changelog/CHANGELOG.md +++ b/docs/changelog/CHANGELOG.md @@ -24,6 +24,8 @@ See also [LTS releases](https://docs.victoriametrics.com/lts-releases/). * FEATURE: [vmui](https://docs.victoriametrics.com/#vmui): add `Raw Query` tab for displaying raw data. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/7024). * FEATURE: [stream aggregation](https://docs.victoriametrics.com/stream-aggregation/): add `ignore_first_sample_interval` param to [aggregation config](https://docs.victoriametrics.com/stream-aggregation/#stream-aggregation-config). It allows users to control the time interval when aggregation skips sending aggregated samples to avoid unexpected spikes in values. By default, this interval is set to x2 of `staleness_interval`. The new setting is applicable only to `total`, `total_prometheus`, `increase`, `increase_prometheus` and `histogram_bucket` outputs. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/7116) for details. Thanks to @iyuroch for the [pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/7313). * FEATURE: [vmauth](https://docs.victoriametrics.com/vmauth/): add `dump_request_on_errors` bool setting to [auth config](https://docs.victoriametrics.com/vmauth/#auth-config) for debugging HTTP requests that missed routing rules. This should improve debugability of vmauth settings. +* FEATURE: [vmauth](https://docs.victoriametrics.com/vmauth/): add `dryRun` flag to validate configuration. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/7505) for details. + * BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent): Properly return `200 OK` HTTP status code when importing data via [Pushgateway protocol](https://docs.victoriametrics.com/#how-to-import-data-in-prometheus-exposition-format) using [multitenant URL format](https://docs.victoriametrics.com/cluster-victoriametrics/#url-format). See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3636) and [this pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/7571). * BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent): Properly set `TCP` connection timeout for `Kubernetes API server` connection for metric scrapping with `kubernetes_sd_configs`. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/7127). diff --git a/docs/vmauth.md b/docs/vmauth.md index 33680c266..1ca4ebc79 100644 --- a/docs/vmauth.md +++ b/docs/vmauth.md @@ -1199,6 +1199,8 @@ See the docs at https://docs.victoriametrics.com/vmauth/ . Whether to discover backend IPs via periodic DNS queries to hostnames specified in url_prefix. This may be useful when url_prefix points to a hostname with dynamically scaled instances behind it. See https://docs.victoriametrics.com/vmauth/#discovering-backend-ips -discoverBackendIPsInterval duration The interval for re-discovering backend IPs if -discoverBackendIPs command-line flag is set. Too low value may lead to DNS errors (default 10s) + -dryRun + Whether to check only config files without running vmauth. The auth configuration file is validated. The -auth.config flag must be specified. -enableTCP6 Whether to enable IPv6 for listening and dialing. By default, only IPv4 TCP and UDP are used -envflag.enable