-
Notifications
You must be signed in to change notification settings - Fork 123
[new-backend] spec hook #4495
[new-backend] spec hook #4495
Conversation
test_require_array (); | ||
test_array_member (); | ||
// test_remove_meta (); | ||
test_hook_copy_default (true); |
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 test all of them for both the get and set operations? Should there be differences between the operations?
For now, e.g. the set operation does not create default:/ 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.
The copy should behave the same in kdbGet
and kdbSet
that's why I used the same name.
That said, the current set from spec
is a bit broken.
To make validation for newly added keys during kdbSet
work properly, we need to copy meta:/
keys from spec:/
to other namespaces at the start of kdbSet
(before prestorage
). This should behave the same as in kdbGet
and the new meta:/
keys should be visible outside kdbSet
I think (see #4484 (comment)).
However, we don't want to store the copied meta:/
keys in the other namespace, so we need to remove them before the storage
phase. To do this we should simply check for every metakey of every key in a namespace other than spec:/
whether it (the metakey) is pointer-equal to the corresponding metakey on the equivalent spec:/
key. So something like:
KeySet * specMeta = keyMeta (specKey);
KeySet * meta = keyMeta (key);
for (elektraCursor it = 0; i < ksGetSize (specMeta); i++)
{
Key * m = ksAtCursor (specMeta, it);
if (ksLookup (meta, m, 0) == m)
{
keySetMeta (key, keyName (m), NULL);
}
}
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.
The differences between a set and get operation for the spec plugin were copied from the existing implementation:
- There can be different settings for the conflict handling
- This can probably be removed
- neither
assign/condition
nordefault
are processed in set- We can probably also execute this on set
- set operation sets
internal/spec/remove
onarray
- remove or also do it in get?
- set removes
internal/spec/array/validated
- remove or also do it in get?
- set does this thing here, I'm not sure what it is
- ??? If its not an array and it should not be removed it appends the specKey to the returned KeySet ???
if (!isKdbGet)
{
keySetMeta (specKey, "internal/spec/array/validated", NULL);
if (keyGetMeta (specKey, "internal/spec/array") == NULL && keyGetMeta (specKey, "internal/spec/remove") == NULL)
{
ksAppendKey (returned, specKey);
}
}
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.
There can be different settings for the conflict handling
- This can probably be removed
Yes, all the conflict handling settings should be removed entirely. During get
all conflicts should be warnings during set
they should be errors (unless @markus2330 thinks some conflicts should never be errors). That part could be handled from the libelektra-kdb
side with the "error blocking trick", so the spec
would be the same.
neither
assign/condition
nordefault
are processed in set
Not sure about assign/condition
and whether we actually want to keep that (@markus2330 ?), but default
should definitely be processed in set
. See also #4484 (comment)
- set operation sets
internal/spec/remove
onarray
- set removes
internal/spec/array/validated
- set does this thing here, I'm not sure what it is
All of the stuff related to array handling is very complicated and weird. Part of the weirdness comes from the fact that on master
the spec
plugin is only called once during kdbSet
and somehow there should still be validation during kdbSet
, but also spec
should cleanup the copied data (obviously not possible).
However, please don't waste time on this. Like I said already: Just try to imitate what spec
does on master
. The existing tests obviously also expect this behaviour. Once that is done and merged, you can create another PR with the actual updates for spec
(probably after new-backend
is merged in master
).
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.
Especially, the conflict handling should remain the same as on master
for now. Changing this will probably break some tests and take more time than might expect.
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.
However, please don't waste time on this. [...] Once that is done and merged, you can create another PR with the actual updates for spec.
I agree, this is probably the correct method, so I can continue with the other hooks. Created issue #4500 to track this.
Please take a look at my comment below with the test cases. I think those still need to be resolved before we can merge 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.
It looks like we got someone who will work on the spec plugin! 🚀
So we should soon have a coordination meeting about spec-related topics.
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 sure about assign/condition and whether we actually want to keep that (@markus2330 ?)
No, we can remove it. Defaults are a superior way. It should be possible via namespace
spec to give default
higher priority than others, giving something like an assignment via defaults.
Haven't had time to look at this properly yet. But there are something that need to be changed about the The things that need to be changed in
|
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.
Great work. Elegant tests. I did not check functionality, though.
New failing tests in this PR:
libelektra/doc/help/kdb-get.md Lines 80 to 89 in fac8496
The keys are:
@kodebach The only difference to previously is that the
There are 1 warnings for this plugin This seems about right, as spec does not have any placements anymore. Should we just ignore the spec plugin for this test? |
@@ -138,6 +168,13 @@ static bool isGoptsEnabledByContract (const KeySet * contract) | |||
return isEnabled; | |||
} | |||
|
|||
static bool isSpecEnabledByConfig (const KeySet * config) | |||
{ | |||
// TODO: check for system:/elektra/hook/spec/enabled or system:/elektra/hook/spec/disabled or something else ... TBD |
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 we need to solve this before merging this PR. Can be added later at any time.
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.
Agreed.
If the issue is just the
Just remove the test.
For now I think excluding |
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.
Great work, LGTM. If you take care of the 3 tests, we can merge this IMO.
@markus2330 the tests are fixed now, you can merge this PR. |
@atmaxinger please don't self-merge. Probably nobody looked at the test fixes now. In this case (for merges to new-backend) it is not a big deal, however, as it gets reviewed again. |
This is still a work in progress:
copy
should behave differently between get and set - will be discussed in [new-backend] spec: reimplement to completely comply with hooks #4500default:/
keys with regards to backend - see also [new-backend] spec hook - default:/ backend #4493Basics
(added as entry in
doc/news/_preparation_next_release.md
whichcontains
_(my name)_
)Please always add something to the release notes.
(first line should have
module: short statement
syntax)close #X
, are in the commit messages.doc/news/_preparation_next_release.md
scripts/dev/reformat-all
Checklist
(not in the PR description)
Review
Labels