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

bugfix: fix meta store return all item when empty prefix #2104

Merged
merged 1 commit into from
Aug 17, 2018
Merged

Conversation

Ace-Tang
Copy link
Contributor

@Ace-Tang Ace-Tang commented Aug 16, 2018

meta store will return all items it keep if prefix is a empty
string.

Signed-off-by: Ace-Tang aceapril@126.com

Ⅰ. Describe what this PR did

 func (mgr *ContainerManager) Get(ctx context.Context, name string) (*Container, error) {
+       name = ""
        c, err := mgr.container(name)
        if err != nil {
                return nil, err

make name to empty, test

root@www:/var/lib/pouch# curl  -X GET --unix-socket /var/run/pouchd.sock "http:/containers/92b62b/json"
{"message":"container: : too many"}

it will return all container infos.

Ⅱ. Does this pull request fix one issue?

Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)

unit test add.

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

meta store will return all items it keep if prefix is a empty
string.

Signed-off-by: Ace-Tang <aceapril@126.com>
@pouchrobot pouchrobot added kind/bug This is bug report for project size/M labels Aug 16, 2018
@codecov-io
Copy link

Codecov Report

Merging #2104 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2104      +/-   ##
==========================================
+ Coverage   65.14%   65.15%   +0.01%     
==========================================
  Files         208      208              
  Lines       16407    16409       +2     
==========================================
+ Hits        10688    10691       +3     
  Misses       4388     4388              
+ Partials     1331     1330       -1
Flag Coverage Δ
#criv1alpha1test 33.01% <0%> (-0.19%) ⬇️
#criv1alpha2test 33.83% <0%> (-0.01%) ⬇️
#integrationtest 39.77% <0%> (-0.11%) ⬇️
#unittest 23.9% <100%> (+0.06%) ⬆️
Impacted Files Coverage Δ
pkg/meta/store.go 62.5% <100%> (+0.59%) ⬆️
apis/server/utils.go 61.9% <0%> (-4.77%) ⬇️
daemon/mgr/system.go 77.68% <0%> (-1.66%) ⬇️
cri/v1alpha1/cri.go 63.66% <0%> (-0.18%) ⬇️
daemon/logger/jsonfile/utils.go 73.17% <0%> (+1.62%) ⬆️
ctrd/image.go 78.94% <0%> (+1.75%) ⬆️

@@ -248,6 +248,10 @@ func (s *Store) GetWithPrefix(prefix string) ([]Object, error) {
func (s *Store) KeysWithPrefix(prefix string) ([]string, error) {
var keys []string

if len(prefix) == 0 {
return keys, nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest that here we return an error, like return nil, fmt.Errorf("input prefix cannot be empty when getting object in store")

@allencloud
Copy link
Collaborator

LGTM

@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Aug 17, 2018
@allencloud allencloud merged commit 94aae1f into AliyunContainerService:master Aug 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug This is bug report for project LGTM one maintainer or community participant agrees to merge the pull reuqest. size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants