-
Notifications
You must be signed in to change notification settings - Fork 209
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
Fix configuration dynamic reload logic #1194
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright © 2022 Kaleido, Inc. | ||
// Copyright © 2023 Kaleido, Inc. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
@@ -49,8 +49,7 @@ func (nm *namespaceManager) configFileChanged() { | |
// the config when it changes and re-read it. | ||
// We are passed this by our parent, as the config initialization of defaults and sections | ||
// might include others than under the namespaces tree (API Server etc. etc.) | ||
nm.resetConfig() | ||
err := viper.ReadInConfig() | ||
err := nm.reloadConfig() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Spent a bunch of time thinking about the reason for this difference... If you look at https://github.com/spf13/viper/blob/c898f59d3345a8317651876020fe4eb7322a00aa/viper.go#L1543 it does not replace There was a time in the writing of this code where I established the safest thing to do was to leave That way if any code was accessing config live during operation, there would not be a time where that was invalid. However, this is something we try very hard to avoid in the FireFly core codebase, and copy the config only in constructors of long-lived manager. I can see from the comments here that eventually I must have had to abandon that and call Sorry for the long detail, but I agree the change now makes sense, and the thing I was worried about already had had to happen in the last rev of this code. |
||
if err != nil { | ||
log.L(nm.ctx).Errorf("Failed to re-read configuration after config reload notification: %s", err) | ||
nm.cancelCtx() // stop the world | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Looks like you're calling
resetConfig
twice in a row along this path.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.
......
Good catch there will submit a follow on PR to address this.