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: change the option to set volume size #1409

Merged
merged 1 commit into from
May 27, 2018

Conversation

rudyfly
Copy link
Collaborator

@rudyfly rudyfly commented May 24, 2018

Ⅰ. Describe what this PR did

Before use 'size' or 'opt.size' to set volume size, now change it to
'opt.size', 'size' will not effective.

Ⅱ. Does this pull request fix one issue?

fixes #1399

Ⅲ. Describe how you did it

Ⅳ. Describe how to verify it

use this way to create volume

# pouch volume create -n diskquota -o opt.size=256m -o mount=/data/volume

Ⅴ. Special notes for reviews

Signed-off-by: Rudy Zhang rudyflyzhang@gmail.com

@pouchrobot pouchrobot added areas/storage kind/bug This is bug report for project size/XS labels May 24, 2018
@rudyfly rudyfly requested review from Letty5411 and shaloulcy May 24, 2018 08:59
@codecov-io
Copy link

codecov-io commented May 24, 2018

Codecov Report

Merging #1409 into master will increase coverage by 22.54%.
The diff coverage is 95%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #1409       +/-   ##
===========================================
+ Coverage   16.23%   38.78%   +22.54%     
===========================================
  Files         200      250       +50     
  Lines       13583    16627     +3044     
===========================================
+ Hits         2205     6448     +4243     
+ Misses      11224     9353     -1871     
- Partials      154      826      +672
Impacted Files Coverage Δ
cli/volume.go 8.19% <0%> (ø) ⬆️
apis/server/volume_bridge.go 84.21% <100%> (+84.21%) ⬆️
storage/volume/modules/local/local.go 68.57% <100%> (ø)
daemon/logger/jsonfile/utils.go 70% <0%> (ø) ⬆️
storage/volume/error/errors.go 28.57% <0%> (ø)
storage/volume/modules/ceph/types.go 0% <0%> (ø)
pkg/system/network.go 70% <0%> (ø)
storage/quota/set_diskquota.go 9.09% <0%> (ø)
registry/auth.go 54.12% <0%> (ø)
cri/v1alpha2/service/cri.go 0% <0%> (ø)
... and 116 more

@shaloulcy
Copy link
Contributor

LGTM

@Letty5411
Copy link
Contributor

CI faild

----------------------------------------------------------------------
FAIL: /go/src/github.com/alibaba/pouch/test/cli_volume_test.go:295: PouchVolumeSuite.TestVolumeListOptions
/go/src/github.com/alibaba/pouch/test/cli_volume_test.go:324:
    c.Errorf("list result have no driver or name or size or mountpoint, line: %s", line)
... Error: list result have no driver or name or size or mountpoint, line: local    volume_TestVolumeListOptions_3     ulimit   /var/lib/pouch/volume/volume_TestVolumeListOptions_3

@@ -64,6 +64,7 @@ func (s *Server) createVolume(ctx context.Context, rw http.ResponseWriter, req *
status[k] = v
}
}
status["size"] = volume.Size()
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you add this line code, then I suggest that use status := map[string]interface{}{} instead in Line 58.
If you do it like this, you can eliminate code

if status == nil {
    status = make(map[string]interface{})
}

WDYT? @rudyfly

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are right.

@@ -122,6 +124,7 @@ func (s *Server) listVolume(ctx context.Context, rw http.ResponseWriter, req *ht
status[k] = v
}
}
status["size"] = volume.Size()
Copy link
Collaborator

Choose a reason for hiding this comment

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

The same as the above comment.

@@ -92,6 +93,7 @@ func (s *Server) getVolume(ctx context.Context, rw http.ResponseWriter, req *htt
status[k] = v
}
}
status["size"] = volume.Size()
Copy link
Collaborator

Choose a reason for hiding this comment

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

see the above comment

@@ -64,6 +64,7 @@ func (s *Server) createVolume(ctx context.Context, rw http.ResponseWriter, req *
status[k] = v
}
}
status["size"] = volume.Size()
respVolume.Status = status
Copy link
Collaborator

@allencloud allencloud May 25, 2018

Choose a reason for hiding this comment

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

I think we have discussed before. When constructing a returned instance like respVolume, try to use prepared everything and then initialize one, rather than initialize one instance and then set values for it.
Could you also change this part as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Modified

Before use 'size' or 'opt.size' to set volume size, now change it to
'opt.size', 'size' will not effective.

Signed-off-by: Rudy Zhang <rudyflyzhang@gmail.com>
@@ -47,25 +47,23 @@ func (s *Server) createVolume(ctx context.Context, rw http.ResponseWriter, req *
return err
}

status := map[string]interface{}{}
for k, v := range volume.Options() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually there is another corner case that size exists in both volume.Options() and volume.Size().
Then what is rule to deal with this case?
Just curious, I will merge this first.

@allencloud
Copy link
Collaborator

LGTM

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

Successfully merging this pull request may close these issues.

[bug] volume size doesn't work in diskquota test
6 participants