Skip to content

Commit e9c88d2

Browse files
committed
Update external-provisioner to use csi spec 1.0
1 parent 64d2d4e commit e9c88d2

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

pkg/controller/controller.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ func getDriverCapabilities(conn *grpc.ClientConn, timeout time.Duration) (sets.I
200200
switch service.GetType() {
201201
case csi.PluginCapability_Service_CONTROLLER_SERVICE:
202202
capabilities.Insert(PluginCapability_CONTROLLER_SERVICE)
203-
case csi.PluginCapability_Service_ACCESSIBILITY_CONSTRAINTS:
203+
case csi.PluginCapability_Service_VOLUME_ACCESSIBILITY_CONSTRAINTS:
204204
capabilities.Insert(PluginCapability_ACCESSIBILITY_CONSTRAINTS)
205205
}
206206
}
@@ -458,7 +458,7 @@ func (p *csiProvisioner) Provision(options controller.VolumeOptions) (*v1.Persis
458458
if err != nil {
459459
return nil, err
460460
}
461-
req.ControllerCreateSecrets = provisionerCredentials
461+
req.Secrets = provisionerCredentials
462462

463463
// Resolve controller publish, node stage, node publish secret references
464464
controllerPublishSecretRef, err := getSecretReference(controllerPublishSecretNameKey, controllerPublishSecretNamespaceKey, options.Parameters, pvName, options.PVC)
@@ -503,16 +503,16 @@ func (p *csiProvisioner) Provision(options controller.VolumeOptions) (*v1.Persis
503503
glog.V(3).Infof("create volume rep: %+v", *rep.Volume)
504504
}
505505
volumeAttributes := map[string]string{provisionerIDKey: p.identity}
506-
for k, v := range rep.Volume.Attributes {
506+
for k, v := range rep.Volume.VolumeContext {
507507
volumeAttributes[k] = v
508508
}
509509
respCap := rep.GetVolume().GetCapacityBytes()
510510
if respCap < volSizeBytes {
511511
capErr := fmt.Errorf("created volume capacity %v less than requested capacity %v", respCap, volSizeBytes)
512512
delReq := &csi.DeleteVolumeRequest{
513-
VolumeId: rep.GetVolume().GetId(),
513+
VolumeId: rep.GetVolume().GetVolumeId(),
514514
}
515-
delReq.ControllerDeleteSecrets = provisionerCredentials
515+
delReq.Secrets = provisionerCredentials
516516
ctx, cancel := context.WithTimeout(context.Background(), p.timeout)
517517
defer cancel()
518518
_, err := p.csiClient.DeleteVolume(ctx, delReq)
@@ -537,7 +537,7 @@ func (p *csiProvisioner) Provision(options controller.VolumeOptions) (*v1.Persis
537537
PersistentVolumeSource: v1.PersistentVolumeSource{
538538
CSI: &v1.CSIPersistentVolumeSource{
539539
Driver: driverState.driverName,
540-
VolumeHandle: p.volumeIdToHandle(rep.Volume.Id),
540+
VolumeHandle: p.volumeIdToHandle(rep.Volume.VolumeId),
541541
FSType: fsType,
542542
VolumeAttributes: volumeAttributes,
543543
ControllerPublishSecretRef: controllerPublishSecretRef,
@@ -584,7 +584,7 @@ func (p *csiProvisioner) getVolumeContentSource(options controller.VolumeOptions
584584

585585
snapshotSource := csi.VolumeContentSource_Snapshot{
586586
Snapshot: &csi.VolumeContentSource_SnapshotSource{
587-
Id: snapContentObj.Spec.VolumeSnapshotSource.CSI.SnapshotHandle,
587+
SnapshotId: snapContentObj.Spec.VolumeSnapshotSource.CSI.SnapshotHandle,
588588
},
589589
}
590590
glog.V(5).Infof("VolumeContentSource_Snapshot %+v", snapshotSource)
@@ -641,7 +641,7 @@ func (p *csiProvisioner) Delete(volume *v1.PersistentVolume) error {
641641
if err != nil {
642642
return err
643643
}
644-
req.ControllerDeleteSecrets = credentials
644+
req.Secrets = credentials
645645
}
646646

647647
}

pkg/controller/controller_test.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
"github.com/kubernetes-incubator/external-storage/lib/controller"
3535
"google.golang.org/grpc"
3636
"k8s.io/api/core/v1"
37+
corev1 "k8s.io/api/core/v1"
3738
storage "k8s.io/api/storage/v1beta1"
3839
"k8s.io/apimachinery/pkg/api/resource"
3940
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -287,7 +288,7 @@ func TestGetDriverCapabilities(t *testing.T) {
287288
switch *cap {
288289
case csi.PluginCapability_Service_CONTROLLER_SERVICE:
289290
ok = ok && capabilities.Has(PluginCapability_CONTROLLER_SERVICE)
290-
case csi.PluginCapability_Service_ACCESSIBILITY_CONSTRAINTS:
291+
case csi.PluginCapability_Service_VOLUME_ACCESSIBILITY_CONSTRAINTS:
291292
ok = ok && capabilities.Has(PluginCapability_ACCESSIBILITY_CONSTRAINTS)
292293
}
293294
}
@@ -443,7 +444,7 @@ func TestCreateDriverReturnsInvalidCapacityDuringProvision(t *testing.T) {
443444
out := &csi.CreateVolumeResponse{
444445
Volume: &csi.Volume{
445446
CapacityBytes: requestedBytes - 1,
446-
Id: "test-volume-id",
447+
VolumeId: "test-volume-id",
447448
},
448449
}
449450

@@ -544,7 +545,7 @@ func provisionWithTopologyMockServerSetupExpectations(identityServer *driver.Moc
544545
{
545546
Type: &csi.PluginCapability_Service_{
546547
Service: &csi.PluginCapability_Service{
547-
Type: csi.PluginCapability_Service_ACCESSIBILITY_CONSTRAINTS,
548+
Type: csi.PluginCapability_Service_VOLUME_ACCESSIBILITY_CONSTRAINTS,
548549
},
549550
},
550551
},
@@ -1133,7 +1134,7 @@ func TestProvision(t *testing.T) {
11331134
out := &csi.CreateVolumeResponse{
11341135
Volume: &csi.Volume{
11351136
CapacityBytes: requestedBytes,
1136-
Id: "test-volume-id",
1137+
VolumeId: "test-volume-id",
11371138
},
11381139
}
11391140

@@ -1220,7 +1221,7 @@ func newSnapshot(name, className, boundToContent, snapshotUID, claimName string,
12201221
SelfLink: "/apis/snapshot.storage.k8s.io/v1alpha1/namespaces/" + "default" + "/volumesnapshots/" + name,
12211222
},
12221223
Spec: crdv1.VolumeSnapshotSpec{
1223-
Source: &crdv1.TypedLocalObjectReference{
1224+
Source: &corev1.TypedLocalObjectReference{
12241225
Name: claimName,
12251226
Kind: "PersistentVolumeClaim",
12261227
},
@@ -1512,7 +1513,7 @@ func TestProvisionFromSnapshot(t *testing.T) {
15121513
out := &csi.CreateVolumeResponse{
15131514
Volume: &csi.Volume{
15141515
CapacityBytes: requestedBytes,
1515-
Id: "test-volume-id",
1516+
VolumeId: "test-volume-id",
15161517
},
15171518
}
15181519

@@ -1607,7 +1608,7 @@ func TestProvisionWithTopology(t *testing.T) {
16071608
out := &csi.CreateVolumeResponse{
16081609
Volume: &csi.Volume{
16091610
CapacityBytes: requestBytes,
1610-
Id: "test-volume-id",
1611+
VolumeId: "test-volume-id",
16111612
AccessibleTopology: accessibleTopology,
16121613
},
16131614
}
@@ -1645,7 +1646,7 @@ func TestProvisionWithMountOptions(t *testing.T) {
16451646
out := &csi.CreateVolumeResponse{
16461647
Volume: &csi.Volume{
16471648
CapacityBytes: requestBytes,
1648-
Id: "test-volume-id",
1649+
VolumeId: "test-volume-id",
16491650
},
16501651
}
16511652

0 commit comments

Comments
 (0)