Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Fixes #1222 and #1228 : Applies config defaults - Metric too ambiguous #1225

Merged
merged 2 commits into from
Oct 7, 2016

Conversation

jcooklin
Copy link
Collaborator

@jcooklin jcooklin commented Sep 21, 2016

Fixes #1222 and #1228

Summary of changes for #1222 (applies config defaults):

  • Renames ReverseMerge on ConfigDataNode to ReverseMergeInPlace
  • Adds ReverseMerge on ConfigDataNode which returns a new ConfigDataNode without modifying the source
  • Adds ApplyDefaults on ConfigDataNode

Testing done:

  • unit
  • manual

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.

after1222


Summary of changes for #1228

  • Updates validateMetric on subscriptionGroups to use GetMetrics instead of GetMetric since some namespace requests can expand to include multiple metrics.

Testing done:

  • unit
  • manual

Below is a screen capture that successful runs the tasks described in #1228.
after1228

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

@jcooklin jcooklin force-pushed the ib/1222-default-config-values branch 3 times, most recently from 37d6f8e to ae07fbe Compare September 23, 2016 06:54
@jcooklin jcooklin changed the title Fixes #1222 Applies config defaults Fixes #1222 and #1228 : Applies config defaults - Metric too ambiguous Sep 23, 2016
@marcin-krolik
Copy link
Collaborator

@jcooklin Retested this PR with #1228. Confirmed it fixes reported issue. 👍

@IRCody
Copy link
Contributor

IRCody commented Sep 23, 2016

The second commit starts Fixes #12228: instead of #1228.

@jcooklin jcooklin force-pushed the ib/1222-default-config-values branch from ae07fbe to 04d873c Compare September 23, 2016 17:01
@jcooklin
Copy link
Collaborator Author

Updated commit message.

@jcooklin jcooklin force-pushed the ib/1222-default-config-values branch 2 times, most recently from b1934be to ef006fa Compare September 23, 2016 19:08
@marcin-krolik
Copy link
Collaborator

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"})
})
Copy link
Contributor

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?

Copy link
Collaborator Author

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(
Copy link
Contributor

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 {
...

Copy link
Collaborator Author

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.

Copy link
Contributor

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 {
Copy link
Contributor

@IRCody IRCody Sep 23, 2016

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.
@jcooklin jcooklin force-pushed the ib/1222-default-config-values branch from 2d560d0 to ef91723 Compare October 5, 2016 20:15
@@ -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)
Copy link
Contributor

@IRCody IRCody Oct 7, 2016

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(
Copy link
Contributor

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.
@jcooklin jcooklin force-pushed the ib/1222-default-config-values branch from ef91723 to 92e2486 Compare October 7, 2016 18:15
Copy link
Contributor

@IRCody IRCody left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jcooklin jcooklin merged commit 57e774d into intelsdi-x:master Oct 7, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tasks don't reflect changes to plugin config
3 participants