-
Notifications
You must be signed in to change notification settings - Fork 122
Disable cascading writes in ambiguous cases #3794
Disable cascading writes in ambiguous cases #3794
Conversation
Thank you so much for working on this! Is the plan here to fully implement the proposal from #3742? |
Thank you for creating the PR! Did you already consider that cascading writes are okay if |
As of ff85a90
All code segments in kdb using the flag have been updated:
I plan to update documentation and testing once we have settled on the new behaviour. |
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.
Thank you for the improvements! Docu&test cases are still missing which makes it hard to know what the intended behavior is.
I am afraid something went wrong in the rebase. One way to resolve it is to create a new branch, cherry-pick the commits and create a new PR. |
39a0f05
to
629bf43
Compare
The rebase is fixed now. |
5ac510e
to
8187098
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.
This PR is starting to look great! 🚀
doc/help/kdb-rm.md
Outdated
@@ -11,6 +11,10 @@ Note that when using the `-r` flag, not only the key directly at `path` will be | |||
|
|||
This command removes key(s) from the Key database. | |||
|
|||
## LIMITATIONS | |||
|
|||
Cascading keys (i.e. keys that start with `/`) are only allowed using the `-f` flag. |
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.
Why? And what is the behavior? I would expect it removes any key in any namespace. What is ambiguous here?
I would also avoid giving -f so different meanings: bypassing spec: validation (which also makes sense for kdb-rm) and allowing cascading writes. What if someone does not want to bypass validation but would like to use cascading?
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.
My rationale was to implement #3742 (I interpreted this to mean that all cascading operations on kdb rm
were meant to be disabled, as not otherwise specified).
The -f option was intended to keep the old behavior available, but of course this is not an optimal solution.
I will revert it back.
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.
Yes, I think in non-ambiguous cases we can simply remove the key(s). -f
should be only for disabling the spec validation.
The remaining problem is that repeated executions of kdb rm -r /something
might remove several keys. Please think about it if we really want the same semantics as used in kdb set
. How is the behavior in FUSE when you remove a file that is "backed up" by several keys (in several namespaces)?
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 old behavior is back.
Although it is not an advisable strategy to do that, I think it is better to not introduce a new special case here. and keep things consistent with the other commands.
In the FUSE tool this case does not occur, since the cascading namespace is mounted read-only (This was decided because a file system that only supports writing partially (due to the ambiguity of creating keys in the cascading namespace) is a mess regarding compatibility with tools and usability for users).
doc/help/kdb-meta-get.md
Outdated
@@ -42,6 +42,8 @@ This command will return the following values as an exit status:<br> | |||
Explain what is happening. Prints additional information in case of errors/warnings. | |||
- `-d`, `--debug`: | |||
Give debug information. Prints additional debug information in case of errors/warnings. | |||
- `-N`, `--namespace=NS`: | |||
Use the specified namespace in case the provided key does not already have a namespace. |
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.
What if the namespace is provided twice? (I would expect an error from this docu.)
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.
For a case like kdb meta-get -N system user:/key metakey
I opted to use the namespace of the key, since this is how kdb set
worked in the past, and throwing an error (while still being consistent with kdb set
) leads to e.g. testcase check_distribution.sh breaking.
What do you think is the solution?
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 proper solution probably is to completely get rid of -N
as we actually want it to be synonymous to add the namespace to the key. I proposed this in #4012
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 proposal is now fully implemented.
567461c
to
e122940
Compare
…behaviour with new shell function prepend_namespace_if_not_present
… namespace" This reverts commit 5ac97e1.
Co-authored-by: Markus Raab <markus2330@users.noreply.github.com>
2b68dbb
to
36901a7
Compare
The manpages are not fully re-generated. The simplest is to apply the patch from the failed CI check: https://cirrus-ci.com/task/5640107244912640 |
Thank you for the hint; Done. |
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.
Awesome work! 🚀
Thank you! |
Proposed Changes
This PR serves, among others, to implement #3742 and #4012.
List of proposed changes:
kdb set
,kdb meta-set
: (Resolve Inconsistent set/get for cascading keys #401) Only allow writes to the cascading namespace if the lookup succeeds (Otherwise, the operation is ambiguous and therefore aborted).No more guessing of namespaces in case a cascading key is given (
user:, system
: forkdb set
,spec:
forkdb meta-set
),kdb file
: Remove namespace guessingkdb editor/import
: Disable the use of cascading names (and the 'validate' strategy operating on cascading keys) entirely to resolve cascading import/export/editor dangerous #2762kdb export
keep behaviour to not breaktests/shell/shell_recorder/shell_recorder.sh
kdb get
,kdb sget
,kdb meta-get
,kdb set
,kdb meta-set
: Use a cascading key forparentKey
to solve kdb set user/ and -N user should behave the same, -f for old behavior #2561.Introduce
-f
flag tokdb set
,kdb meta-set
to use old behaviour (bypass validation)kdb
manpages.elektra-cascading.md
.Basics
These points need to be fulfilled for every PR:
(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
If you have any troubles fulfilling these criteria, please write
about the trouble as comment in the PR. We will help you.
But we cannot accept PRs that do not fulfill the basics.
Checklist
Check relevant points but please do not remove entries.
For docu fixes, spell checking, and similar none of these points below
need to be checked.
(not in the PR description)
Review
Reviewers will usually check the following:
Labels
If you are already Elektra developer:
say that everything is ready to be merged.