-
Notifications
You must be signed in to change notification settings - Fork 123
spec: does not remove copied metadata before writing config #2700
Comments
This issue is not as easy as it seems at first. We could of course just store what metadata was added (e.g. in a What if we added e.g. IMO the best solution is to introduce a new bitfield (of type This bitfield may also be useful for diffs and merging, as well as some storage plugins, which are able to change only part of their backing storage (e.g. databases). |
I think this could also be wanted (to not intermix specifications from different sources: if some meta data is in spec, the same meta data should not be in any other namespaces). But even if we want this mixing (we would need to define the behavior for this, though) you can implement it with the features we already have:
|
EDIT: I just noticed with the current setup we cannot remove the metadata. |
Iirc the idea from @tom-wa was to add the metadata in the beginning of the set path, and remove it shortly before the end. |
Of course that is the only real solution. But that would require mounting the spec plugin twice on the set side. While that is possible, it is very awkward to do right now. At least we should provide a way for plugins to find out in which position they are currently being called first. |
The corresponding problem in An example: sudo kdb mount demo.ini user/tests/demo/abc ni type
sudo kdb setmeta spec/tests/demo/abc type boolean
# the following works as expected
kdb set -N user /tests/demo/abc true
kdb get user/tests/demo/abc
#> 1
# reset
kdb rm user/tests/demo/abc
# the spec plugin only runs with cascading parent keys
# so this demonstrate what would happen, if spec removed the metadata
kdb set user/tests/demo/abc true
kdb get user/tests/demo/abc
#> true
kdb lsmeta user/tests/demo/abc
#> Right now the best (maybe only) way to correctly set a key is this sequence: kdb set -N user /my/key value
kdb rmmeta user/my/key origvalue
kdb lsmeta "user/my/key" | grep '^internal/' | xargs -L1 kdb rmmeta "user/my/key" |
See implementation hint above, here it is only about removing meta-data before writing to the storage (as very last step). As |
I have no idea what you want to tell me here.... I explained, why removing metadata before calling the setstorage plugin DOES NOT WORK with the way |
From the example above:
I do not think this demonstrates anything as the workflow of multiple kdbGet and kdbSet within applications cannot be demonstrated with the But I think I understand what you mean.
The correct implementation will only remove metadata copied from spec to other keys within the The (hopefully) only difference will be that the meta-data does not end up in config files outside of spec.
The type checker already checks (and normalizes) before writing out, so it still has the metadata. The high-level API and the application's KeySet also has the meta-data as we will only remove the meta-data from a duplicated KeySet which is never passed to the high-level API. See source code: src/libs/elektra/split.c line 818. The correct implementation would only remove the meta-data from So as said above in implementation hint: |
Oh I see now... You misunderstood my example. Only the I didn't even consider calling
That was my original point. It should be like that, but removing metadata in
That is true. It is also true, that no correct position exists right now and that creating a correct position will be very involved. Simply calling global I don't have a good solution for this problem. All I can say is that the current plugin position system might not be good enough. A more granular (and much more complex) system for ordering plugins by their tasks (e.g. normalisation before validation, creating metadata before using metadata, etc) might be required. |
The split keysets need to be merged and split again or even better: we call the cleanup plugin on every split separately (what should be no problem for the cleanup. I updated the implementation hint above).
For 1.0 we will continue to merge the plugins. With less plugins there are less opportunities of unwanted feature interactions like #404. Please report all concrete feature interaction problems you know (with the concrete plugins).
Yes, this is unfortunately a completely open problem @Piankero did not work on. Does type, rgbcolor and unit now play together? Please report bugs if (and how) it does not. With merging all type and normalization features to "type" it should be much better now. Now we "only" need to fix the interaction of "type" and "spec". Concrete reproducible bugs would help here, too. Now with lcdproc is the first time that we can test with a real-world specification. So obviously we will find new problems.
This should be enforced by the spec plugin anyway. Other plugins should (for now) not create metadata that is for others. For now we need to simplify it to be able to release 1.0. Most likely we will need to remove further plugins that do not play well with the current architecture. |
Sidenote: I think certain metakeys (like |
@kodebach thanks for the info. The design doc afair states that the position should be given to the global plugin via parentKey, so the position should be easy to determine. I'll ping you if I get stuck with |
I mark this issue stale as it did not have any activity for one year. I'll close it in two weeks if no further activity occurs. If you want it to be alive again, ping the issue by writing a message here or create a new issue with the remainder of this issue. |
If we really need this is dependent on what we want to do with spec (see #3549) |
I mark this issue stale as it did not have any activity for one year. I'll close it in two weeks if no further activity occurs. If you want it to be alive again, ping the issue by writing a message here or create a new issue with the remainder of this issue. |
I closed this issue now because it has been inactive for more than one year. If I closed it by mistake, please do not hesitate to reopen it or create a new issue with the remainder of this issue. |
I think this is a show-stopper for using in LCDproc or machinekit (who want INI as first step for smooth migration)
Steps to Reproduce the Problem
kdb set
kdb mount wrong-copy.ini /tests ini kdb setmeta /tests/some-key some-meta some-value kdb set /tests/some-key x
Expected Result
To have a file
some-key = x
Actual Result
System Information
Implementation Hints
The spec plugin does not have the positioning to remove its meta-data before writing to the storage. See discussion below: the KeySet passed back from
kdbSet
must not be altered. Only the meta-data withinsplit
is allowed to be removed.So the easiest way is to call the spec plugin for every part in the split plugin separately. (As foreach plugin.)
The text was updated successfully, but these errors were encountered: