lib/envflag: do not allow unsupported form for boolean command-line flags in the form -boolFlag value

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4845
This commit is contained in:
Aliaksandr Valialkin 2023-08-17 13:26:10 +02:00
parent 27f790458b
commit a5df1e2525
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1
2 changed files with 6 additions and 0 deletions

View file

@ -15,6 +15,7 @@ The following tip changes can be tested by building VictoriaMetrics components f
## v1.87.x long-time support release (LTS)
* BUGFIX: do not allow starting VictoriaMetrics components with improperly set boolean command-line flags in the form `-boolFlagName value`, since this leads to silent incomplete flags' parsing. This form should be replaced with `-boolFlagName=value`. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4845).
* BUGFIX: properly replace `:` chars in label names with `_` when `-usePromCompatibleNaming` command-line flag is passed to `vmagent`, `vminsert` or single-node VictoriaMetrics. This addresses [this comment](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3113#issuecomment-1275077071).
* BUGFIX: [vmbackup](https://docs.victoriametrics.com/vmbackup.html): correctly check if specified `-dst` belongs to specified `-storageDataPath`. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4837).

View file

@ -32,6 +32,11 @@ func ParseFlagSet(fs *flag.FlagSet, args []string) {
// Do not use lib/logger here, since it is uninitialized yet.
log.Fatalf("cannot parse flags %q: %s", args, err)
}
if fs.NArg() > 0 {
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4845
log.Fatalf("unprocessed command-line args left: %s; the most likely reason is missing `=` between boolean flag name and value; "+
"see https://pkg.go.dev/flag#hdr-Command_line_flag_syntax", fs.Args())
}
if !*enable {
return
}