fscore: rollback trailing space trim (#7106)

Previous commit 201fd6de1e removed
trailing space trim from data read from file. But common practice is to
remove such trailing space. And it leaded to the authorization errors
for the major group of users.

In first place, this change must help to mitigate an issue with
kubernetes. When authorization information was read from Secret content.
Changes to the operator was made to mitigate such problem at commit
1cf64358c8

We could introduce later optional flag for VictoriaMetrics to disable
trim space behavior.

Related issues:
https://github.com/VictoriaMetrics/VictoriaMetrics/issues/6986
https://github.com/VictoriaMetrics/VictoriaMetrics/issues/7089 
https://github.com/VictoriaMetrics/VictoriaMetrics/issues/6947

---------

Signed-off-by: f41gh7 <nik@victoriametrics.com>
Co-authored-by: Zhu Jiekun <jiekun@victoriametrics.com>
This commit is contained in:
Nikolay 2024-09-29 10:59:25 +02:00 committed by GitHub
parent b52862badf
commit 3bbb2aed72
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 3 deletions

View file

@ -51,6 +51,7 @@ See also [LTS releases](https://docs.victoriametrics.com/lts-releases/).
* BUGFIX: [MetricsQL](https://docs.victoriametrics.com/metricsql/): consistently return the first non-`NaN` value from [`range_first`](https://docs.victoriametrics.com/metricsql/#range_first) function across all the returned data points. Previously `NaN` data points weren't replaced with the first non-`NaN` value.
* BUGFIX: [MetricsQL](https://docs.victoriametrics.com/metricsql/): consistently return the last non-`NaN` value from [`range_last`](https://docs.victoriametrics.com/metricsql/#range_last) function across all the returned data points. Previously `NaN` data points weren't replaced with the last non-`NaN` value.
* BUGFIX: all VictoriaMetrics components: increase default value of `-loggerMaxArgLen` cmd-line flag from 1000 to 5000. This should improve visibility on errors produced by very long queries.
* BUGFIX: all VictoriaMetrics components: trim trailing spaces when reading content from `*.passwordFile` and similar flags. It reverts changes introduced at [v1.102.0-rc2](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.102.0-rc2) release. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/6986) for details.
## [v1.103.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.103.0)

View file

@ -32,7 +32,7 @@ func TestPassword(t *testing.T) {
// read the password from file by relative path
localPassFile := "testdata/password.txt"
expectedPassword = "foo-bar-baz\n\n\n"
expectedPassword = "foo-bar-baz"
path := "file://" + localPassFile
if err := p.Set(path); err != nil {
t.Fatalf("cannot set password to file: %s", err)
@ -52,7 +52,7 @@ func TestPassword(t *testing.T) {
if err != nil {
t.Fatalf("unexpected error: %s", err)
}
expectedPassword = "foo-bar-baz\n\n\n"
expectedPassword = "foo-bar-baz"
path = "file://" + localPassFile
if err := p.Set(path); err != nil {
t.Fatalf("unexpected error: %s", err)

View file

@ -7,6 +7,8 @@ import (
"net/url"
"os"
"path/filepath"
"strings"
"unicode"
)
// ReadPasswordFromFileOrHTTP reads password for the give path.
@ -17,7 +19,8 @@ func ReadPasswordFromFileOrHTTP(path string) (string, error) {
if err != nil {
return "", err
}
return string(data), nil
pass := strings.TrimRightFunc(string(data), unicode.IsSpace)
return pass, nil
}
// ReadFileOrHTTP reads path either from local filesystem or from http if path starts with http or https.