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

feature: add container's volume manager #15

Merged
merged 1 commit into from
Nov 1, 2017
Merged

feature: add container's volume manager #15

merged 1 commit into from
Nov 1, 2017

Conversation

rudyfly
Copy link
Collaborator

@rudyfly rudyfly commented Oct 25, 2017

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

@@ -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 {
Copy link
Collaborator

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.
Copy link
Collaborator

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...

Copy link
Collaborator Author

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?

Copy link
Collaborator

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",
Copy link
Collaborator

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?

Copy link
Collaborator Author

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)
Copy link
Collaborator

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)
Copy link
Collaborator

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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

same comments above 🍺

// 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.
Copy link
Collaborator

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/

return vm.Core.CreateVolume(id)
}

// Remove is used delete an exist volume.
Copy link
Collaborator

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/

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks

if err != nil || ret == nil {
time.Sleep(interval)
continue
} else if ret.ExitStatus != 0 {
Copy link
Collaborator

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.

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, it can change like these:
if err != nil || ret == nil || ret.ExitStatus != 0 {
time.Sleep(interval)
continue
}

@allencloud
Copy link
Collaborator

allencloud commented Oct 30, 2017

I left some comments, while it is still too large review.
I am afraid I need some other maintainer's help to finish this.

In addition, I have one question for us?
Do we have any plan to add some unit tests for the added code? @rudyfly 🐯

@rudyfly
Copy link
Collaborator Author

rudyfly commented Oct 30, 2017

I will add some unit tests in the next few days.

@@ -0,0 +1,55 @@
package serializer
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

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

这个文件的代码感觉不太好,应该抽象成工具,而不是 idc.

@@ -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 {
Copy link
Contributor

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{})
Copy link
Contributor

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.

Copy link
Contributor

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.

_ "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"
Copy link
Contributor

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.

// VolumeManager is the default implement of interface VolumeMgr.
type VolumeManager struct {
Core *volume.Core
Store *meta.Store
Copy link
Contributor

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" ?????

@@ -0,0 +1,74 @@
package utils
Copy link
Contributor

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>
@skoowoo
Copy link
Contributor

skoowoo commented Nov 1, 2017

LGTM

@allencloud allencloud added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Nov 1, 2017
@skoowoo skoowoo merged commit bb359be into AliyunContainerService:master Nov 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature LGTM one maintainer or community participant agrees to merge the pull reuqest. size/XXL volume
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants