-
Notifications
You must be signed in to change notification settings - Fork 950
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
bugfix: change the option to set volume size #1409
Conversation
Codecov Report
@@ 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
|
LGTM |
CI faild
|
apis/server/volume_bridge.go
Outdated
@@ -64,6 +64,7 @@ func (s *Server) createVolume(ctx context.Context, rw http.ResponseWriter, req * | |||
status[k] = v | |||
} | |||
} | |||
status["size"] = volume.Size() |
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.
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
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.
You are right.
apis/server/volume_bridge.go
Outdated
@@ -122,6 +124,7 @@ func (s *Server) listVolume(ctx context.Context, rw http.ResponseWriter, req *ht | |||
status[k] = v | |||
} | |||
} | |||
status["size"] = volume.Size() |
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 same as the above comment.
apis/server/volume_bridge.go
Outdated
@@ -92,6 +93,7 @@ func (s *Server) getVolume(ctx context.Context, rw http.ResponseWriter, req *htt | |||
status[k] = v | |||
} | |||
} | |||
status["size"] = volume.Size() |
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.
see the above comment
apis/server/volume_bridge.go
Outdated
@@ -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 |
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.
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?
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.
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() { |
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.
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.
LGTM |
Ⅰ. 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
Ⅴ. Special notes for reviews
Signed-off-by: Rudy Zhang rudyflyzhang@gmail.com