Skip to content

Commit 6543e54

Browse files
kayrusmandre
authored andcommitted
Remove unused manila code (kubernetes#2299)
1 parent 8b2ed3b commit 6543e54

File tree

13 files changed

+86
-274
lines changed

13 files changed

+86
-274
lines changed

cmd/manila-csi-plugin/main.go

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
"k8s.io/cloud-provider-openstack/pkg/csi/manila"
2828
"k8s.io/cloud-provider-openstack/pkg/csi/manila/csiclient"
2929
"k8s.io/cloud-provider-openstack/pkg/csi/manila/manilaclient"
30-
"k8s.io/cloud-provider-openstack/pkg/csi/manila/options"
3130
"k8s.io/cloud-provider-openstack/pkg/csi/manila/runtimeconfig"
3231
"k8s.io/component-base/cli"
3332
"k8s.io/klog/v2"
@@ -65,38 +64,6 @@ func validateShareProtocolSelector(v string) error {
6564
return fmt.Errorf("share protocol %q not supported; supported protocols are %v", v, supportedShareProtocols)
6665
}
6766

68-
func parseCompatOpts() (*options.CompatibilityOptions, error) {
69-
data := make(map[string]string)
70-
71-
if compatibilitySettings == "" {
72-
return options.NewCompatibilityOptions(data)
73-
}
74-
75-
knownCompatSettings := map[string]interface{}{}
76-
77-
isKnown := func(v string) bool {
78-
_, ok := knownCompatSettings[v]
79-
return ok
80-
}
81-
82-
settings := strings.Split(compatibilitySettings, ",")
83-
for _, elem := range settings {
84-
setting := strings.SplitN(elem, "=", 2)
85-
86-
if len(setting) != 2 || setting[0] == "" || setting[1] == "" {
87-
return nil, fmt.Errorf("invalid format in option %v, expected KEY=VALUE", setting)
88-
}
89-
90-
if !isKnown(setting[0]) {
91-
return nil, fmt.Errorf("unrecognized option '%s'", setting[0])
92-
}
93-
94-
data[setting[0]] = setting[1]
95-
}
96-
97-
return options.NewCompatibilityOptions(data)
98-
}
99-
10067
func main() {
10168
if err := flag.CommandLine.Parse([]string{}); err != nil {
10269
klog.Fatalf("Unable to parse flags: %v", err)
@@ -131,11 +98,6 @@ func main() {
13198
klog.Fatalf(err.Error())
13299
}
133100

134-
compatOpts, err := parseCompatOpts()
135-
if err != nil {
136-
klog.Fatalf("failed to parse compatibility settings: %v", err)
137-
}
138-
139101
manilaClientBuilder := &manilaclient.ClientBuilder{UserAgent: "manila-csi-plugin", ExtraUserAgentData: userAgentData}
140102
csiClientBuilder := &csiclient.ClientBuilder{}
141103

@@ -150,7 +112,6 @@ func main() {
150112
FwdCSIEndpoint: fwdEndpoint,
151113
ManilaClientBuilder: manilaClientBuilder,
152114
CSIClientBuilder: csiClientBuilder,
153-
CompatOpts: compatOpts,
154115
ClusterID: clusterID,
155116
},
156117
)

pkg/csi/manila/capabilities/manilacapabilities.go

Lines changed: 0 additions & 70 deletions
This file was deleted.

pkg/csi/manila/compatibility/compatibility.go

Lines changed: 0 additions & 44 deletions
This file was deleted.

pkg/csi/manila/controllerserver.go

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
"google.golang.org/grpc/status"
2828
"google.golang.org/protobuf/types/known/timestamppb"
2929
"k8s.io/apimachinery/pkg/util/wait"
30-
"k8s.io/cloud-provider-openstack/pkg/csi/manila/capabilities"
3130
"k8s.io/cloud-provider-openstack/pkg/csi/manila/options"
3231
"k8s.io/cloud-provider-openstack/pkg/csi/manila/shareadapters"
3332
"k8s.io/cloud-provider-openstack/pkg/util"
@@ -123,11 +122,6 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
123122
return nil, status.Errorf(codes.Unauthenticated, "failed to create Manila v2 client: %v", err)
124123
}
125124

126-
shareTypeCaps, err := capabilities.GetManilaCapabilities(shareOpts.Type, manilaClient)
127-
if err != nil {
128-
return nil, status.Errorf(codes.Internal, "failed to get Manila capabilities for share type %s: %v", shareOpts.Type, err)
129-
}
130-
131125
requestedSize := req.GetCapacityRange().GetRequiredBytes()
132126
if requestedSize == 0 {
133127
// At least 1GiB
@@ -159,12 +153,12 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
159153
return nil, err
160154
}
161155

162-
share, err := volCreator.create(req, req.GetName(), sizeInGiB, manilaClient, shareOpts, shareMetadata)
156+
share, err := volCreator.create(manilaClient, req, req.GetName(), sizeInGiB, shareOpts, shareMetadata)
163157
if err != nil {
164158
return nil, err
165159
}
166160

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

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

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

272266
// Retrieve an existing snapshot or create a new one
273267

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

304-
manilaErrMsg, err := lastResourceError(snapshot.ID, manilaClient)
298+
manilaErrMsg, err := lastResourceError(manilaClient, snapshot.ID)
305299
if err != nil {
306300
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())
307301
}
@@ -344,7 +338,7 @@ func (cs *controllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteS
344338
return nil, status.Errorf(codes.Unauthenticated, "failed to create Manila v2 client: %v", err)
345339
}
346340

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

@@ -482,7 +476,7 @@ func (cs *controllerServer) ControllerExpandVolume(ctx context.Context, req *csi
482476
}, nil
483477
}
484478

485-
share, err = extendShare(share.ID, desiredSizeInGiB, manilaClient)
479+
share, err = extendShare(manilaClient, share.ID, desiredSizeInGiB)
486480
if err != nil {
487481
return nil, err
488482
}

pkg/csi/manila/driver.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
"google.golang.org/grpc"
3232
"k8s.io/cloud-provider-openstack/pkg/csi/manila/csiclient"
3333
"k8s.io/cloud-provider-openstack/pkg/csi/manila/manilaclient"
34-
"k8s.io/cloud-provider-openstack/pkg/csi/manila/options"
3534
"k8s.io/cloud-provider-openstack/pkg/version"
3635
"k8s.io/klog/v2"
3736
)
@@ -49,8 +48,6 @@ type DriverOpts struct {
4948

5049
ManilaClientBuilder manilaclient.Builder
5150
CSIClientBuilder csiclient.Builder
52-
53-
CompatOpts *options.CompatibilityOptions
5451
}
5552

5653
type Driver struct {
@@ -65,8 +62,6 @@ type Driver struct {
6562
serverEndpoint string
6663
fwdEndpoint string
6764

68-
compatOpts *options.CompatibilityOptions
69-
7065
ids *identityServer
7166
cs *controllerServer
7267
ns *nodeServer
@@ -103,7 +98,14 @@ func argNotEmpty(val, name string) error {
10398
}
10499

105100
func NewDriver(o *DriverOpts) (*Driver, error) {
106-
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} {
101+
m := map[string]string{
102+
"node ID": o.NodeID,
103+
"driver name": o.DriverName,
104+
"driver endpoint": o.ServerCSIEndpoint,
105+
"FWD endpoint": o.FwdCSIEndpoint,
106+
"share protocol selector": o.ShareProto,
107+
}
108+
for k, v := range m {
107109
if err := argNotEmpty(v, k); err != nil {
108110
return nil, err
109111
}
@@ -118,7 +120,6 @@ func NewDriver(o *DriverOpts) (*Driver, error) {
118120
serverEndpoint: o.ServerCSIEndpoint,
119121
fwdEndpoint: o.FwdCSIEndpoint,
120122
shareProto: strings.ToUpper(o.ShareProto),
121-
compatOpts: o.CompatOpts,
122123
manilaClientBuilder: o.ManilaClientBuilder,
123124
csiClientBuilder: o.CSIClientBuilder,
124125
clusterID: o.ClusterID,

0 commit comments

Comments
 (0)