Skip to content

Commit

Permalink
Remove unused manila code (#2299)
Browse files Browse the repository at this point in the history
  • Loading branch information
kayrus authored Jul 20, 2023
1 parent 0514aba commit 64b382f
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 274 deletions.
39 changes: 0 additions & 39 deletions cmd/manila-csi-plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"k8s.io/cloud-provider-openstack/pkg/csi/manila"
"k8s.io/cloud-provider-openstack/pkg/csi/manila/csiclient"
"k8s.io/cloud-provider-openstack/pkg/csi/manila/manilaclient"
"k8s.io/cloud-provider-openstack/pkg/csi/manila/options"
"k8s.io/cloud-provider-openstack/pkg/csi/manila/runtimeconfig"
"k8s.io/component-base/cli"
"k8s.io/klog/v2"
Expand Down Expand Up @@ -65,38 +64,6 @@ func validateShareProtocolSelector(v string) error {
return fmt.Errorf("share protocol %q not supported; supported protocols are %v", v, supportedShareProtocols)
}

func parseCompatOpts() (*options.CompatibilityOptions, error) {
data := make(map[string]string)

if compatibilitySettings == "" {
return options.NewCompatibilityOptions(data)
}

knownCompatSettings := map[string]interface{}{}

isKnown := func(v string) bool {
_, ok := knownCompatSettings[v]
return ok
}

settings := strings.Split(compatibilitySettings, ",")
for _, elem := range settings {
setting := strings.SplitN(elem, "=", 2)

if len(setting) != 2 || setting[0] == "" || setting[1] == "" {
return nil, fmt.Errorf("invalid format in option %v, expected KEY=VALUE", setting)
}

if !isKnown(setting[0]) {
return nil, fmt.Errorf("unrecognized option '%s'", setting[0])
}

data[setting[0]] = setting[1]
}

return options.NewCompatibilityOptions(data)
}

func main() {
if err := flag.CommandLine.Parse([]string{}); err != nil {
klog.Fatalf("Unable to parse flags: %v", err)
Expand Down Expand Up @@ -131,11 +98,6 @@ func main() {
klog.Fatalf(err.Error())
}

compatOpts, err := parseCompatOpts()
if err != nil {
klog.Fatalf("failed to parse compatibility settings: %v", err)
}

manilaClientBuilder := &manilaclient.ClientBuilder{UserAgent: "manila-csi-plugin", ExtraUserAgentData: userAgentData}
csiClientBuilder := &csiclient.ClientBuilder{}

Expand All @@ -150,7 +112,6 @@ func main() {
FwdCSIEndpoint: fwdEndpoint,
ManilaClientBuilder: manilaClientBuilder,
CSIClientBuilder: csiClientBuilder,
CompatOpts: compatOpts,
ClusterID: clusterID,
},
)
Expand Down
70 changes: 0 additions & 70 deletions pkg/csi/manila/capabilities/manilacapabilities.go

This file was deleted.

44 changes: 0 additions & 44 deletions pkg/csi/manila/compatibility/compatibility.go

This file was deleted.

22 changes: 8 additions & 14 deletions pkg/csi/manila/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/timestamppb"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/cloud-provider-openstack/pkg/csi/manila/capabilities"
"k8s.io/cloud-provider-openstack/pkg/csi/manila/options"
"k8s.io/cloud-provider-openstack/pkg/csi/manila/shareadapters"
"k8s.io/cloud-provider-openstack/pkg/util"
Expand Down Expand Up @@ -123,11 +122,6 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
return nil, status.Errorf(codes.Unauthenticated, "failed to create Manila v2 client: %v", err)
}

shareTypeCaps, err := capabilities.GetManilaCapabilities(shareOpts.Type, manilaClient)
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to get Manila capabilities for share type %s: %v", shareOpts.Type, err)
}

requestedSize := req.GetCapacityRange().GetRequiredBytes()
if requestedSize == 0 {
// At least 1GiB
Expand Down Expand Up @@ -159,12 +153,12 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
return nil, err
}

share, err := volCreator.create(req, req.GetName(), sizeInGiB, manilaClient, shareOpts, shareMetadata)
share, err := volCreator.create(manilaClient, req, req.GetName(), sizeInGiB, shareOpts, shareMetadata)
if err != nil {
return nil, err
}

err = verifyVolumeCompatibility(sizeInGiB, req, share, shareOpts, cs.d.compatOpts, shareTypeCaps)
err = verifyVolumeCompatibility(sizeInGiB, req, share, shareOpts)
if err != nil {
return nil, status.Errorf(codes.AlreadyExists, "volume %s already exists, but is incompatible with the request: %v", req.GetName(), err)
}
Expand Down Expand Up @@ -212,7 +206,7 @@ func (cs *controllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
return nil, status.Errorf(codes.Unauthenticated, "failed to create Manila v2 client: %v", err)
}

if err := deleteShare(req.GetVolumeId(), manilaClient); err != nil {
if err := deleteShare(manilaClient, req.GetVolumeId()); err != nil {
return nil, status.Errorf(codes.Internal, "failed to delete volume %s: %v", req.GetVolumeId(), err)
}

Expand Down Expand Up @@ -271,7 +265,7 @@ func (cs *controllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS

// Retrieve an existing snapshot or create a new one

snapshot, err := getOrCreateSnapshot(req.GetName(), sourceShare.ID, manilaClient)
snapshot, err := getOrCreateSnapshot(manilaClient, req.GetName(), sourceShare.ID)
if err != nil {
if wait.Interrupted(err) {
return nil, status.Errorf(codes.DeadlineExceeded, "deadline exceeded while waiting for snapshot %s of volume %s to become available", snapshot.ID, req.GetSourceVolumeId())
Expand Down Expand Up @@ -299,9 +293,9 @@ func (cs *controllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
readyToUse = true
case snapshotError:
// An error occurred, try to roll-back the snapshot
tryDeleteSnapshot(snapshot, manilaClient)
tryDeleteSnapshot(manilaClient, snapshot)

manilaErrMsg, err := lastResourceError(snapshot.ID, manilaClient)
manilaErrMsg, err := lastResourceError(manilaClient, snapshot.ID)
if err != nil {
return nil, status.Errorf(codes.Internal, "snapshot %s of volume %s is in error state, error description could not be retrieved: %v", snapshot.ID, req.GetSourceVolumeId(), err.Error())
}
Expand Down Expand Up @@ -344,7 +338,7 @@ func (cs *controllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteS
return nil, status.Errorf(codes.Unauthenticated, "failed to create Manila v2 client: %v", err)
}

if err := deleteSnapshot(req.GetSnapshotId(), manilaClient); err != nil {
if err := deleteSnapshot(manilaClient, req.GetSnapshotId()); err != nil {
return nil, status.Errorf(codes.Internal, "failed to delete snapshot %s: %v", req.GetSnapshotId(), err)
}

Expand Down Expand Up @@ -482,7 +476,7 @@ func (cs *controllerServer) ControllerExpandVolume(ctx context.Context, req *csi
}, nil
}

share, err = extendShare(share.ID, desiredSizeInGiB, manilaClient)
share, err = extendShare(manilaClient, share.ID, desiredSizeInGiB)
if err != nil {
return nil, err
}
Expand Down
15 changes: 8 additions & 7 deletions pkg/csi/manila/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"google.golang.org/grpc"
"k8s.io/cloud-provider-openstack/pkg/csi/manila/csiclient"
"k8s.io/cloud-provider-openstack/pkg/csi/manila/manilaclient"
"k8s.io/cloud-provider-openstack/pkg/csi/manila/options"
"k8s.io/cloud-provider-openstack/pkg/version"
"k8s.io/klog/v2"
)
Expand All @@ -49,8 +48,6 @@ type DriverOpts struct {

ManilaClientBuilder manilaclient.Builder
CSIClientBuilder csiclient.Builder

CompatOpts *options.CompatibilityOptions
}

type Driver struct {
Expand All @@ -65,8 +62,6 @@ type Driver struct {
serverEndpoint string
fwdEndpoint string

compatOpts *options.CompatibilityOptions

ids *identityServer
cs *controllerServer
ns *nodeServer
Expand Down Expand Up @@ -103,7 +98,14 @@ func argNotEmpty(val, name string) error {
}

func NewDriver(o *DriverOpts) (*Driver, error) {
for k, v := range map[string]string{"node ID": o.NodeID, "driver name": o.DriverName, "driver endpoint": o.ServerCSIEndpoint, "FWD endpoint": o.FwdCSIEndpoint, "share protocol selector": o.ShareProto} {
m := map[string]string{
"node ID": o.NodeID,
"driver name": o.DriverName,
"driver endpoint": o.ServerCSIEndpoint,
"FWD endpoint": o.FwdCSIEndpoint,
"share protocol selector": o.ShareProto,
}
for k, v := range m {
if err := argNotEmpty(v, k); err != nil {
return nil, err
}
Expand All @@ -118,7 +120,6 @@ func NewDriver(o *DriverOpts) (*Driver, error) {
serverEndpoint: o.ServerCSIEndpoint,
fwdEndpoint: o.FwdCSIEndpoint,
shareProto: strings.ToUpper(o.ShareProto),
compatOpts: o.CompatOpts,
manilaClientBuilder: o.ManilaClientBuilder,
csiClientBuilder: o.CSIClientBuilder,
clusterID: o.ClusterID,
Expand Down
Loading

0 comments on commit 64b382f

Please sign in to comment.