Skip to content

csi: v1.0.0 #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## unreleased

* Add support for CSI SPEC `v1.0.0`. This includes various new changes and
additions in the driver and is intended to be used with Kubernetes `v1.13+`
[[GH-113]](https://github.com/digitalocean/csi-digitalocean/pull/113)
* Add priorityClassName to controller and node plugin to prevent the CSI
components from being evicted in favor of user workloads
[[GH-115]](https://github.com/digitalocean/csi-digitalocean/pull/115)
Expand Down
104 changes: 46 additions & 58 deletions deploy/kubernetes/releases/csi-digitalocean-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,53 +66,6 @@ status:

---

apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
creationTimestamp: null
name: csidrivers.csi.storage.k8s.io
spec:
group: csi.storage.k8s.io
names:
kind: CSIDriver
plural: csidrivers
scope: Cluster
validation:
openAPIV3Schema:
properties:
spec:
description: Specification of the CSI Driver.
properties:
attachRequired:
description: Indicates this CSI volume driver requires an attach operation,
and that Kubernetes should call attach and wait for any attach operation
to complete before proceeding to mount.
type: boolean
podInfoOnMountVersion:
description: Indicates this CSI volume driver requires additional pod
information (like podName, podUID, etc.) during mount operations.
type: string
version: v1alpha1
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []

---

# CSIDriverRegistry feature gate needs to be enabled
apiVersion: csi.storage.k8s.io/v1alpha1
kind: CSIDriver
metadata:
name: dobs.csi.digitalocean.com
spec:
attachRequired: true
podInfoOnMountVersion: "v1"

---

##############################################
########### ############
########### Snapshot CRDs ############
Expand Down Expand Up @@ -190,7 +143,6 @@ provisioner: dobs.csi.digitalocean.com

---


##############################################
########### ############
########### Controller plugin ############
Expand All @@ -215,7 +167,7 @@ spec:
serviceAccount: csi-do-controller-sa
containers:
- name: csi-provisioner
image: quay.io/k8scsi/csi-provisioner:v0.4.1
image: quay.io/k8scsi/csi-provisioner:v1.0.1
args:
- "--provisioner=dobs.csi.digitalocean.com"
- "--csi-address=$(ADDRESS)"
Expand All @@ -228,7 +180,7 @@ spec:
- name: socket-dir
mountPath: /var/lib/csi/sockets/pluginproxy/
- name: csi-attacher
image: quay.io/k8scsi/csi-attacher:v0.4.1
image: quay.io/k8scsi/csi-attacher:v1.0.1
args:
- "--v=5"
- "--csi-address=$(ADDRESS)"
Expand All @@ -240,7 +192,7 @@ spec:
- name: socket-dir
mountPath: /var/lib/csi/sockets/pluginproxy/
- name: csi-snapshotter
image: quay.io/k8scsi/csi-snapshotter:v0.4.1
image: quay.io/k8scsi/csi-snapshotter:v1.0.1
args:
- "--connection-timeout=15s"
- "--csi-address=$(ADDRESS)"
Expand All @@ -251,6 +203,18 @@ spec:
volumeMounts:
- name: socket-dir
mountPath: /var/lib/csi/sockets/pluginproxy/
- name: csi-cluster-driver-registrar
image: quay.io/k8scsi/csi-cluster-driver-registrar:v1.0.1
args:
- "--v=5"
- "--pod-info-mount-version=\"v1\""
- "--csi-address=$(ADDRESS)"
env:
- name: ADDRESS
value: /var/lib/csi/sockets/pluginproxy/csi.sock
volumeMounts:
- name: socket-dir
mountPath: /var/lib/csi/sockets/pluginproxy/
- name: csi-do-plugin
image: digitalocean/do-csi-plugin:dev
args :
Expand Down Expand Up @@ -410,6 +374,30 @@ roleRef:

---

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-do-cluster-driver-registrar-role
rules:
- apiGroups: ["csi.storage.k8s.io"]
resources: ["csidrivers"]
verbs: ["create", "delete"]

---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-do-cluster-driver-registrar-binding
subjects:
- kind: ServiceAccount
name: csi-do-controller-sa
namespace: kube-system
roleRef:
kind: ClusterRole
name: csi-do-cluster-driver-registrar-role
apiGroup: rbac.authorization.k8s.io

---

########################################
########### ############
Expand All @@ -436,15 +424,16 @@ spec:
serviceAccount: csi-do-node-sa
hostNetwork: true
containers:
- name: driver-registrar
image: quay.io/k8scsi/driver-registrar:v0.4.1
- name: csi-node-driver-registrar
image: quay.io/k8scsi/csi-node-driver-registrar:v1.0.1
args:
- "--v=5"
- "--csi-address=$(ADDRESS)"
- "--mode=node-register"
- "--driver-requires-attachment=true"
- "--pod-info-mount-version=\"v1\""
- "--kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)"
lifecycle:
preStop:
exec:
command: ["/bin/sh", "-c", "rm -rf /registration/dobs.csi.digitalocean.com /registration/dobs.csi.digitalocean.com-reg.sock"]
env:
- name: ADDRESS
value: /csi/csi.sock
Expand Down Expand Up @@ -494,7 +483,7 @@ spec:
volumes:
- name: registration-dir
hostPath:
path: /var/lib/kubelet/plugins/
path: /var/lib/kubelet/plugins_registry/
type: DirectoryOrCreate
- name: plugin-dir
hostPath:
Expand Down Expand Up @@ -541,4 +530,3 @@ roleRef:
kind: ClusterRole
name: csi-do-driver-registrar-role
apiGroup: rbac.authorization.k8s.io

57 changes: 25 additions & 32 deletions driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ import (
"strings"
"time"

csi "github.com/container-storage-interface/spec/lib/go/csi/v0"
"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/digitalocean/godo"
"github.com/golang/protobuf/ptypes"
"github.com/sirupsen/logrus"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
Expand Down Expand Up @@ -135,7 +136,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
ll.Info("volume already created")
return &csi.CreateVolumeResponse{
Volume: &csi.Volume{
Id: vol.ID,
VolumeId: vol.ID,
CapacityBytes: vol.SizeGigaBytes * GB,
},
}, nil
Expand All @@ -161,7 +162,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)

resp := &csi.CreateVolumeResponse{
Volume: &csi.Volume{
Id: vol.ID,
VolumeId: vol.ID,
CapacityBytes: size,
AccessibleTopology: []*csi.Topology{
{
Expand Down Expand Up @@ -267,7 +268,7 @@ func (d *Driver) ControllerPublishVolume(ctx context.Context, req *csi.Controlle
if id == dropletID {
ll.Info("volume is already attached")
return &csi.ControllerPublishVolumeResponse{
PublishInfo: map[string]string{
PublishContext: map[string]string{
PublishInfoVolumeName: vol.Name,
},
}, nil
Expand All @@ -291,7 +292,7 @@ func (d *Driver) ControllerPublishVolume(ctx context.Context, req *csi.Controlle
"resp": resp,
}).Warn("assuming volume is attached already")
return &csi.ControllerPublishVolumeResponse{
PublishInfo: map[string]string{
PublishContext: map[string]string{
PublishInfoVolumeName: vol.Name,
},
}, nil
Expand Down Expand Up @@ -319,7 +320,7 @@ func (d *Driver) ControllerPublishVolume(ctx context.Context, req *csi.Controlle

ll.Info("volume is attached")
return &csi.ControllerPublishVolumeResponse{
PublishInfo: map[string]string{
PublishContext: map[string]string{
PublishInfoVolumeName: vol.Name,
},
}, nil
Expand Down Expand Up @@ -414,7 +415,6 @@ func (d *Driver) ValidateVolumeCapabilities(ctx context.Context, req *csi.Valida
ll := d.log.WithFields(logrus.Fields{
"volume_id": req.VolumeId,
"volume_capabilities": req.VolumeCapabilities,
"accessible_topology": req.AccessibleTopology,
"supported_capabilities": supportedAccessMode,
"method": "validate_volume_capabilities",
})
Expand All @@ -429,29 +429,18 @@ func (d *Driver) ValidateVolumeCapabilities(ctx context.Context, req *csi.Valida
return nil, err
}

if req.AccessibleTopology != nil {
for _, t := range req.AccessibleTopology {
region, ok := t.Segments["region"]
if !ok {
continue // nothing to do
}

if region != d.region {
// return early if a different region is expected
ll.WithField("supported", false).Info("supported capabilities")
return &csi.ValidateVolumeCapabilitiesResponse{
Supported: false,
}, nil
}
}
}

// if it's not supported (i.e: wrong region), we shouldn't override it
resp := &csi.ValidateVolumeCapabilitiesResponse{
Supported: validateCapabilities(req.VolumeCapabilities),
Confirmed: &csi.ValidateVolumeCapabilitiesResponse_Confirmed{
VolumeCapabilities: []*csi.VolumeCapability{
{
AccessMode: supportedAccessMode,
},
},
},
}

ll.WithField("supported", resp.Supported).Info("supported capabilities")
ll.WithField("confirmed", resp.Confirmed).Info("supported capabilities")
return resp, nil
}

Expand Down Expand Up @@ -515,7 +504,7 @@ func (d *Driver) ListVolumes(ctx context.Context, req *csi.ListVolumesRequest) (
for _, vol := range volumes {
entries = append(entries, &csi.ListVolumesResponse_Entry{
Volume: &csi.Volume{
Id: vol.ID,
VolumeId: vol.ID,
CapacityBytes: vol.SizeGigaBytes * GB,
},
})
Expand Down Expand Up @@ -931,14 +920,18 @@ func toCSISnapshot(snap *godo.Snapshot) (*csi.Snapshot, error) {
return nil, fmt.Errorf("couldn't parse snapshot's created field: %s", err.Error())
}

tstamp, err := ptypes.TimestampProto(createdAt)
if err != nil {
return nil, fmt.Errorf("couldn't convert protobuf timestamp to go time.Time: %s",
err.Error())
}

return &csi.Snapshot{
Id: snap.ID,
SnapshotId: snap.ID,
SourceVolumeId: snap.ResourceID,
SizeBytes: int64(snap.SizeGigaBytes) * GB,
CreatedAt: createdAt.UTC().UnixNano(),
Status: &csi.SnapshotStatus{
Type: csi.SnapshotStatus_READY,
},
CreationTime: tstamp,
ReadyToUse: true,
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"strconv"
"sync"

csi "github.com/container-storage-interface/spec/lib/go/csi/v0"
"github.com/container-storage-interface/spec/lib/go/csi"
metadata "github.com/digitalocean/go-metadata"
"github.com/digitalocean/godo"
"github.com/sirupsen/logrus"
Expand Down
4 changes: 2 additions & 2 deletions driver/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package driver
import (
"context"

csi "github.com/container-storage-interface/spec/lib/go/csi/v0"
"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/golang/protobuf/ptypes/wrappers"
"github.com/sirupsen/logrus"
)
Expand Down Expand Up @@ -52,7 +52,7 @@ func (d *Driver) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCa
{
Type: &csi.PluginCapability_Service_{
Service: &csi.PluginCapability_Service{
Type: csi.PluginCapability_Service_ACCESSIBILITY_CONSTRAINTS,
Type: csi.PluginCapability_Service_VOLUME_ACCESSIBILITY_CONSTRAINTS,
},
},
},
Expand Down
Loading