Skip to content

Commit

Permalink
Merge pull request #14 from bizflycloud/feat/Add_PVC_name
Browse files Browse the repository at this point in the history
Feat/add pvc name
  • Loading branch information
greatbn authored Aug 30, 2021
2 parents 4b3b292 + b31d2ef commit ea71765
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 16 deletions.
4 changes: 2 additions & 2 deletions cmd/csi-bizflycloud/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ func handle() {
klog.Errorf("Failed to get bizfly client token: %v", err)
return
}
client.SetKeystoneToken(tok.KeystoneToken)

client.SetKeystoneToken(tok)
d.SetupControlDriver(client, iMount, metadatda)
d.Run()
} else {
Expand Down
2 changes: 1 addition & 1 deletion driver/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func diskIsAttached(ctx context.Context, client *gobizfly.Client, serverId strin
}

func GetSnapshotByNameAndVolumeID(ctx context.Context, client *gobizfly.Client, volumeId string, name string) ([]*gobizfly.Snapshot, error) {
snapshots, err := client.Snapshot.List(ctx, &gobizfly.ListOptions{})
snapshots, err := client.Snapshot.List(ctx, &gobizfly.ListSnasphotsOptions{})
if err != nil {
return nil, err
}
Expand Down
7 changes: 5 additions & 2 deletions driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
// Volume Availability - Default is nova
volAvailability = req.GetParameters()["availability"]
}

volPVCName := req.GetParameters()["csi.storage.k8s.io/pvc/name"]
volPVCNamespace := req.GetParameters()["csi.storage.k8s.io/pvc/namespace"]
Description := volPVCNamespace + "/" + volPVCName + " by csi-bizflycloud"
client := cs.Client

// Verify a volume with the provided name doesn't already exist for this tenant
Expand Down Expand Up @@ -106,6 +108,7 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
AvailabilityZone: volAvailability,
SnapshotID: snapshotID,
VolumeCategory: volCategory,
Description: Description,
}
vol, err := cs.Client.Volume.Create(ctx, &vcr)
if err != nil {
Expand Down Expand Up @@ -405,7 +408,7 @@ func (cs *controllerServer) ListSnapshots(ctx context.Context, req *csi.ListSnap
return nil, status.Error(codes.Internal, fmt.Sprintf("ListSnapshots get snapshot failed with error %v", err))
}
} else {
vlist, err = cs.Client.Snapshot.List(ctx, &gobizfly.ListOptions{})
vlist, err = cs.Client.Snapshot.List(ctx, &gobizfly.ListSnasphotsOptions{})
if err != nil {
klog.V(3).Infof("Failed to ListSnapshots: %v", err)
return nil, status.Error(codes.Internal, fmt.Sprintf("ListSnapshots get snapshot failed with error %v", err))
Expand Down
1 change: 1 addition & 0 deletions examples/pvc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ spec:
requests:
storage: 50Gi
storageClassName: premium-hdd

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/bizflycloud/csi-bizflycloud
go 1.14

require (
github.com/bizflycloud/gobizfly v0.0.0-20200925081217-c929a1f56559
github.com/bizflycloud/gobizfly v0.0.0-20210826035312-56219bf93eb1
github.com/container-storage-interface/spec v1.2.0
github.com/golang/protobuf v1.4.1
github.com/spf13/cobra v1.0.0
Expand Down
12 changes: 2 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bifurcation/mint v0.0.0-20180715133206-93c51c6ce115/go.mod h1:zVt7zX3K/aDCk9Tj+VM7YymsX66ERvzCJzw8rFCX2JU=
github.com/bizflycloud/gobizfly v0.0.0-20200509022858-1dd705ff35b3 h1:3195YbHKzPFwKiRPXD75xUu0S3MWiCeSTr7liXqNoc0=
github.com/bizflycloud/gobizfly v0.0.0-20200509022858-1dd705ff35b3/go.mod h1:2otUgZd6PrKezjMrdAw9gy7byEXMrigX9Sm4ujCaFuk=
github.com/bizflycloud/gobizfly v0.0.0-20200514081735-03c430a0585b h1:9DaY0hAkK/PGs12481LXTyFmuGKfkW6u7VPsyRXuPHk=
github.com/bizflycloud/gobizfly v0.0.0-20200514081735-03c430a0585b/go.mod h1:2otUgZd6PrKezjMrdAw9gy7byEXMrigX9Sm4ujCaFuk=
github.com/bizflycloud/gobizfly v0.0.0-20200610135315-1b3e23893213 h1:Ihr811tiEnUKB0QaDJglGI+fCwFrcXy8Q17vpFTEvEc=
github.com/bizflycloud/gobizfly v0.0.0-20200610135315-1b3e23893213/go.mod h1:2otUgZd6PrKezjMrdAw9gy7byEXMrigX9Sm4ujCaFuk=
github.com/bizflycloud/gobizfly v0.0.0-20200824165811-4aad89a434b1 h1:MVd1DoK4jZD1vCSc8h0/ztu9BvLauoMJLo/XyV3AMl8=
github.com/bizflycloud/gobizfly v0.0.0-20200824165811-4aad89a434b1/go.mod h1:2otUgZd6PrKezjMrdAw9gy7byEXMrigX9Sm4ujCaFuk=
github.com/bizflycloud/gobizfly v0.0.0-20200925081217-c929a1f56559 h1:U/5x1+bfz+5IMTf6mAW6IeyZdwr2vumjnegerwS9VAg=
github.com/bizflycloud/gobizfly v0.0.0-20200925081217-c929a1f56559/go.mod h1:2otUgZd6PrKezjMrdAw9gy7byEXMrigX9Sm4ujCaFuk=
github.com/bizflycloud/gobizfly v0.0.0-20210826035312-56219bf93eb1 h1:q6w8IOT74Jy2XU+urDQKIlnF6miAHQT51f1RR02DdNY=
github.com/bizflycloud/gobizfly v0.0.0-20210826035312-56219bf93eb1/go.mod h1:dESSbBmjQ5OJBgRPCTgmxAeqxNnRzXIZuRK3CTW2DUs=
github.com/blang/semver v3.5.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g=
Expand Down
1 change: 1 addition & 0 deletions manifest/plugin/csi-bizflycloud-controllerplugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ spec:
- "--csi-address=/var/lib/csi/sockets/pluginproxy/csi.sock"
- "--timeout=3m"
- "--feature-gates=Topology=true"
- "--extra-create-metadata=True"
volumeMounts:
- name: socket-dir
mountPath: /var/lib/csi/sockets/pluginproxy/
Expand Down

0 comments on commit ea71765

Please sign in to comment.