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

refactor: remove ceph volume plugin #1441

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ validate-swagger: ## run swagger validate
.PHONY: modules
modules:
@./hack/module --clean
@./hack/module --add-volume=github.com/alibaba/pouch/storage/volume/modules/ceph
@./hack/module --add-volume=github.com/alibaba/pouch/storage/volume/modules/tmpfs
@./hack/module --add-volume=github.com/alibaba/pouch/storage/volume/modules/local

Expand Down
6 changes: 1 addition & 5 deletions apis/server/volume_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ func (s *Server) createVolume(ctx context.Context, rw http.ResponseWriter, req *
driver = volumetypes.DefaultBackend
}

if err := s.VolumeMgr.Create(ctx, name, driver, options, labels); err != nil {
return err
}

volume, err := s.VolumeMgr.Get(ctx, name)
volume, err := s.VolumeMgr.Create(ctx, name, driver, options, labels)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion daemon/mgr/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -1771,7 +1771,7 @@ func (mgr *ContainerManager) attachVolume(ctx context.Context, name string, meta
opts := map[string]string{
"backend": driver,
}
if err := mgr.VolumeMgr.Create(ctx, name, meta.HostConfig.VolumeDriver, opts, nil); err != nil {
if _, err := mgr.VolumeMgr.Create(ctx, name, meta.HostConfig.VolumeDriver, opts, nil); err != nil {
logrus.Errorf("failed to create volume: %s, err: %v", name, err)
return "", "", errors.Wrap(err, "failed to create volume")
}
Expand Down
27 changes: 9 additions & 18 deletions daemon/mgr/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package mgr
import (
"context"
"os"
"path"
"strings"

"github.com/alibaba/pouch/pkg/errtypes"
Expand All @@ -16,7 +15,7 @@ import (
// VolumeMgr defines interface to manage container volume.
type VolumeMgr interface {
// Create is used to create volume.
Create(ctx context.Context, name, driver string, options, labels map[string]string) error
Create(ctx context.Context, name, driver string, options, labels map[string]string) (*types.Volume, error)

// Get returns the information of volume that specified name/id.
Get(ctx context.Context, name string) (*types.Volume, error)
Expand Down Expand Up @@ -59,33 +58,25 @@ func NewVolumeManager(cfg volume.Config) (*VolumeManager, error) {
}

// Create is used to create volume.
func (vm *VolumeManager) Create(ctx context.Context, name, driver string, options, labels map[string]string) error {
func (vm *VolumeManager) Create(ctx context.Context, name, driver string, options, labels map[string]string) (*types.Volume, error) {
if driver == "" {
driver = types.DefaultBackend
}

id := types.VolumeID{
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 the naming of VolumeID is so bad.
Is there anyway to change this to be a more readable one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@allencloud I will refactor VolumeID in other PRs later

Name: name,
Driver: driver,
Options: map[string]string{},
Selectors: map[string]string{},
Labels: map[string]string{},
}

if labels != nil {
id.Labels = labels
} else {
id.Labels = map[string]string{}
}

for key, opt := range options {
if strings.HasPrefix(key, "selector.") {
key = strings.TrimPrefix(key, "selector.")
id.Selectors[key] = opt
continue
}

id.Options[key] = opt
}

// set default volume mount path
if mount, ok := id.Options["mount"]; !ok || mount == "" {
id.Options["mount"] = path.Dir(vm.core.VolumeMetaPath)
if options != nil {
id.Options = options
}

return vm.core.CreateVolume(id)
Expand Down
115 changes: 0 additions & 115 deletions storage/controlserver/client/client.go

This file was deleted.

28 changes: 0 additions & 28 deletions storage/controlserver/client/errors.go

This file was deleted.

Loading