-
Notifications
You must be signed in to change notification settings - Fork 829
Do not log "failed to load config" if runtime config file is empty #3706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not log "failed to load config" if runtime config file is empty #3706
Conversation
Signed-off-by: Marco Pracucci <marco@pracucci.com>
pkg/cortex/runtime_config.go
Outdated
content, err := ioutil.ReadAll(r) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
decoder := yaml.NewDecoder(r) | ||
decoder.SetStrict(true) | ||
if err := decoder.Decode(&overrides); err != nil { | ||
var overrides = &runtimeConfigValues{} | ||
if err := yaml.UnmarshalStrict(content, overrides); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should revert back to original code, and extend the checks as follows:
- If first returned error is EOF, we return
nil
. This covers empty document case. - We call
decoder.Decode
second time, and if it doesn't return EOF, thenloadRuntimeConfig
will return error.
Second check covers the case when there are multiple YAML documents on the input, eg.
---
# This is an empty YAML.
---
multi_kv_config:
mirror_enabled: true
In this case, first two calls to Decode
return nil
(no error), so our current version of loadRuntimeConfig
(or version suggested in this PR, which only decodes first document) would return no error, which is confusing.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good point about multiple documents (that should be forbidden). I've changed it. What do you think?
…cuments Signed-off-by: Marco Pracucci <marco@pracucci.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, nice. Remaining comments are just non-blocking nits.
Signed-off-by: Marco Pracucci <marco@pracucci.com> Co-authored-by: Peter Štibraný <pstibrany@gmail.com>
Signed-off-by: Marco Pracucci <marco@pracucci.com> Co-authored-by: Peter Štibraný <pstibrany@gmail.com>
What this PR does:
We recently introduced an empty
runtime.yaml
in the local dev env setupdevelopment/tsdb-blocks-storage-s3/config/
, but I've just realised the config fails to load because empty (no YAML node). Should an empty config be legit? If so, then this PR fixes it.Which issue(s) this PR fixes:
N/A
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]