Skip to content
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

Make the List method homogeneous between all stores #32

Closed

Conversation

nmengin
Copy link

@nmengin nmengin commented Sep 19, 2017

When the List() method is called for the etcd provider, a Pair with the given key is returned in the result.

This behavior is different than the others stores which only return the children Pairs.

The PR allows filtering this root Pair from the result for ETCD V2 and V3.

@abronan
Copy link
Owner

abronan commented Sep 20, 2017

@nmengin Changes LGTM, although tests are failing because of boltdb and redis which have the same behavior of including the "directory" in the result. We may have to modify both backends to also exclude the "directory" on List().

@nmengin nmengin changed the title Delete the key Pair from result in etcd List Make the List method homogeneous between all stores Sep 20, 2017
@nmengin
Copy link
Author

nmengin commented Sep 20, 2017

@abronan BoltDB and Redis are now homogeneous too 😉 (and by commits need to be squashed 😜 )

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.009%) to 84.115% when pulling 59bdf9d on nmengin:feature/make-etcd-list-homogeneous into 0c1d214 on abronan:master.

.gitignore Outdated
@@ -1 +1,4 @@
dump.rdb
.idea/
Gopkg.*
vendor/
Copy link
Owner

Choose a reason for hiding this comment

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

Is it possible to remove these lines from the .gitignore? Because they are either IDE specific or depending on other PRs 😸

Repository owner deleted a comment from coveralls Sep 20, 2017
Repository owner deleted a comment from coveralls Sep 20, 2017
Repository owner deleted a comment from coveralls Sep 20, 2017
Repository owner deleted a comment from coveralls Sep 20, 2017
Repository owner deleted a comment from coveralls Sep 20, 2017
@abronan
Copy link
Owner

abronan commented Sep 21, 2017

@nmengin Is it possible to squash your commits? Also it would be perfect if you can write a full description for this change that impact all stores and what it fixes (not using the -m flag). Thanks!

…ing an empty list if the key given in entry has no child. The modifications are done on ETCD V2,V3, BoltDB and Redis stores.
@nmengin nmengin force-pushed the feature/make-etcd-list-homogeneous branch from b8a243e to b7ad9bc Compare September 22, 2017 07:25
@nmengin
Copy link
Author

nmengin commented Sep 22, 2017

@abronan squash done.

Let me know if the description is OK for you.

@@ -302,6 +301,8 @@ func (b *BoltDB) List(keyPrefix string) ([]*store.KVPair, error) {
})
if len(kv) == 0 {
return nil, store.ErrKeyNotFound
} else if len(kv) == 1 && kv[0].Key == keyPrefix {
return []*store.KVPair{}, err
Copy link
Owner

@abronan abronan Sep 22, 2017

Choose a reason for hiding this comment

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

Unfortunately this is not going to work here: if we have an array of > 1 element, we're still going return the directory key like before. I think we should do like other stores and filter in the loop above before appending to the array of pairs, when key == directory we skip that entry and continue looping over keys.

if assert.NotNil(t, pairs) {
assert.Equal(t, 0, len(pairs))
}
}
Copy link
Owner

@abronan abronan Sep 22, 2017

Choose a reason for hiding this comment

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

We should add a test case where the list is non-empty with a few elements and check we don't return the directory key on List. We should test for all cases (otherwise we would have missed the bad case for boltdb).

Copy link
Author

Choose a reason for hiding this comment

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

@abronan OK, I'll crate the parent key in the testList() function.
In this way, 3 keys will be inserted (1 parent and 2 children) but only 2 Pairs have to been returned.

@abronan
Copy link
Owner

abronan commented Oct 10, 2017

@nmengin I'm carrying this change in #35

Found out more cases of misalignment, thus I decided to complement your solution. Let me know what you think :)

@abronan
Copy link
Owner

abronan commented Oct 13, 2017

Closing now that #35 is merged.

Thanks @nmengin

@abronan abronan closed this Oct 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants