-
Notifications
You must be signed in to change notification settings - Fork 294
Fixes #1222 and #1228 : Applies config defaults - Metric too ambiguous #1225
Fixes #1222 and #1228 : Applies config defaults - Metric too ambiguous #1225
Conversation
37d6f8e
to
ae07fbe
Compare
The second commit starts |
ae07fbe
to
04d873c
Compare
Updated commit message. |
b1934be
to
ef006fa
Compare
LGTM |
@@ -815,9 +815,6 @@ func TestMetricConfig(t *testing.T) { | |||
errs := c.subscriptionGroups.validateMetric(m1) | |||
So(errs, ShouldBeNil) | |||
}) | |||
Convey("So mock should have name: bob config from defaults", func() { | |||
So(c.Config.Plugins.pluginCache["0"+core.Separator+"mock"+core.Separator+"1"].Table()["name"], ShouldResemble, ctypes.ConfigValueStr{Value: "bob"}) | |||
}) |
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.
If this is still applying defaults, why was this test no longer valid?
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 wasn't valid here since the subscription group would need to be processed before the default would be applied to the plugin config cache. I added the test back as part of the convey that runs subscriptionGroups.ValidateMetric
.
if plugin.TypeName() != core.CollectorPluginType.String() { | ||
plugins = append(plugins, plugin) | ||
// add defaults to plugins (exposed in a plugins ConfigPolicy) | ||
if lp, err := s.pluginManager.get( |
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.
Would this be cleaner as:
key := fmt.Sprintf("%s:%s:%d",plugin.TypeName(), plugin.Name(), plugin.Version())
lp, err := s.pluginManager.get(key)
if err == nil && lp.ConfigPolicy != 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 don't think so however if you feel strongly I'll change it.
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 don't feel super strongly.
plugin.TypeName(), | ||
plugin.Name(), | ||
plugin.Version())); err == nil && lp.ConfigPolicy != nil { | ||
if policy := lp.ConfigPolicy.Get([]string{""}); policy != nil && len(policy.Defaults()) > 0 { |
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.
Similar comment on this line.
* Adds ApplyDefaults(map[string]ctypes.ConfigValue) to ConfigDataNode * Renames ReverseMerge to ReverseMergeInPlace on ConfigDataNode * Adds ReverseMerge to ConfigDataNode returning a copy of the merged node ReverseMerge, which now returns a copy, is called when validating deps (task creation) and when loading plugins.
2d560d0
to
ef91723
Compare
@@ -1391,7 +1394,7 @@ func TestCollectSpecifiedDynamicMetrics(t *testing.T) { | |||
So(err, ShouldBeNil) | |||
// metric catalog should contain the 3 following metrics: | |||
// /intel/mock/foo; /intel/mock/bar; /intel/mock/*/baz | |||
So(len(mts), ShouldEqual, 3) | |||
So(len(mts), ShouldEqual, 4) |
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 we add the /intel/mock/all/baz
to the comment so it's accurate?
if plugin.TypeName() != core.CollectorPluginType.String() { | ||
plugins = append(plugins, plugin) | ||
// add defaults to plugins (exposed in a plugins ConfigPolicy) | ||
if lp, err := s.pluginManager.get( |
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 don't feel super strongly.
* Updates validateMetric on subscriptionGroups to use GetMetrics instead of GetMetric since some namespace requests can expand to include multiple metrics.
ef91723
to
92e2486
Compare
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 #1222 and #1228
Summary of changes for #1222 (applies config defaults):
ReverseMerge
on ConfigDataNode toReverseMergeInPlace
ReverseMerge
on ConfigDataNode which returns a new ConfigDataNode without modifying the sourceApplyDefaults
on ConfigDataNodeTesting done:
Example: After a task is started the configuration for which file will be published to is updated through the API. The next time the task fires this configuration is applied.
Summary of changes for #1228
Testing done:
Below is a screen capture that successful runs the tasks described in #1228.
![after1228](https://camo.githubusercontent.com/e972e46590ac47bc8779167d5ef04d9337ccf839e2e841771e0cd46ebe95b259/68747470733a2f2f7777772e64726f70626f782e636f6d2f732f6e66717a68666b30663978376e62342f70737574696c2d6669786564332e6769663f7261773d31)
Note: These two issues were included in the same PR since #1228 depended on #1222. #1228 adds test coverage across
ValidateDeps
and as a result needed to apply defaults from the mocks config policy.@intelsdi-x/snap-maintainers