-
Notifications
You must be signed in to change notification settings - Fork 40
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
Add configuration change validations #1004
Conversation
lib/pharos/config.rb
Outdated
|
||
# @example deep get network provider | ||
# config.deep_get("network.provider") | ||
# @param key [String] a dot separated key, such as network.provider |
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.
@return
missing.
yield config_key, old_value, new_value | ||
end | ||
|
||
def previous_config |
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.
Should this be in Phase
?
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.
It's only used in addon_manager in addition to this phase.
lib/pharos/config.rb
Outdated
# config.deep_get("network.provider") | ||
# @param key [String] a dot separated key, such as network.provider | ||
# @return [Object,NilClass] nil when any part of the chain is unreachable | ||
def deep_get(key) |
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.
Probably should use Pharos::CoreExt::DeepKeys
?
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.
This one doesn't need to hashify in the middle. Interestingly, something like config.deep_get("hosts.first.address")
works with this.
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.
Is one .to_h
that bad? It would remove duplicate code.
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 threw away the DeepKeys refinement thing and replaced it with HashDiff and renamed config.deep_get
to config.dig
which acts like hash.dig
: config.dig(:network, :provider)
.
b860ce5
to
cf04d08
Compare
lib/pharos/autoload.rb
Outdated
@@ -47,6 +47,7 @@ module CommandOptions | |||
module CoreExt | |||
autoload :IPAddrLoopback, 'pharos/core-ext/ip_addr_loopback' | |||
autoload :DeepTransformKeys, 'pharos/core-ext/deep_transform_keys' | |||
autoload :DeepKeys, 'pharos/core-ext/deep_keys' |
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.
Not needed anymore?
lib/pharos/autoload.rb
Outdated
@@ -47,6 +47,7 @@ module CommandOptions | |||
module CoreExt | |||
autoload :IPAddrLoopback, 'pharos/core-ext/ip_addr_loopback' | |||
autoload :DeepTransformKeys, 'pharos/core-ext/deep_transform_keys' | |||
autoload :DeepKeys, 'pharos/core-ext/deep_keys' |
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.
autoload :DeepKeys, 'pharos/core-ext/deep_keys' |
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
Fixes #997
Here's the mechanism
For addons added a hook:
It can also be defined with only 1 param:
Or 3:
For phases / general config changes, made the cluster_manager load previous config earlier and run
ValidateConfigurationChanges
phase if a working master was found duringGatherFacts
.It appears to work: