-
Notifications
You must be signed in to change notification settings - Fork 52
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
[WIP] Subtype setting config val: use as key’s default val #1014
base: master
Are you sure you want to change the base?
[WIP] Subtype setting config val: use as key’s default val #1014
Conversation
Otherwise if another blueprint uses this subtype, it does not see the config val for that key. Worst case, it says the blueprint is invalid because the config key has no value.
I like this idea but the test failures highlight an edge cases that need some thinking.
This can possibly be resolved by making the key-overwrite method aware of the different ConfigKey subtypes. Will be interesting to see whether that improves the test failure situation. Re the problem you mention, default values being different now for keys that have a value set in YAML, I don't think that's a problem. It has some notable implications, e.g. if a config value is subsequently cleared the initial YAML-set value will be returned on read, rather than the original key definition default -- but I think this is okay. |
I've opened aledsage#4 against this PR to address many of the failing tests and improve logic as noted in previous comment ("making the key-overwrite method aware of the different ConfigKey subtypes"). It also adds a test for a corner case that was previously overlooked that was exposed by this, and changes serialization slightly (you can revert that commit if you don't like it). With these changes, it is now failing in the [IGNORE BELOW THIS] Previously I thought one of the failures was down to how uninherited keys are visible, as follows:
The code (A) looks in the parent to find the key, (B) finds it, then (C) resolves it, correctly detecting that it is "never reinherited" but with these changes (D) it now sees To preserve original semantics here we need to stop (D), i.e. the default values at runtime shouldl not be changed, which is one option, ie only change the default value on catalog reads (which will invalidate a few of the previous test changes but that's okay and minor). Alternatively, and better in my view, would be to change semantics so that if a key is never inherited or not reinherited, the attempt to find it (B) is unable to do so. This feels better because the key should not even be visible to the child entity. Thus it will not return either the original default value or the set value; it won't even know the type; and (C) will return [END OF OLD THOUGHTS - CONFIRMED THAT (D) DOES NOT HAPPEN UNLESS TEST DOES SOMETHING WEIRD WHICH IT WAS DOING] (In addition to the failures in |
The test failures highlight one other problem: if the immediate type and parent type both declare values for a key type which should be merged, in some cases I think where a short v long name is used, it is not correctly merging. [edited, removed a few things that seemed to be a more general problem but I was mislead] |
Fixed that last problem in my PR, a few So I think the only outstanding thing is ensuring non-visible ancestor config keys are not even seen as keys when resolving. |
I've updated the long note above. The failure I thought was due to non-reinherited keys was actually due to something odd the test was doing. It was purely a case of default-changed-as-expected. However I've expanded that test in my PR to test more things, and everything is acting as it should be, with the exception of set-from-flag values are not taken as default values. In my view, this is good to merge once my PR is merged -- if tests pass! |
@aledsage Can you take a look at this please to see if it is still relevant, and address the comments above, and also the failing tests if appropriate Thanks |
retest this please |
For review/feedback only - failing unit tests.
Otherwise if another blueprint uses this subtype, it does not see the
config val for that key. Worst case, it says the blueprint is invalid
because the config key has no value.
My new unit tests pass, but it breaks existing unit tests (e.g. in
ConfigParametersYamlTest.java
). The logic is applied to a catalog item and also to a blueprint being deployed. Our assertions in existing tests check that the config keys of the app being deployed have particular default vals, but these are now being overridden by the blueprint.What do folk think (cc @ahgittin) - should we use this approach, and fix the tests, or do something else?