-
Notifications
You must be signed in to change notification settings - Fork 947
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
feature: add container's volume manager #15
Conversation
cli/http_request.go
Outdated
@@ -36,7 +36,7 @@ func (r *Request) Send() *Response { | |||
response.Err = ErrHTTP5xx | |||
return response | |||
} | |||
if resp.StatusCode != http.StatusOK { | |||
if resp.StatusCode < 200 || resp.StatusCode > 300 { |
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 had better compare with 400 instead of 300. Since 3xx is also reasonable for a request. WDYT? @rudyfly @skoo87
cli/volume.go
Outdated
"github.com/spf13/cobra" | ||
) | ||
|
||
// VolumeCommand use to implement 'volume' command. |
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 strongly suggest that the comment of a func should use "第三人称单数". for example, VolumeCommand uses
, Init initializes
...
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.
yeah, I always use this format "xxx is used to do something", is it ok?
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.
Yeah, that is much better. 👍
cli/volume.go
Outdated
|
||
// Run is the entry of VolumeCreateCommand command. | ||
func (v *VolumeCreateCommand) Run(args []string) { | ||
logrus.Infof("create a volume: %s, options: %v, labels: %v, selectors: %v", |
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 do not think that write an info log in command line is reasonable.
Always, we get the correct result returned or some error message.
How about that?
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.
ok, just for debug, forgot to change log level :)
cli/volume.go
Outdated
for _, l := range v.labels { | ||
label := strings.Split(l, "=") | ||
if len(label) != 2 { | ||
logrus.Warnf("unknown label: %s", l) |
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.
Yeah, I totally agree with that we should tell user the error message.
But to be honest, I think maybe there are some other ways to meet user's demand. Maybe it is worth considering.
For user, if he inputs an incorrect label like "asdfgh" by mistake, not the format of "a=b", of course throwing a warn log is also telling him. Meanwhile. the pouchd is also creating a mistaken volume which does not meet the demand. So, if there any possibility to return error directly to user and stop processing it with remote pouchd?
cli/volume.go
Outdated
for _, o := range v.options { | ||
option := strings.Split(o, "=") | ||
if len(option) != 2 { | ||
logrus.Warnf("unknown option: %s", o) |
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 comments above 🍺
cli/volume.go
Outdated
for _, s := range v.selectors { | ||
selector := strings.Split(s, "=") | ||
if len(selector) != 2 { | ||
logrus.Warnf("unknown selector: %s", s) |
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.
same comments above 🍺
daemon/mgr/volume.go
Outdated
// Create is used to create volume. | ||
Create(ctx context.Context, name, driver string, options, labels map[string]string) error | ||
|
||
// Remove is used delete an exist volume. |
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.
s/delete/to delete/
s/exist/existing/
daemon/mgr/volume.go
Outdated
return vm.Core.CreateVolume(id) | ||
} | ||
|
||
// Remove is used delete an exist volume. |
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.
s/delete/to delete/
s/exist/existing/
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.
Thanks
pkg/utils/command.go
Outdated
if err != nil || ret == nil { | ||
time.Sleep(interval) | ||
continue | ||
} else if ret.ExitStatus != 0 { |
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.
We are not fans of else
. 😃
If the if block ends up with continue
or return
, we suggest that we could eliminate else
.
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, it can change like these:
if err != nil || ret == nil || ret.ExitStatus != 0 {
time.Sleep(interval)
continue
}
I left some comments, while it is still too large review. In addition, I have one question for us? |
I will add some unit tests in the next few days. |
@@ -0,0 +1,55 @@ | |||
package serializer |
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.
Can remove the serializer package ??? Use json package directly ????
pkg/node/idc.go
Outdated
@@ -0,0 +1,7 @@ | |||
// +build linux |
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.
这个文件的代码感觉不太好,应该抽象成工具,而不是 idc.
cli/http_request.go
Outdated
@@ -36,7 +36,7 @@ func (r *Request) Send() *Response { | |||
response.Err = ErrHTTP5xx | |||
return response | |||
} | |||
if resp.StatusCode != http.StatusOK { | |||
if resp.StatusCode < 200 || resp.StatusCode > 300 { |
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.
'> 300' to '>= 300' ????
cli.AddCommand(base, &StartCommand{}) | ||
cli.AddCommand(base, &VersionCommand{}) | ||
cli.AddCommand(base, &ImageCommand{}) | ||
cli.AddCommand(base, &VolumeCommand{}) |
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 define the "base" command, and pass it to "AddCommand" ??? If you need to define the "base" command, I think that You may be put it into "AddCommand", so don't need to pass it here.
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.
Oh, I understand what you mean, please ignore the above comment.
daemon/mgr/volume.go
Outdated
_ "github.com/alibaba/pouch/volume/modules/ceph" | ||
_ "github.com/alibaba/pouch/volume/modules/local" | ||
_ "github.com/alibaba/pouch/volume/modules/tmpfs" | ||
_ "github.com/alibaba/pouch/volume/store/boltdb" |
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.
Please put these imports in some "*_builtin.go", Is it better ????
eg:
ceph_builtin.go
// +build ceph
package mrg
_ "github.com/alibaba/pouch/volume/modules/ceph"
local_builtin.go
// +build !local
_ "github.com/alibaba/pouch/volume/modules/local"
and so on.
daemon/mgr/volume.go
Outdated
// VolumeManager is the default implement of interface VolumeMgr. | ||
type VolumeManager struct { | ||
Core *volume.Core | ||
Store *meta.Store |
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.
s / "Core" and "Store" / "core" and "store" ?????
pkg/utils/command.go
Outdated
@@ -0,0 +1,74 @@ | |||
package utils |
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.
Could you put these codes ("command.go") into "pkg/exec/exec.go", then remove the "command.go" file.
I think that is more uniform on the realization.
Add container's volume manager in pouch. Ultron: (Container Storage Manager), used to manager the container's volume, it supports local and remote storages. Local storage is local disk on the server, such as hdd disk, memory disk, tmpfs and so on. Remote storage is connecting to central storage or distributed storage, such as ceph, nas, aws EBS. Ultron supports local/remote mode, remote mode can schedue the volume base on storage which is the the optimal storage. More information about ultron is coming soon... Signed-off-by: Rudy Zhang <rudyflyzhang@gmail.com>
LGTM |
Add container's volume manager in pouch.
Ultron: (Container Storage Manager), used to manager the container's
volume, it supports local and remote storages. Local storage is local
disk on the server, such as hdd disk, memory disk, tmpfs and so on.
Remote storage is connecting to central storage or distributed storage,
such as ceph, nas, aws EBS.
Ultron supports local/remote mode, remote mode can schedue the volume
base on storage which is the the optimal storage.
More information about ultron is coming soon...
Signed-off-by: Rudy Zhang rudyflyzhang@gmail.com