Skip to content

Commit

Permalink
Use snapshot v1 client
Browse files Browse the repository at this point in the history
  • Loading branch information
xing-yang committed Nov 17, 2020
1 parent 8d12c5e commit c1cb7e5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/csi-provisioner/csi-provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func main() {
klog.Fatalf("Failed to create client: %v", err)
}

// snapclientset.NewForConfig creates a new Clientset for VolumesnapshotV1beta1Client
// snapclientset.NewForConfig creates a new Clientset for VolumesnapshotV1Client
snapClient, err := snapclientset.NewForConfig(config)
if err != nil {
klog.Fatalf("Failed to create snapshot client: %v", err)
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import (
"github.com/kubernetes-csi/csi-lib-utils/connection"
"github.com/kubernetes-csi/csi-lib-utils/metrics"
"github.com/kubernetes-csi/csi-lib-utils/rpc"
snapapi "github.com/kubernetes-csi/external-snapshotter/client/v3/apis/volumesnapshot/v1beta1"
snapapi "github.com/kubernetes-csi/external-snapshotter/client/v3/apis/volumesnapshot/v1"
snapclientset "github.com/kubernetes-csi/external-snapshotter/client/v3/clientset/versioned"
)

Expand Down Expand Up @@ -918,7 +918,7 @@ func (p *csiProvisioner) getPVCSource(ctx context.Context, options controller.Pr
// getSnapshotSource verifies DataSource.Kind of type VolumeSnapshot, making sure that the requested Snapshot is available/ready
// returns the VolumeContentSource for the requested snapshot
func (p *csiProvisioner) getSnapshotSource(ctx context.Context, options controller.ProvisionOptions) (*csi.VolumeContentSource, error) {
snapshotObj, err := p.snapshotClient.SnapshotV1beta1().VolumeSnapshots(options.PVC.Namespace).Get(ctx, options.PVC.Spec.DataSource.Name, metav1.GetOptions{})
snapshotObj, err := p.snapshotClient.SnapshotV1().VolumeSnapshots(options.PVC.Namespace).Get(ctx, options.PVC.Spec.DataSource.Name, metav1.GetOptions{})
if err != nil {
return nil, fmt.Errorf("error getting snapshot %s from api server: %v", options.PVC.Spec.DataSource.Name, err)
}
Expand All @@ -932,7 +932,7 @@ func (p *csiProvisioner) getSnapshotSource(ctx context.Context, options controll
return nil, fmt.Errorf(snapshotNotBound, options.PVC.Spec.DataSource.Name)
}

snapContentObj, err := p.snapshotClient.SnapshotV1beta1().VolumeSnapshotContents().Get(ctx, *snapshotObj.Status.BoundVolumeSnapshotContentName, metav1.GetOptions{})
snapContentObj, err := p.snapshotClient.SnapshotV1().VolumeSnapshotContents().Get(ctx, *snapshotObj.Status.BoundVolumeSnapshotContentName, metav1.GetOptions{})

if err != nil {
klog.Warningf("error getting snapshotcontent %s for snapshot %s/%s from api server: %s", *snapshotObj.Status.BoundVolumeSnapshotContentName, snapshotObj.Namespace, snapshotObj.Name, err)
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import (
"github.com/kubernetes-csi/csi-lib-utils/rpc"
"github.com/kubernetes-csi/csi-test/v3/driver"
"github.com/kubernetes-csi/external-provisioner/pkg/features"
crdv1 "github.com/kubernetes-csi/external-snapshotter/client/v3/apis/volumesnapshot/v1beta1"
crdv1 "github.com/kubernetes-csi/external-snapshotter/client/v3/apis/volumesnapshot/v1"
"github.com/kubernetes-csi/external-snapshotter/client/v3/clientset/versioned/fake"
)

Expand Down Expand Up @@ -1817,7 +1817,7 @@ func newSnapshot(name, className, boundToContent, snapshotUID, claimName string,
Namespace: "default",
UID: types.UID(snapshotUID),
ResourceVersion: "1",
SelfLink: "/apis/snapshot.storage.k8s.io/v1beta1/namespaces/" + "default" + "/volumesnapshots/" + name,
SelfLink: "/apis/snapshot.storage.k8s.io/v1/namespaces/" + "default" + "/volumesnapshots/" + name,
},
Spec: crdv1.VolumeSnapshotSpec{
Source: crdv1.VolumeSnapshotSource{
Expand Down Expand Up @@ -2034,7 +2034,7 @@ func newContent(name, className, snapshotHandle, volumeUID, volumeName, boundToS
if boundToSnapshotName != "" {
content.Spec.VolumeSnapshotRef = v1.ObjectReference{
Kind: "VolumeSnapshot",
APIVersion: "snapshot.storage.k8s.io/v1beta1",
APIVersion: "snapshot.storage.k8s.io/v1",
UID: types.UID(boundToSnapshotUID),
Namespace: "default",
Name: boundToSnapshotName,
Expand Down

0 comments on commit c1cb7e5

Please sign in to comment.