From c8abf1cb6511be520f715e538818cec9455a5e0e Mon Sep 17 00:00:00 2001 From: sanjid133 Date: Tue, 16 Apr 2019 19:46:32 +0600 Subject: [PATCH 01/24] Resize volume --- go.mod | 3 +- go.sum | 4 +- pkg/linode-bs/controllerserver.go | 47 ++ .../kubernetes/05-csi-storageclass.yaml | 3 +- ...linode-blockstorage-csi-driver-v1.1.0.yaml | 522 ++++++++++++++++++ pkg/linode-bs/driver.go | 8 + .../examples/kubernetes/csi-pvc.yaml | 2 +- pkg/linode-bs/identityserver.go | 17 +- pkg/linode-bs/nodeserver.go | 8 + pkg/linode-client/linode-client.go | 2 + 10 files changed, 609 insertions(+), 7 deletions(-) create mode 100644 pkg/linode-bs/deploy/releases/linode-blockstorage-csi-driver-v1.1.0.yaml diff --git a/go.mod b/go.mod index 70799141..d2b286db 100644 --- a/go.mod +++ b/go.mod @@ -2,13 +2,14 @@ module github.com/linode/linode-blockstorage-csi-driver require ( github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 // indirect - github.com/container-storage-interface/spec v1.0.0 + github.com/container-storage-interface/spec v1.1.0 github.com/davecgh/go-spew v1.1.1 // indirect github.com/dnaeon/go-vcr v0.0.0-20180920040454-5637cf3d8a31 // indirect github.com/docker/distribution v2.6.2+incompatible // indirect github.com/gogo/protobuf v1.1.1 // indirect github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b github.com/golang/groupcache v0.0.0-20181024230925-c65c006176ff // indirect + github.com/golang/protobuf v1.2.0 github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c // indirect github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf // indirect github.com/googleapis/gnostic v0.2.0 // indirect diff --git a/go.sum b/go.sum index ad2d9c18..e3d54ed5 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/container-storage-interface/spec v1.0.0 h1:3DyXuJgf9MU6kyULESegQUmozsSxhpyrrv9u5bfwA3E= -github.com/container-storage-interface/spec v1.0.0/go.mod h1:6URME8mwIBbpVyZV93Ce5St17xBiQJQY67NDsuohiy4= +github.com/container-storage-interface/spec v1.1.0 h1:qPsTqtR1VUPvMPeK0UnCZMtXaKGyyLPG8gj/wG6VqMs= +github.com/container-storage-interface/spec v1.1.0/go.mod h1:6URME8mwIBbpVyZV93Ce5St17xBiQJQY67NDsuohiy4= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dnaeon/go-vcr v0.0.0-20180920040454-5637cf3d8a31 h1:Dzuw9GtbmllUqEcoHfScT9YpKFUssSiZ5PgZkIGf/YQ= diff --git a/pkg/linode-bs/controllerserver.go b/pkg/linode-bs/controllerserver.go index 54b7fdef..c425f505 100644 --- a/pkg/linode-bs/controllerserver.go +++ b/pkg/linode-bs/controllerserver.go @@ -419,6 +419,7 @@ func (linodeCS *LinodeControllerServer) ControllerGetCapabilities(ctx context.Co csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME, csi.ControllerServiceCapability_RPC_PUBLISH_UNPUBLISH_VOLUME, csi.ControllerServiceCapability_RPC_LIST_VOLUMES, + csi.ControllerServiceCapability_RPC_EXPAND_VOLUME, } { caps = append(caps, newCap(capability)) } @@ -450,6 +451,52 @@ func (linodeCS *LinodeControllerServer) ListSnapshots(ctx context.Context, req * return nil, status.Error(codes.Unimplemented, "") } +func (linodeCS *LinodeControllerServer) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) { + volumeID, statusErr := common.VolumeIdAsInt("ControllerUnpublishVolume", req) + if statusErr != nil { + return nil, statusErr + } + + capRange := req.GetCapacityRange() + size, err := getRequestCapacitySize(capRange) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + glog.V(4).Infoln("expand volume called", map[string]interface{}{ + "volume_id": volumeID, + "method": "controller_expand_volume", + }) + + var vol *linodego.Volume + + if vol, err = linodeCS.CloudProvider.GetVolume(ctx, volumeID); err != nil { + if apiErr, ok := err.(*linodego.Error); ok && apiErr.Code == 404 { + return &csi.ControllerExpandVolumeResponse{}, nil + } + return nil, status.Error(codes.Internal, err.Error()) + } else if vol.LinodeID != nil { + return nil, status.Error(codes.FailedPrecondition, "DeleteVolume Volume in use") + } + + if vol.Size > int(size/gigabyte) { + return nil, status.Error(codes.Internal, "Volumes can only be resized up") + } + + if err := linodeCS.CloudProvider.ResizeVolume(ctx, volumeID, int(size / gigabyte)); err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + resp := &csi.ControllerExpandVolumeResponse{ + CapacityBytes: size, + NodeExpansionRequired: false, + } + glog.V(4).Info("volume is resized") + return resp, nil + + +} + // getRequestCapacity evaluates the CapacityRange parameters to validate and resolve the best volume size func getRequestCapacitySize(capRange *csi.CapacityRange) (int64, error) { if capRange == nil { diff --git a/pkg/linode-bs/deploy/kubernetes/05-csi-storageclass.yaml b/pkg/linode-bs/deploy/kubernetes/05-csi-storageclass.yaml index 2c87f88d..121954fa 100644 --- a/pkg/linode-bs/deploy/kubernetes/05-csi-storageclass.yaml +++ b/pkg/linode-bs/deploy/kubernetes/05-csi-storageclass.yaml @@ -3,8 +3,6 @@ apiVersion: storage.k8s.io/v1 metadata: name: linode-block-storage namespace: kube-system - annotations: - storageclass.kubernetes.io/is-default-class: "true" provisioner: linodebs.csi.linode.com --- kind: StorageClass @@ -14,3 +12,4 @@ metadata: namespace: kube-system provisioner: linodebs.csi.linode.com reclaimPolicy: Retain +allowVolumeExpansion: true \ No newline at end of file diff --git a/pkg/linode-bs/deploy/releases/linode-blockstorage-csi-driver-v1.1.0.yaml b/pkg/linode-bs/deploy/releases/linode-blockstorage-csi-driver-v1.1.0.yaml new file mode 100644 index 00000000..e837fe11 --- /dev/null +++ b/pkg/linode-bs/deploy/releases/linode-blockstorage-csi-driver-v1.1.0.yaml @@ -0,0 +1,522 @@ +# pkg/linode-bs/deploy/kubernetes/01-csi-nodeinfo.yaml +# Requires CSINodeInfo feature gate (alpha in 1.12) +# xref: https://raw.githubusercontent.com/kubernetes/csi-api/master/pkg/crd/manifests/csidriver.yaml +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: csinodeinfos.csi.storage.k8s.io + labels: + addonmanager.kubernetes.io/mode: Reconcile +spec: + group: csi.storage.k8s.io + version: v1alpha1 + names: + kind: CSINodeInfo + plural: csinodeinfos + scope: Cluster + validation: + openAPIV3Schema: + properties: + spec: + description: Specification of CSINodeInfo + properties: + drivers: + description: List of CSI drivers running on the node and their specs. + type: array + items: + properties: + name: + description: The CSI driver that this object refers to. + type: string + nodeID: + description: The node from the driver point of view. + type: string + topologyKeys: + description: List of keys supported by the driver. + items: + type: string + type: array + status: + description: Status of CSINodeInfo + properties: + drivers: + description: List of CSI drivers running on the node and their statuses. + type: array + items: + properties: + name: + description: The CSI driver that this object refers to. + type: string + available: + description: Whether the CSI driver is installed. + type: boolean + volumePluginMechanism: + description: Indicates to external components the required mechanism + to use for any in-tree plugins replaced by this driver. + pattern: in-tree|csi + type: string + +--- +# pkg/linode-bs/deploy/kubernetes/02-csi-driver.yaml +# Requires CSIDriverRegistry feature gate (alpha in 1.12) +# xref: https://raw.githubusercontent.com/kubernetes/csi-api/master/pkg/crd/manifests/csinodeinfo.yaml +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: csidrivers.csi.storage.k8s.io + labels: + addonmanager.kubernetes.io/mode: Reconcile +spec: + version: v1alpha1 + 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 +--- +# pkg/linode-bs/deploy/kubernetes/03-accounts-roles-bindings.yaml +##### Node Service Account, Roles, RoleBindings +apiVersion: v1 +kind: ServiceAccount +metadata: + name: csi-node-sa + namespace: kube-system + +--- + +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: driver-registrar-role + namespace: kube-system +rules: +- apiGroups: [""] + resources: ["events"] + verbs: ["get", "list", "watch", "create", "update", "patch"] + + +--- + +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: driver-registrar-binding + namespace: kube-system +subjects: +- kind: ServiceAccount + name: csi-node-sa + namespace: kube-system +roleRef: + kind: ClusterRole + name: driver-registrar-role + apiGroup: rbac.authorization.k8s.io + +--- +##### Controller Service Account, Roles, Rolebindings +apiVersion: v1 +kind: ServiceAccount +metadata: + name: csi-controller-sa + namespace: kube-system + +--- +# xref: https://github.com/kubernetes-csi/external-provisioner/blob/master/deploy/kubernetes/rbac.yaml +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: external-provisioner-role + namespace: kube-system +rules: +- apiGroups: [""] + resources: ["secrets"] + verbs: ["get", "list"] +- apiGroups: [""] + resources: ["persistentvolumes"] + verbs: ["get", "list", "watch", "create", "delete"] +- apiGroups: [""] + resources: ["persistentvolumeclaims"] + verbs: ["get", "list", "watch", "update"] +- apiGroups: ["storage.k8s.io"] + resources: ["storageclasses"] + verbs: ["get", "list", "watch"] +- apiGroups: [""] + resources: ["events"] + verbs: ["list", "watch", "create", "update", "patch"] +- apiGroups: ["snapshot.storage.k8s.io"] + resources: ["volumesnapshots"] + verbs: ["get", "list"] +- apiGroups: ["snapshot.storage.k8s.io"] + resources: ["volumesnapshotcontents"] + verbs: ["get", "list"] + +--- + +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: csi-controller-provisioner-binding + namespace: kube-system +subjects: +- kind: ServiceAccount + name: csi-controller-sa + namespace: kube-system +roleRef: + kind: ClusterRole + name: external-provisioner-role + apiGroup: rbac.authorization.k8s.io + +--- +# xref: https://github.com/kubernetes-csi/external-attacher/blob/master/deploy/kubernetes/rbac.yaml +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: external-attacher-role + namespace: kube-system +rules: +- apiGroups: [""] + resources: ["persistentvolumes"] + verbs: ["get", "list", "watch", "update"] +- apiGroups: [""] + resources: ["nodes"] + verbs: ["get", "list", "watch"] +- apiGroups: ["csi.storage.k8s.io"] + resources: ["csinodeinfos"] + verbs: ["get", "list", "watch"] +- apiGroups: ["storage.k8s.io"] + resources: ["volumeattachments"] + verbs: ["get", "list", "watch", "update"] + +--- + +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: csi-controller-attacher-binding + namespace: kube-system +subjects: +- kind: ServiceAccount + name: csi-controller-sa + namespace: kube-system +roleRef: + kind: ClusterRole + name: external-attacher-role + apiGroup: rbac.authorization.k8s.io + +--- +# xref: https://github.com/kubernetes-csi/external-snapshotter/blob/master/deploy/kubernetes/rbac.yaml +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: external-snapshotter-role + namespace: kube-system +rules: +- apiGroups: ["snapshot.storage.k8s.io"] + resources: ["volumesnapshotclasses"] + verbs: ["get", "list", "watch"] +- apiGroups: ["snapshot.storage.k8s.io"] + resources: ["volumesnapshotcontents"] + verbs: ["create", "get", "list", "watch", "update", "delete"] +- apiGroups: ["snapshot.storage.k8s.io"] + resources: ["volumesnapshots"] + verbs: ["get", "list", "watch", "update"] +- apiGroups: ["apiextensions.k8s.io"] + resources: ["customresourcedefinitions"] + verbs: ["create", "list", "watch", "delete"] +- apiGroups: [""] + resources: ["events"] + verbs: ["list", "watch", "create", "update", "patch"] +- apiGroups: ["storage.k8s.io"] + resources: ["storageclasses"] + verbs: ["watch", "get", "list"] +- apiGroups: ["admissionregistration.k8s.io"] + resources: ["mutatingwebhookconfigurations"] + verbs: ["create"] + +--- + +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: csi-controller-snapshotter-binding + namespace: kube-system +subjects: +- kind: ServiceAccount + name: csi-controller-sa + namespace: kube-system +roleRef: + kind: ClusterRole + name: external-snapshotter-role + apiGroup: rbac.authorization.k8s.io + +--- +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: 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-controller-cluster-registrar-binding + namespace: kube-system +subjects: +- kind: ServiceAccount + name: csi-controller-sa + namespace: kube-system +roleRef: + kind: ClusterRole + name: cluster-driver-registrar-role + apiGroup: rbac.authorization.k8s.io + +--- +# pkg/linode-bs/deploy/kubernetes/05-csi-storageclass.yaml +kind: StorageClass +apiVersion: storage.k8s.io/v1 +metadata: + name: linode-block-storage + namespace: kube-system + annotations: + storageclass.kubernetes.io/is-default-class: "true" +provisioner: linodebs.csi.linode.com +--- +kind: StorageClass +apiVersion: storage.k8s.io/v1 +metadata: + name: linode-block-storage-retain + namespace: kube-system +provisioner: linodebs.csi.linode.com +reclaimPolicy: Retain + +--- +# pkg/linode-bs/deploy/kubernetes/06-ss-csi-linode-controller.yaml +kind: StatefulSet +apiVersion: apps/v1 +metadata: + name: csi-linode-controller + namespace: kube-system +spec: + serviceName: "csi-linode" + replicas: 1 + selector: + matchLabels: + app: csi-linode-controller + template: + metadata: + labels: + app: csi-linode-controller + role: csi-linode + spec: + serviceAccount: csi-controller-sa + containers: + - name: csi-provisioner + image: quay.io/k8scsi/csi-provisioner:v1.1.0 + args: + - "--volume-name-prefix=pvc" + - "--volume-name-uuid-length=16" + - "--csi-address=$(ADDRESS)" + - "--v=5" + env: + - name: ADDRESS + value: /var/lib/csi/sockets/pluginproxy/csi.sock + imagePullPolicy: "Always" + volumeMounts: + - name: socket-dir + mountPath: /var/lib/csi/sockets/pluginproxy/ + - name: csi-attacher + image: quay.io/k8scsi/csi-attacher:v1.0.1 + args: + - "--v=5" + - "--csi-address=$(ADDRESS)" + env: + - name: ADDRESS + value: /var/lib/csi/sockets/pluginproxy/csi.sock + imagePullPolicy: "Always" + 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: linode-csi-plugin + image: sanjid/linode-blockstorage-csi-driver:canary + args : + - "--endpoint=$(CSI_ENDPOINT)" + - "--token=$(LINODE_TOKEN)" + - "--url=$(LINODE_API_URL)" + - "--node=$(NODE_NAME)" + - "--bs-prefix=$(LINODE_BS_PREFIX)" + - "--v=10" + env: + - name: CSI_ENDPOINT + value: unix:///var/lib/csi/sockets/pluginproxy/csi.sock + - name: LINODE_API_URL + value: https://api.linode.com/v4 + - name: LINODE_BS_PREFIX + value: + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: LINODE_TOKEN + valueFrom: + secretKeyRef: + name: linode + key: token + imagePullPolicy: "Always" + volumeMounts: + - name: socket-dir + mountPath: /var/lib/csi/sockets/pluginproxy/ + volumes: + - name: socket-dir + emptyDir: {} + +--- +# pkg/linode-bs/deploy/kubernetes/07-ds-csi-linode-node.yaml +kind: DaemonSet +apiVersion: apps/v1 +metadata: + name: csi-linode-node + namespace: kube-system +spec: + selector: + matchLabels: + app: csi-linode-node + template: + metadata: + labels: + app: csi-linode-node + role: csi-linode + spec: + serviceAccount: csi-node-sa + hostNetwork: true + containers: + - name: driver-registrar + image: quay.io/k8scsi/csi-node-driver-registrar:v1.1.0 + args: + - "--v=5" + - "--csi-address=$(ADDRESS)" + - "--kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)" + lifecycle: + preStop: + exec: + command: ["/bin/sh", "-c", "rm -rf /registration/linodebs.csi.linode.com /registration/linodebs.csi.linode.com-reg.sock"] + env: + - name: ADDRESS + value: /csi/csi.sock + - name: DRIVER_REG_SOCK_PATH + value: /var/lib/kubelet/plugins/linodebs.csi.linode.com/csi.sock + - name: KUBE_NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + volumeMounts: + - name: plugin-dir + mountPath: /csi/ + - name: registration-dir + mountPath: /registration/ + - name: csi-linode-plugin + image: sanjid/linode-blockstorage-csi-driver:canary + args : + - "--endpoint=$(CSI_ENDPOINT)" + - "--token=$(LINODE_TOKEN)" + - "--url=$(LINODE_API_URL)" + - "--node=$(NODE_NAME)" + - "--v=10" + env: + - name: CSI_ENDPOINT + value: unix:///csi/csi.sock + - name: LINODE_API_URL + value: https://api.linode.com/v4 + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: LINODE_TOKEN + valueFrom: + secretKeyRef: + name: linode + key: token + imagePullPolicy: "Always" + securityContext: + privileged: true + capabilities: + add: ["SYS_ADMIN"] + allowPrivilegeEscalation: true + volumeMounts: + - name: plugin-dir + mountPath: /csi + - name: pods-mount-dir + mountPath: /var/lib/kubelet + # needed so that any mounts setup inside this container are + # propagated back to the host machine. + mountPropagation: "Bidirectional" + - mountPath: /dev + name: device-dir + volumes: + - name: registration-dir + hostPath: + path: /var/lib/kubelet/plugins_registry/ + type: DirectoryOrCreate + - name: kubelet-dir + hostPath: + path: /var/lib/kubelet + type: Directory + - name: plugin-dir + hostPath: + path: /var/lib/kubelet/plugins/linodebs.csi.linode.com + type: DirectoryOrCreate + - name: pods-mount-dir + hostPath: + path: /var/lib/kubelet + type: Directory + - name: device-dir + hostPath: + path: /dev + # The following mounts are required to trigger host udevadm from container + - name: udev-rules-etc + hostPath: + path: /etc/udev + type: Directory + - name: udev-rules-lib + hostPath: + path: /lib/udev + type: Directory + - name: udev-socket + hostPath: + path: /run/udev + type: Directory + - name: sys + hostPath: + path: /sys + type: Directory + +--- diff --git a/pkg/linode-bs/driver.go b/pkg/linode-bs/driver.go index 8c7dc611..be7f61e8 100644 --- a/pkg/linode-bs/driver.go +++ b/pkg/linode-bs/driver.go @@ -18,6 +18,7 @@ import ( "fmt" "regexp" "strconv" + "sync" "github.com/container-storage-interface/spec/lib/go/csi" linodeclient "github.com/linode/linode-blockstorage-csi-driver/pkg/linode-client" @@ -42,6 +43,9 @@ type LinodeDriver struct { vcap []*csi.VolumeCapability_AccessMode cscap []*csi.ControllerServiceCapability nscap []*csi.NodeServiceCapability + + readyMu sync.Mutex // protects ready + ready bool } const linodeBSPrefixLength = 12 @@ -82,12 +86,14 @@ func (linodeDriver *LinodeDriver) SetupLinodeDriver(linodeClient linodeclient.Li // csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT, // csi.ControllerServiceCapability_RPC_LIST_SNAPSHOTS, csi.ControllerServiceCapability_RPC_PUBLISH_READONLY, + csi.ControllerServiceCapability_RPC_EXPAND_VOLUME, } if err := linodeDriver.AddControllerServiceCapabilities(csc); err != nil { return err } ns := []csi.NodeServiceCapability_RPC_Type{ csi.NodeServiceCapability_RPC_STAGE_UNSTAGE_VOLUME, + csi.NodeServiceCapability_RPC_EXPAND_VOLUME, } if err := linodeDriver.AddNodeServiceCapabilities(ns); err != nil { return err @@ -175,6 +181,8 @@ func (linodeDriver *LinodeDriver) Run(endpoint string) { glog.V(4).Infof("BS Volume Prefix: %v", linodeDriver.bsPrefix) } + linodeDriver.ready = true + //Start the nonblocking GRPC s := NewNonBlockingGRPCServer() // TODO(#34): Only start specific servers based on a flag. diff --git a/pkg/linode-bs/examples/kubernetes/csi-pvc.yaml b/pkg/linode-bs/examples/kubernetes/csi-pvc.yaml index f66d64da..c8e1cf1a 100644 --- a/pkg/linode-bs/examples/kubernetes/csi-pvc.yaml +++ b/pkg/linode-bs/examples/kubernetes/csi-pvc.yaml @@ -8,4 +8,4 @@ spec: resources: requests: storage: 10Gi - storageClassName: linode-block-storage + storageClassName: linode-block-storage-expand diff --git a/pkg/linode-bs/identityserver.go b/pkg/linode-bs/identityserver.go index 0f13525f..af2d21e1 100644 --- a/pkg/linode-bs/identityserver.go +++ b/pkg/linode-bs/identityserver.go @@ -16,6 +16,7 @@ package linodebs import ( csi "github.com/container-storage-interface/spec/lib/go/csi" + "github.com/golang/protobuf/ptypes/wrappers" "github.com/golang/glog" "golang.org/x/net/context" "google.golang.org/grpc/codes" @@ -58,11 +59,25 @@ func (linodeIdentity *LinodeIdentityServer) GetPluginCapabilities(ctx context.Co }, }, }, + { + Type: &csi.PluginCapability_VolumeExpansion_{ + VolumeExpansion: &csi.PluginCapability_VolumeExpansion{ + Type: csi.PluginCapability_VolumeExpansion_ONLINE, + }, + }, + }, }, }, nil } func (linodeIdentity *LinodeIdentityServer) Probe(ctx context.Context, req *csi.ProbeRequest) (*csi.ProbeResponse, error) { glog.V(4).Infof("Probe called with args: %#v", req) - return &csi.ProbeResponse{}, nil + linodeIdentity.Driver.readyMu.Lock() + defer linodeIdentity.Driver.readyMu.Unlock() + + return &csi.ProbeResponse{ + Ready: &wrappers.BoolValue{ + Value: true, + }, + }, nil } diff --git a/pkg/linode-bs/nodeserver.go b/pkg/linode-bs/nodeserver.go index 3d0fb6a8..47a37778 100644 --- a/pkg/linode-bs/nodeserver.go +++ b/pkg/linode-bs/nodeserver.go @@ -268,6 +268,14 @@ func (ns *LinodeNodeServer) NodeUnstageVolume(ctx context.Context, req *csi.Node return &csi.NodeUnstageVolumeResponse{}, nil } +func (ns *LinodeNodeServer) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandVolumeRequest) (*csi.NodeExpandVolumeResponse, error) { + glog.V(4).Infof("NodeExpandVolume called with req: %#v", req) + + return &csi.NodeExpandVolumeResponse{ + CapacityBytes: req.CapacityRange.RequiredBytes, + }, nil +} + func (ns *LinodeNodeServer) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) { glog.V(4).Infof("NodeGetCapabilities called with req: %#v", req) diff --git a/pkg/linode-client/linode-client.go b/pkg/linode-client/linode-client.go index f4c9f1fb..bcc9fd44 100644 --- a/pkg/linode-client/linode-client.go +++ b/pkg/linode-client/linode-client.go @@ -24,6 +24,8 @@ type LinodeClient interface { WaitForVolumeLinodeID(context.Context, int, *int, int) (*linodego.Volume, error) WaitForVolumeStatus(context.Context, int, linodego.VolumeStatus, int) (*linodego.Volume, error) DeleteVolume(context.Context, int) error + + ResizeVolume(context.Context, int, int) error } func NewLinodeClient(token, uaPrefix string, url string) *linodego.Client { From 7a123c83b6fe351fb41582909bd4a3abcbfdbc73 Mon Sep 17 00:00:00 2001 From: sanjid133 Date: Tue, 30 Apr 2019 17:14:17 +0600 Subject: [PATCH 02/24] volume expand working with kube1.14 --- pkg/linode-bs/controllerserver.go | 13 +++++++--- .../kubernetes/05-csi-storageclass.yaml | 6 ++--- ...linode-blockstorage-csi-driver-v1.1.0.yaml | 24 ++++++++++++++----- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/pkg/linode-bs/controllerserver.go b/pkg/linode-bs/controllerserver.go index c425f505..77d4cbba 100644 --- a/pkg/linode-bs/controllerserver.go +++ b/pkg/linode-bs/controllerserver.go @@ -452,7 +452,7 @@ func (linodeCS *LinodeControllerServer) ListSnapshots(ctx context.Context, req * } func (linodeCS *LinodeControllerServer) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) { - volumeID, statusErr := common.VolumeIdAsInt("ControllerUnpublishVolume", req) + volumeID, statusErr := common.VolumeIdAsInt("ControllerExpandVolume", req) if statusErr != nil { return nil, statusErr } @@ -475,8 +475,6 @@ func (linodeCS *LinodeControllerServer) ControllerExpandVolume(ctx context.Conte return &csi.ControllerExpandVolumeResponse{}, nil } return nil, status.Error(codes.Internal, err.Error()) - } else if vol.LinodeID != nil { - return nil, status.Error(codes.FailedPrecondition, "DeleteVolume Volume in use") } if vol.Size > int(size/gigabyte) { @@ -487,6 +485,15 @@ func (linodeCS *LinodeControllerServer) ControllerExpandVolume(ctx context.Conte return nil, status.Error(codes.Internal, err.Error()) } + vol, err = linodeCS.CloudProvider.WaitForVolumeStatus(ctx, vol.ID, linodego.VolumeActive, waitTimeout) + + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + glog.V(4).Infoln("volume active", map[string]interface{}{"vol": vol}) + + resp := &csi.ControllerExpandVolumeResponse{ CapacityBytes: size, NodeExpansionRequired: false, diff --git a/pkg/linode-bs/deploy/kubernetes/05-csi-storageclass.yaml b/pkg/linode-bs/deploy/kubernetes/05-csi-storageclass.yaml index 121954fa..17c66ac4 100644 --- a/pkg/linode-bs/deploy/kubernetes/05-csi-storageclass.yaml +++ b/pkg/linode-bs/deploy/kubernetes/05-csi-storageclass.yaml @@ -8,8 +8,8 @@ provisioner: linodebs.csi.linode.com kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: - name: linode-block-storage-retain + name: linode-block-storage-expand namespace: kube-system provisioner: linodebs.csi.linode.com -reclaimPolicy: Retain -allowVolumeExpansion: true \ No newline at end of file +reclaimPolicy: Delete +allowVolumeExpansion: true diff --git a/pkg/linode-bs/deploy/releases/linode-blockstorage-csi-driver-v1.1.0.yaml b/pkg/linode-bs/deploy/releases/linode-blockstorage-csi-driver-v1.1.0.yaml index e837fe11..a541d9eb 100644 --- a/pkg/linode-bs/deploy/releases/linode-blockstorage-csi-driver-v1.1.0.yaml +++ b/pkg/linode-bs/deploy/releases/linode-blockstorage-csi-driver-v1.1.0.yaml @@ -149,8 +149,8 @@ rules: resources: ["persistentvolumes"] verbs: ["get", "list", "watch", "create", "delete"] - apiGroups: [""] - resources: ["persistentvolumeclaims"] - verbs: ["get", "list", "watch", "update"] + resources: ["persistentvolumeclaims", "persistentvolumeclaims/status"] + verbs: ["get", "list", "watch", "update", "patch"] - apiGroups: ["storage.k8s.io"] resources: ["storageclasses"] verbs: ["get", "list", "watch"] @@ -199,7 +199,7 @@ rules: verbs: ["get", "list", "watch"] - apiGroups: ["storage.k8s.io"] resources: ["volumeattachments"] - verbs: ["get", "list", "watch", "update"] + verbs: ["create", "get", "list", "watch", "update"] --- @@ -270,7 +270,7 @@ metadata: name: cluster-driver-registrar-role rules: - apiGroups: ["csi.storage.k8s.io"] - resources: ["csidrivers"] + resources: ["csidrivers", "volumeattachments"] verbs: ["create", "delete"] --- @@ -302,10 +302,11 @@ provisioner: linodebs.csi.linode.com kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: - name: linode-block-storage-retain + name: linode-block-storage-expand namespace: kube-system provisioner: linodebs.csi.linode.com -reclaimPolicy: Retain +reclaimPolicy: Delete +allowVolumeExpansion: true --- # pkg/linode-bs/deploy/kubernetes/06-ss-csi-linode-controller.yaml @@ -366,6 +367,17 @@ spec: volumeMounts: - name: socket-dir mountPath: /var/lib/csi/sockets/pluginproxy/ + - name: linode-csi-resizer + image: quay.io/k8scsi/csi-resizer:v0.1.0 + args: + - "--v=5" + - "--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: linode-csi-plugin image: sanjid/linode-blockstorage-csi-driver:canary args : From f5dac6765cb162adef5cdf4a5b2b19ae73072024 Mon Sep 17 00:00:00 2001 From: Fahim Abrar Date: Thu, 2 May 2019 17:49:06 +0600 Subject: [PATCH 03/24] Add Test for Expanding a Linode Block Storage Volume --- e2e/test/csi_driver_test.go | 88 +-- e2e/test/e2e_suite_test.go | 31 +- e2e/test/framework/framework.go | 9 +- e2e/test/framework/pod.go | 11 +- e2e/test/framework/pvc.go | 35 +- e2e/test/framework/util.go | 13 +- e2e/test/go.mod | 8 +- e2e/test/go.sum | 15 + .../linode-blockstorage-csi-driver.yaml | 534 ++++++++++++++++++ ...linode-blockstorage-csi-driver-v1.1.0.yaml | 4 +- 10 files changed, 686 insertions(+), 62 deletions(-) create mode 100644 e2e/test/manifest/linode-blockstorage-csi-driver.yaml diff --git a/e2e/test/csi_driver_test.go b/e2e/test/csi_driver_test.go index 419ff129..4b5b8b5b 100644 --- a/e2e/test/csi_driver_test.go +++ b/e2e/test/csi_driver_test.go @@ -2,24 +2,23 @@ package test import ( "e2e_test/framework" + "strconv" "time" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" core "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/resource" ) var _ = Describe("CSIDriver", func() { var ( - err error - pod *core.Pod - podName1 = "test-pod-1" - podName2 = "test-pod-2" - pvc *core.PersistentVolumeClaim - f *framework.Invocation - size string - file = "/data/heredoc" - waitTime = 1 * time.Minute + err error + pod *core.Pod + pvc *core.PersistentVolumeClaim + f *framework.Invocation + size string + file = "/data/heredoc" ) BeforeEach(func() { f = root.Invoke() @@ -37,22 +36,22 @@ var _ = Describe("CSIDriver", func() { Expect(err).NotTo(HaveOccurred()) } - var waitForOperation = func() { - time.Sleep(waitTime) - } - - var deleteAndCreatePod = func(name string) { - By("Deleting the First pod") - err = f.DeletePod(pod.Name) + var expandVolume = func(size string) { + By("Expanding Size of the Persistent Volume") + currentPVC, err := f.GetPersistentVolumeClaim(pvc.ObjectMeta) Expect(err).NotTo(HaveOccurred()) - By("Waiting for the Volume to be Detached") - waitForOperation() - - By("Creating Second Pod with the Same PVC") - pod = f.GetPodObject(name, pvc.Name) - err = f.CreatePod(pod) + currentPVC.Spec.Resources.Requests = core.ResourceList{ + core.ResourceName(core.ResourceStorage): resource.MustParse(size), + } + err = f.UpdatePersistentVolumeClaim(currentPVC) Expect(err).NotTo(HaveOccurred()) + + By("Checking if Volume Expansion Occurred") + Eventually(func() string { + s, _ := f.GetVolumeSize(currentPVC) + return strconv.Itoa(s) + "Gi" + }).Should(Equal(size)) } Describe("Test", func() { @@ -60,30 +59,30 @@ var _ = Describe("CSIDriver", func() { Context("Block Storage", func() { JustBeforeEach(func() { By("Creating Persistent Volume Claim") - pvc = f.GetPersistentVolumeClaim(size) + pvc = f.GetPersistentVolumeClaimObject(size, f.StorageClass) err = f.CreatePersistentVolumeClaim(pvc) Expect(err).NotTo(HaveOccurred()) By("Creating Pod with PVC") - pod = f.GetPodObject(podName1, pvc.Name) + pod = f.GetPodObject(pvc.Name) err = f.CreatePod(pod) Expect(err).NotTo(HaveOccurred()) }) AfterEach(func() { By("Deleting the Pod with PVC") - err = f.DeletePod(pod.Name) + err = f.DeletePod(pod.ObjectMeta) Expect(err).NotTo(HaveOccurred()) By("Waiting for the Volume to be Detached") - waitForOperation() + time.Sleep(2 * time.Minute) By("Deleting the PVC") err = f.DeletePersistentVolumeClaim(pvc.ObjectMeta) Expect(err).NotTo(HaveOccurred()) By("Waiting for the Volume to be Deleted") - waitForOperation() + time.Sleep(1 * time.Minute) }) Context("1Gi Storage", func() { @@ -117,71 +116,76 @@ var _ = Describe("CSIDriver", func() { }) }) }) + }) - Context("Pre-Provisioned", func() { - Context("Linode Block Storage", func() { + Describe("Test", func() { + Context("Block Storage", func() { + Context("Volume Expansion", func() { JustBeforeEach(func() { + By("Applying Manifest") + err = framework.ApplyManifest("apply", "manifest/linode-blockstorage-csi-driver.yaml") + Expect(err).NotTo(HaveOccurred()) + By("Creating Persistent Volume Claim") - pvc = f.GetPersistentVolumeClaim(size) + pvc = f.GetPersistentVolumeClaimObject(size, "linode-block-storage-expand") err = f.CreatePersistentVolumeClaim(pvc) Expect(err).NotTo(HaveOccurred()) By("Creating Pod with PVC") - pod = f.GetPodObject(podName1, pvc.Name) + pod = f.GetPodObject(pvc.Name) err = f.CreatePod(pod) Expect(err).NotTo(HaveOccurred()) }) AfterEach(func() { By("Deleting the Pod with PVC") - err = f.DeletePod(pod.Name) + err = f.DeletePod(pod.ObjectMeta) Expect(err).NotTo(HaveOccurred()) By("Waiting for the Volume to be Detached") - waitForOperation() + time.Sleep(2 * time.Minute) By("Deleting the PVC") err = f.DeletePersistentVolumeClaim(pvc.ObjectMeta) Expect(err).NotTo(HaveOccurred()) By("Waiting for the Volume to be Deleted") - waitForOperation() + time.Sleep(1 * time.Minute) }) - Context("10Gi Storage", func() { + Context("Expanding Storage from 10Gi to 15Gi", func() { BeforeEach(func() { size = "10Gi" }) It("should write and read", func() { writeFile(file) - deleteAndCreatePod(podName2) + expandVolume("15Gi") readFile(file) }) }) - Context("15Gi Storage", func() { + Context("Expanding Storage from 10Gi to 20Gi", func() { BeforeEach(func() { - size = "15Gi" + size = "10Gi" }) It("should write and read", func() { writeFile(file) - deleteAndCreatePod(podName2) + expandVolume("20Gi") readFile(file) }) }) - Context("20Gi Storage", func() { + Context("Expanding Storage from 20Gi to 25Gi", func() { BeforeEach(func() { size = "20Gi" }) It("should write and read", func() { writeFile(file) - deleteAndCreatePod(podName2) + expandVolume("25Gi") readFile(file) }) }) }) }) }) - }) diff --git a/e2e/test/e2e_suite_test.go b/e2e/test/e2e_suite_test.go index d29a7980..e6010767 100644 --- a/e2e/test/e2e_suite_test.go +++ b/e2e/test/e2e_suite_test.go @@ -2,19 +2,24 @@ package test import ( "flag" - "github.com/appscode/go/crypto/rand" - "k8s.io/client-go/util/homedir" + "net/http" "testing" "time" + "github.com/appscode/go/crypto/rand" + "github.com/linode/linodego" + "golang.org/x/oauth2" + "k8s.io/client-go/util/homedir" + "e2e_test/framework" + "os" + "path/filepath" + . "github.com/onsi/ginkgo" "github.com/onsi/ginkgo/reporters" . "github.com/onsi/gomega" "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/clientcmd" - "os" - "path/filepath" ) var ( @@ -48,6 +53,21 @@ func TestE2e(t *testing.T) { RunSpecsWithDefaultAndCustomReporters(t, "e2e Suite", []Reporter{junitReporter}) } +var getLinodeClient = func() linodego.Client { + tokenSource := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: framework.ApiToken}) + + oauth2Client := &http.Client{ + Transport: &oauth2.Transport{ + Source: tokenSource, + }, + } + + linodeClient := linodego.NewClient(oauth2Client) + linodeClient.SetDebug(true) + + return linodeClient +} + var _ = BeforeSuite(func() { if !useExisting { @@ -64,9 +84,10 @@ var _ = BeforeSuite(func() { // Clients kubeClient := kubernetes.NewForConfigOrDie(config) + linodeClient := getLinodeClient() // Framework - root = framework.New(config, kubeClient, StorageClass) + root = framework.New(config, kubeClient, linodeClient, StorageClass) By("Using Namespace " + root.Namespace()) err = root.CreateNamespace() diff --git a/e2e/test/framework/framework.go b/e2e/test/framework/framework.go index a3b360c3..496f6d0d 100644 --- a/e2e/test/framework/framework.go +++ b/e2e/test/framework/framework.go @@ -2,6 +2,7 @@ package framework import ( "github.com/appscode/go/crypto/rand" + "github.com/linode/linodego" "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" ) @@ -18,16 +19,20 @@ type Framework struct { namespace string name string StorageClass string + + linodeClient linodego.Client } func New( restConfig *rest.Config, kubeClient kubernetes.Interface, + linodeClient linodego.Client, storageClass string, ) *Framework { return &Framework{ - restConfig: restConfig, - kubeClient: kubeClient, + restConfig: restConfig, + kubeClient: kubeClient, + linodeClient: linodeClient, name: "csidriver", namespace: rand.WithUniqSuffix("csi"), diff --git a/e2e/test/framework/pod.go b/e2e/test/framework/pod.go index 93c9cf76..e3435cc3 100644 --- a/e2e/test/framework/pod.go +++ b/e2e/test/framework/pod.go @@ -2,7 +2,6 @@ package framework import ( "fmt" - "github.com/appscode/go/wait" "github.com/pkg/errors" core "k8s.io/api/core/v1" @@ -10,16 +9,16 @@ import ( "kmodules.xyz/client-go/tools/exec" ) -func (f *Invocation) GetPodObject(name string, pvc string) *core.Pod { +func (f *Invocation) GetPodObject(pvc string) *core.Pod { return &core.Pod{ ObjectMeta: metav1.ObjectMeta{ - Name: name, + Name: f.app, Namespace: f.namespace, }, Spec: core.PodSpec{ Containers: []core.Container{ { - Name: name, + Name: f.app, Image: "busybox", VolumeMounts: []core.VolumeMount{ { @@ -53,8 +52,8 @@ func (f *Invocation) CreatePod(pod *core.Pod) error { } -func (f *Invocation) DeletePod(name string) error { - return f.kubeClient.CoreV1().Pods(f.namespace).Delete(name, deleteInForeground()) +func (f *Invocation) DeletePod(meta metav1.ObjectMeta) error { + return f.kubeClient.CoreV1().Pods(f.namespace).Delete(meta.Name, deleteInForeground()) } func (f *Invocation) GetPod(name, ns string) (*core.Pod, error) { diff --git a/e2e/test/framework/pvc.go b/e2e/test/framework/pvc.go index 7a6da4fb..7964db40 100644 --- a/e2e/test/framework/pvc.go +++ b/e2e/test/framework/pvc.go @@ -1,12 +1,16 @@ package framework import ( + "context" + "strconv" + "strings" + core "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -func (f *Invocation) GetPersistentVolumeClaim(size string) *core.PersistentVolumeClaim { +func (f *Invocation) GetPersistentVolumeClaimObject(size, storageClass string) *core.PersistentVolumeClaim { return &core.PersistentVolumeClaim{ ObjectMeta: metav1.ObjectMeta{ Name: f.app, @@ -16,7 +20,7 @@ func (f *Invocation) GetPersistentVolumeClaim(size string) *core.PersistentVolum AccessModes: []core.PersistentVolumeAccessMode{ core.ReadWriteOnce, }, - StorageClassName: &f.StorageClass, + StorageClassName: &storageClass, Resources: core.ResourceRequirements{ Requests: core.ResourceList{ core.ResourceName(core.ResourceStorage): resource.MustParse(size), @@ -26,6 +30,15 @@ func (f *Invocation) GetPersistentVolumeClaim(size string) *core.PersistentVolum } } +func (f *Invocation) GetPersistentVolumeClaim(meta metav1.ObjectMeta) (*core.PersistentVolumeClaim, error) { + return f.kubeClient.CoreV1().PersistentVolumeClaims(meta.Namespace).Get(meta.Name, metav1.GetOptions{}) +} + +func (f *Invocation) UpdatePersistentVolumeClaim(pvc *core.PersistentVolumeClaim) error { + _, err := f.kubeClient.CoreV1().PersistentVolumeClaims(pvc.Namespace).Update(pvc) + return err +} + func (f *Invocation) CreatePersistentVolumeClaim(pvc *core.PersistentVolumeClaim) error { _, err := f.kubeClient.CoreV1().PersistentVolumeClaims(pvc.Namespace).Create(pvc) return err @@ -34,3 +47,21 @@ func (f *Invocation) CreatePersistentVolumeClaim(pvc *core.PersistentVolumeClaim func (f *Invocation) DeletePersistentVolumeClaim(meta metav1.ObjectMeta) error { return f.kubeClient.CoreV1().PersistentVolumeClaims(meta.Namespace).Delete(meta.Name, nil) } + +func (f *Invocation) GetVolumeSize(pvc *core.PersistentVolumeClaim) (int, error) { + pv, err := f.kubeClient.CoreV1().PersistentVolumes().Get(pvc.Spec.VolumeName, metav1.GetOptions{}) + if err != nil { + return -1, err + } + + volumeHandle := pv.Spec.CSI.VolumeHandle + volumeID, err := strconv.Atoi(strings.Split(volumeHandle, "-")[0]) + if err != nil { + return -1, err + } + volume, err := f.linodeClient.GetVolume(context.Background(), volumeID) + if err != nil { + return -1, err + } + return volume.Size, err +} diff --git a/e2e/test/framework/util.go b/e2e/test/framework/util.go index 803a145e..8b891c2b 100644 --- a/e2e/test/framework/util.go +++ b/e2e/test/framework/util.go @@ -1,12 +1,16 @@ package framework import ( - "github.com/golang/glog" + "log" "os" "os/exec" "path" "time" + "github.com/codeskyblue/go-sh" + + "github.com/golang/glog" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -38,3 +42,10 @@ func deleteInForeground() *metav1.DeleteOptions { policy := metav1.DeletePropagationForeground return &metav1.DeleteOptions{PropagationPolicy: &policy} } + +func ApplyManifest(commandName, manifest string) error { + args := []string{commandName, "--kubeconfig", KubeConfigFile, "-f", manifest} + out, err := sh.Command("kubectl", args).Output() + log.Println(string(out)) + return err +} diff --git a/e2e/test/go.mod b/e2e/test/go.mod index d2eeb5ab..f42e49ac 100644 --- a/e2e/test/go.mod +++ b/e2e/test/go.mod @@ -4,6 +4,9 @@ go 1.12 require ( github.com/appscode/go v0.0.0-20190112082056-52eaa8008e2e + github.com/codeskyblue/go-sh v0.0.0-20171228145154-cf804ac79dff + github.com/davecgh/go-spew v1.1.1 + github.com/dnaeon/go-vcr v1.0.1 // indirect github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c // indirect github.com/elazarl/goproxy v0.0.0-20190410145444-c548f45dcf1d // indirect github.com/elazarl/goproxy/ext v0.0.0-20190410145444-c548f45dcf1d // indirect @@ -15,14 +18,15 @@ require ( github.com/googleapis/gnostic v0.2.0 // indirect github.com/gregjones/httpcache v0.0.0-20190212212710-3befbb6ad0cc // indirect github.com/imdario/mergo v0.3.7 // indirect + github.com/linode/linodego v0.7.1 github.com/onsi/ginkgo v1.8.0 github.com/onsi/gomega v1.5.0 github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/pkg/errors v0.8.0 - golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e // indirect - golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 // indirect + golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect gopkg.in/inf.v0 v0.9.1 // indirect + gopkg.in/resty.v1 v1.12.0 // indirect k8s.io/api v0.0.0-20180904230853-4e7be11eab3f k8s.io/apimachinery v0.0.0-20180621070125-103fd098999d k8s.io/client-go v8.0.0+incompatible diff --git a/e2e/test/go.sum b/e2e/test/go.sum index d13e119a..005a07b5 100644 --- a/e2e/test/go.sum +++ b/e2e/test/go.sum @@ -1,12 +1,17 @@ +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/appscode/go v0.0.0-20190112082056-52eaa8008e2e h1:QwszriolcyRBOTovn+OLx/f1yclQtatwoVqvAvPGQlI= github.com/appscode/go v0.0.0-20190112082056-52eaa8008e2e/go.mod h1:a9V9cFfL4x+IolJkNLeM4ZaNPTY8GXCyQB6Ool2I4AI= github.com/appscode/go-notify v0.0.0-20180516083708-17078f08a5ba/go.mod h1:ta+dFCq77Bh3GwYmYtKuzO0HhDxsalgPelI4nDOk5lA= github.com/beevik/ntp v0.2.0/go.mod h1:hIHWr+l3+/clUnF44zdK+CWW7fO8dR5cIylAQ76NRpg= github.com/cenkalti/backoff v2.0.0+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= +github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0 h1:sDMmm+q/3+BukdIpxwO365v/Rbspp2Nt5XntgQRXq8Q= github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM= +github.com/codeskyblue/go-sh v0.0.0-20171228145154-cf804ac79dff h1:6dIlQE/9GSZhFYpqKUKnx9IJKQ7ANrzvwR7xdJhOsnk= github.com/codeskyblue/go-sh v0.0.0-20171228145154-cf804ac79dff/go.mod h1:2hUMLQDY+46DXIf/i7n2rUCHUwF3gZrb4slZV8C4RYI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dnaeon/go-vcr v1.0.1 h1:r8L/HqC0Hje5AXMu1ooW8oyQyOFv4GxqpL0nRP7SLLY= +github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c h1:ZfSZ3P3BedhKGUhzj7BQlPSU4OvT6tfOKe3DVHzOA7s= github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= github.com/elazarl/goproxy v0.0.0-20190410145444-c548f45dcf1d h1:FEw1BeUVT/wxetVmacXPqQgRyYCG+0aCfQel+53Pa/E= @@ -50,6 +55,8 @@ github.com/juju/loggo v0.0.0-20180524022052-584905176618/go.mod h1:vgyd7OREkbtVE github.com/juju/testing v0.0.0-20180920084828-472a3e8b2073/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/linode/linodego v0.7.1 h1:4WZmMpSA2NRwlPZcc0+4Gyn7rr99Evk9bnr0B3gXRKE= +github.com/linode/linodego v0.7.1/go.mod h1:ga11n3ivecUrPCHN0rANxKmfWBJVkOXfLMZinAbj2sY= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= @@ -78,10 +85,14 @@ github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1 github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= golang.org/x/crypto v0.0.0-20180830192347-182538f80094 h1:rVTAlhYa4+lCfNxmAIEOGQRoD23UqP72M3+rSWVGDTg= golang.org/x/crypto v0.0.0-20180830192347-182538f80094/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a h1:tImsplftrFpALCYumobsd0K86vlAs/eXGFms2txfJfA= +golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw= @@ -94,6 +105,8 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= @@ -101,6 +114,8 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= +gopkg.in/resty.v1 v1.12.0 h1:CuXP0Pjfw9rOuY6EP+UvtNvt5DSqHpIxILZKT/quCZI= +gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= diff --git a/e2e/test/manifest/linode-blockstorage-csi-driver.yaml b/e2e/test/manifest/linode-blockstorage-csi-driver.yaml new file mode 100644 index 00000000..e0ac33aa --- /dev/null +++ b/e2e/test/manifest/linode-blockstorage-csi-driver.yaml @@ -0,0 +1,534 @@ +# pkg/linode-bs/deploy/kubernetes/01-csi-nodeinfo.yaml +# Requires CSINodeInfo feature gate (alpha in 1.12) +# xref: https://raw.githubusercontent.com/kubernetes/csi-api/master/pkg/crd/manifests/csidriver.yaml +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: csinodeinfos.csi.storage.k8s.io + labels: + addonmanager.kubernetes.io/mode: Reconcile +spec: + group: csi.storage.k8s.io + version: v1alpha1 + names: + kind: CSINodeInfo + plural: csinodeinfos + scope: Cluster + validation: + openAPIV3Schema: + properties: + spec: + description: Specification of CSINodeInfo + properties: + drivers: + description: List of CSI drivers running on the node and their specs. + type: array + items: + properties: + name: + description: The CSI driver that this object refers to. + type: string + nodeID: + description: The node from the driver point of view. + type: string + topologyKeys: + description: List of keys supported by the driver. + items: + type: string + type: array + status: + description: Status of CSINodeInfo + properties: + drivers: + description: List of CSI drivers running on the node and their statuses. + type: array + items: + properties: + name: + description: The CSI driver that this object refers to. + type: string + available: + description: Whether the CSI driver is installed. + type: boolean + volumePluginMechanism: + description: Indicates to external components the required mechanism + to use for any in-tree plugins replaced by this driver. + pattern: in-tree|csi + type: string + +--- +# pkg/linode-bs/deploy/kubernetes/02-csi-driver.yaml +# Requires CSIDriverRegistry feature gate (alpha in 1.12) +# xref: https://raw.githubusercontent.com/kubernetes/csi-api/master/pkg/crd/manifests/csinodeinfo.yaml +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: csidrivers.csi.storage.k8s.io + labels: + addonmanager.kubernetes.io/mode: Reconcile +spec: + version: v1alpha1 + 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 +--- +# pkg/linode-bs/deploy/kubernetes/03-accounts-roles-bindings.yaml +##### Node Service Account, Roles, RoleBindings +apiVersion: v1 +kind: ServiceAccount +metadata: + name: csi-node-sa + namespace: kube-system + +--- + +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: driver-registrar-role + namespace: kube-system +rules: +- apiGroups: [""] + resources: ["events"] + verbs: ["get", "list", "watch", "create", "update", "patch"] + + +--- + +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: driver-registrar-binding + namespace: kube-system +subjects: +- kind: ServiceAccount + name: csi-node-sa + namespace: kube-system +roleRef: + kind: ClusterRole + name: driver-registrar-role + apiGroup: rbac.authorization.k8s.io + +--- +##### Controller Service Account, Roles, Rolebindings +apiVersion: v1 +kind: ServiceAccount +metadata: + name: csi-controller-sa + namespace: kube-system + +--- +# xref: https://github.com/kubernetes-csi/external-provisioner/blob/master/deploy/kubernetes/rbac.yaml +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: external-provisioner-role + namespace: kube-system +rules: +- apiGroups: [""] + resources: ["secrets"] + verbs: ["get", "list"] +- apiGroups: [""] + resources: ["persistentvolumes"] + verbs: ["get", "list", "watch", "create", "delete"] +- apiGroups: [""] + resources: ["persistentvolumeclaims", "persistentvolumeclaims/status"] + verbs: ["get", "list", "watch", "update", "patch"] +- apiGroups: ["storage.k8s.io"] + resources: ["storageclasses"] + verbs: ["get", "list", "watch"] +- apiGroups: [""] + resources: ["events"] + verbs: ["list", "watch", "create", "update", "patch"] +- apiGroups: ["snapshot.storage.k8s.io"] + resources: ["volumesnapshots"] + verbs: ["get", "list"] +- apiGroups: ["snapshot.storage.k8s.io"] + resources: ["volumesnapshotcontents"] + verbs: ["get", "list"] + +--- + +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: csi-controller-provisioner-binding + namespace: kube-system +subjects: +- kind: ServiceAccount + name: csi-controller-sa + namespace: kube-system +roleRef: + kind: ClusterRole + name: external-provisioner-role + apiGroup: rbac.authorization.k8s.io + +--- +# xref: https://github.com/kubernetes-csi/external-attacher/blob/master/deploy/kubernetes/rbac.yaml +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: external-attacher-role + namespace: kube-system +rules: +- apiGroups: [""] + resources: ["persistentvolumes"] + verbs: ["get", "list", "watch", "update"] +- apiGroups: [""] + resources: ["nodes"] + verbs: ["get", "list", "watch"] +- apiGroups: ["csi.storage.k8s.io"] + resources: ["csinodeinfos"] + verbs: ["get", "list", "watch"] +- apiGroups: ["storage.k8s.io"] + resources: ["volumeattachments"] + verbs: ["create", "get", "list", "watch", "update"] + +--- + +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: csi-controller-attacher-binding + namespace: kube-system +subjects: +- kind: ServiceAccount + name: csi-controller-sa + namespace: kube-system +roleRef: + kind: ClusterRole + name: external-attacher-role + apiGroup: rbac.authorization.k8s.io + +--- +# xref: https://github.com/kubernetes-csi/external-snapshotter/blob/master/deploy/kubernetes/rbac.yaml +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: external-snapshotter-role + namespace: kube-system +rules: +- apiGroups: ["snapshot.storage.k8s.io"] + resources: ["volumesnapshotclasses"] + verbs: ["get", "list", "watch"] +- apiGroups: ["snapshot.storage.k8s.io"] + resources: ["volumesnapshotcontents"] + verbs: ["create", "get", "list", "watch", "update", "delete"] +- apiGroups: ["snapshot.storage.k8s.io"] + resources: ["volumesnapshots"] + verbs: ["get", "list", "watch", "update"] +- apiGroups: ["apiextensions.k8s.io"] + resources: ["customresourcedefinitions"] + verbs: ["create", "list", "watch", "delete"] +- apiGroups: [""] + resources: ["events"] + verbs: ["list", "watch", "create", "update", "patch"] +- apiGroups: ["storage.k8s.io"] + resources: ["storageclasses"] + verbs: ["watch", "get", "list"] +- apiGroups: ["admissionregistration.k8s.io"] + resources: ["mutatingwebhookconfigurations"] + verbs: ["create"] + +--- + +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: csi-controller-snapshotter-binding + namespace: kube-system +subjects: +- kind: ServiceAccount + name: csi-controller-sa + namespace: kube-system +roleRef: + kind: ClusterRole + name: external-snapshotter-role + apiGroup: rbac.authorization.k8s.io + +--- +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: cluster-driver-registrar-role +rules: +- apiGroups: ["csi.storage.k8s.io"] + resources: ["csidrivers", "volumeattachments"] + verbs: ["create", "delete"] +--- + +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: csi-controller-cluster-registrar-binding + namespace: kube-system +subjects: +- kind: ServiceAccount + name: csi-controller-sa + namespace: kube-system +roleRef: + kind: ClusterRole + name: cluster-driver-registrar-role + apiGroup: rbac.authorization.k8s.io + +--- +# pkg/linode-bs/deploy/kubernetes/05-csi-storageclass.yaml +kind: StorageClass +apiVersion: storage.k8s.io/v1 +metadata: + name: linode-block-storage + namespace: kube-system + annotations: + storageclass.kubernetes.io/is-default-class: "true" +provisioner: linodebs.csi.linode.com +--- +kind: StorageClass +apiVersion: storage.k8s.io/v1 +metadata: + name: linode-block-storage-expand + namespace: kube-system +provisioner: linodebs.csi.linode.com +reclaimPolicy: Delete +allowVolumeExpansion: true + +--- +# pkg/linode-bs/deploy/kubernetes/06-ss-csi-linode-controller.yaml +kind: StatefulSet +apiVersion: apps/v1 +metadata: + name: csi-linode-controller + namespace: kube-system +spec: + serviceName: "csi-linode" + replicas: 1 + selector: + matchLabels: + app: csi-linode-controller + template: + metadata: + labels: + app: csi-linode-controller + role: csi-linode + spec: + serviceAccount: csi-controller-sa + containers: + - name: csi-provisioner + image: quay.io/k8scsi/csi-provisioner:v1.1.0 + args: + - "--volume-name-prefix=pvc" + - "--volume-name-uuid-length=16" + - "--csi-address=$(ADDRESS)" + - "--v=5" + env: + - name: ADDRESS + value: /var/lib/csi/sockets/pluginproxy/csi.sock + imagePullPolicy: "Always" + volumeMounts: + - name: socket-dir + mountPath: /var/lib/csi/sockets/pluginproxy/ + - name: csi-attacher + image: quay.io/k8scsi/csi-attacher:v1.0.1 + args: + - "--v=5" + - "--csi-address=$(ADDRESS)" + env: + - name: ADDRESS + value: /var/lib/csi/sockets/pluginproxy/csi.sock + imagePullPolicy: "Always" + 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: linode-csi-resizer + image: quay.io/k8scsi/csi-resizer:v0.1.0 + args: + - "--v=5" + - "--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: linode-csi-plugin + image: linode/linode-blockstorage-csi-driver:canary + args : + - "--endpoint=$(CSI_ENDPOINT)" + - "--token=$(LINODE_TOKEN)" + - "--url=$(LINODE_API_URL)" + - "--node=$(NODE_NAME)" + - "--bs-prefix=$(LINODE_BS_PREFIX)" + - "--v=10" + env: + - name: CSI_ENDPOINT + value: unix:///var/lib/csi/sockets/pluginproxy/csi.sock + - name: LINODE_API_URL + value: https://api.linode.com/v4 + - name: LINODE_BS_PREFIX + value: + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: LINODE_TOKEN + valueFrom: + secretKeyRef: + name: linode + key: token + imagePullPolicy: "Always" + volumeMounts: + - name: socket-dir + mountPath: /var/lib/csi/sockets/pluginproxy/ + volumes: + - name: socket-dir + emptyDir: {} + +--- +# pkg/linode-bs/deploy/kubernetes/07-ds-csi-linode-node.yaml +kind: DaemonSet +apiVersion: apps/v1 +metadata: + name: csi-linode-node + namespace: kube-system +spec: + selector: + matchLabels: + app: csi-linode-node + template: + metadata: + labels: + app: csi-linode-node + role: csi-linode + spec: + serviceAccount: csi-node-sa + hostNetwork: true + containers: + - name: driver-registrar + image: quay.io/k8scsi/csi-node-driver-registrar:v1.1.0 + args: + - "--v=5" + - "--csi-address=$(ADDRESS)" + - "--kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)" + lifecycle: + preStop: + exec: + command: ["/bin/sh", "-c", "rm -rf /registration/linodebs.csi.linode.com /registration/linodebs.csi.linode.com-reg.sock"] + env: + - name: ADDRESS + value: /csi/csi.sock + - name: DRIVER_REG_SOCK_PATH + value: /var/lib/kubelet/plugins/linodebs.csi.linode.com/csi.sock + - name: KUBE_NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + volumeMounts: + - name: plugin-dir + mountPath: /csi/ + - name: registration-dir + mountPath: /registration/ + - name: csi-linode-plugin + image: linode/linode-blockstorage-csi-driver:canary + args : + - "--endpoint=$(CSI_ENDPOINT)" + - "--token=$(LINODE_TOKEN)" + - "--url=$(LINODE_API_URL)" + - "--node=$(NODE_NAME)" + - "--v=10" + env: + - name: CSI_ENDPOINT + value: unix:///csi/csi.sock + - name: LINODE_API_URL + value: https://api.linode.com/v4 + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: LINODE_TOKEN + valueFrom: + secretKeyRef: + name: linode + key: token + imagePullPolicy: "Always" + securityContext: + privileged: true + capabilities: + add: ["SYS_ADMIN"] + allowPrivilegeEscalation: true + volumeMounts: + - name: plugin-dir + mountPath: /csi + - name: pods-mount-dir + mountPath: /var/lib/kubelet + # needed so that any mounts setup inside this container are + # propagated back to the host machine. + mountPropagation: "Bidirectional" + - mountPath: /dev + name: device-dir + volumes: + - name: registration-dir + hostPath: + path: /var/lib/kubelet/plugins_registry/ + type: DirectoryOrCreate + - name: kubelet-dir + hostPath: + path: /var/lib/kubelet + type: Directory + - name: plugin-dir + hostPath: + path: /var/lib/kubelet/plugins/linodebs.csi.linode.com + type: DirectoryOrCreate + - name: pods-mount-dir + hostPath: + path: /var/lib/kubelet + type: Directory + - name: device-dir + hostPath: + path: /dev + # The following mounts are required to trigger host udevadm from container + - name: udev-rules-etc + hostPath: + path: /etc/udev + type: Directory + - name: udev-rules-lib + hostPath: + path: /lib/udev + type: Directory + - name: udev-socket + hostPath: + path: /run/udev + type: Directory + - name: sys + hostPath: + path: /sys + type: Directory + +--- diff --git a/pkg/linode-bs/deploy/releases/linode-blockstorage-csi-driver-v1.1.0.yaml b/pkg/linode-bs/deploy/releases/linode-blockstorage-csi-driver-v1.1.0.yaml index a541d9eb..e0ac33aa 100644 --- a/pkg/linode-bs/deploy/releases/linode-blockstorage-csi-driver-v1.1.0.yaml +++ b/pkg/linode-bs/deploy/releases/linode-blockstorage-csi-driver-v1.1.0.yaml @@ -379,7 +379,7 @@ spec: - name: socket-dir mountPath: /var/lib/csi/sockets/pluginproxy/ - name: linode-csi-plugin - image: sanjid/linode-blockstorage-csi-driver:canary + image: linode/linode-blockstorage-csi-driver:canary args : - "--endpoint=$(CSI_ENDPOINT)" - "--token=$(LINODE_TOKEN)" @@ -456,7 +456,7 @@ spec: - name: registration-dir mountPath: /registration/ - name: csi-linode-plugin - image: sanjid/linode-blockstorage-csi-driver:canary + image: linode/linode-blockstorage-csi-driver:canary args : - "--endpoint=$(CSI_ENDPOINT)" - "--token=$(LINODE_TOKEN)" From eae387c0e0a5932701b5b35a88a883977ca2dba5 Mon Sep 17 00:00:00 2001 From: sanjid133 Date: Tue, 16 Apr 2019 19:46:32 +0600 Subject: [PATCH 04/24] Resize volume --- go.mod | 3 +- go.sum | 4 +- pkg/linode-bs/controllerserver.go | 47 ++ .../kubernetes/05-csi-storageclass.yaml | 3 +- ...linode-blockstorage-csi-driver-v1.1.0.yaml | 522 ++++++++++++++++++ pkg/linode-bs/driver.go | 8 + .../examples/kubernetes/csi-pvc.yaml | 2 +- pkg/linode-bs/identityserver.go | 17 +- pkg/linode-bs/nodeserver.go | 8 + pkg/linode-client/linode-client.go | 2 + 10 files changed, 609 insertions(+), 7 deletions(-) create mode 100644 pkg/linode-bs/deploy/releases/linode-blockstorage-csi-driver-v1.1.0.yaml diff --git a/go.mod b/go.mod index 70799141..d2b286db 100644 --- a/go.mod +++ b/go.mod @@ -2,13 +2,14 @@ module github.com/linode/linode-blockstorage-csi-driver require ( github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 // indirect - github.com/container-storage-interface/spec v1.0.0 + github.com/container-storage-interface/spec v1.1.0 github.com/davecgh/go-spew v1.1.1 // indirect github.com/dnaeon/go-vcr v0.0.0-20180920040454-5637cf3d8a31 // indirect github.com/docker/distribution v2.6.2+incompatible // indirect github.com/gogo/protobuf v1.1.1 // indirect github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b github.com/golang/groupcache v0.0.0-20181024230925-c65c006176ff // indirect + github.com/golang/protobuf v1.2.0 github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c // indirect github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf // indirect github.com/googleapis/gnostic v0.2.0 // indirect diff --git a/go.sum b/go.sum index ad2d9c18..e3d54ed5 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/container-storage-interface/spec v1.0.0 h1:3DyXuJgf9MU6kyULESegQUmozsSxhpyrrv9u5bfwA3E= -github.com/container-storage-interface/spec v1.0.0/go.mod h1:6URME8mwIBbpVyZV93Ce5St17xBiQJQY67NDsuohiy4= +github.com/container-storage-interface/spec v1.1.0 h1:qPsTqtR1VUPvMPeK0UnCZMtXaKGyyLPG8gj/wG6VqMs= +github.com/container-storage-interface/spec v1.1.0/go.mod h1:6URME8mwIBbpVyZV93Ce5St17xBiQJQY67NDsuohiy4= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dnaeon/go-vcr v0.0.0-20180920040454-5637cf3d8a31 h1:Dzuw9GtbmllUqEcoHfScT9YpKFUssSiZ5PgZkIGf/YQ= diff --git a/pkg/linode-bs/controllerserver.go b/pkg/linode-bs/controllerserver.go index 54b7fdef..c425f505 100644 --- a/pkg/linode-bs/controllerserver.go +++ b/pkg/linode-bs/controllerserver.go @@ -419,6 +419,7 @@ func (linodeCS *LinodeControllerServer) ControllerGetCapabilities(ctx context.Co csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME, csi.ControllerServiceCapability_RPC_PUBLISH_UNPUBLISH_VOLUME, csi.ControllerServiceCapability_RPC_LIST_VOLUMES, + csi.ControllerServiceCapability_RPC_EXPAND_VOLUME, } { caps = append(caps, newCap(capability)) } @@ -450,6 +451,52 @@ func (linodeCS *LinodeControllerServer) ListSnapshots(ctx context.Context, req * return nil, status.Error(codes.Unimplemented, "") } +func (linodeCS *LinodeControllerServer) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) { + volumeID, statusErr := common.VolumeIdAsInt("ControllerUnpublishVolume", req) + if statusErr != nil { + return nil, statusErr + } + + capRange := req.GetCapacityRange() + size, err := getRequestCapacitySize(capRange) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + glog.V(4).Infoln("expand volume called", map[string]interface{}{ + "volume_id": volumeID, + "method": "controller_expand_volume", + }) + + var vol *linodego.Volume + + if vol, err = linodeCS.CloudProvider.GetVolume(ctx, volumeID); err != nil { + if apiErr, ok := err.(*linodego.Error); ok && apiErr.Code == 404 { + return &csi.ControllerExpandVolumeResponse{}, nil + } + return nil, status.Error(codes.Internal, err.Error()) + } else if vol.LinodeID != nil { + return nil, status.Error(codes.FailedPrecondition, "DeleteVolume Volume in use") + } + + if vol.Size > int(size/gigabyte) { + return nil, status.Error(codes.Internal, "Volumes can only be resized up") + } + + if err := linodeCS.CloudProvider.ResizeVolume(ctx, volumeID, int(size / gigabyte)); err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + resp := &csi.ControllerExpandVolumeResponse{ + CapacityBytes: size, + NodeExpansionRequired: false, + } + glog.V(4).Info("volume is resized") + return resp, nil + + +} + // getRequestCapacity evaluates the CapacityRange parameters to validate and resolve the best volume size func getRequestCapacitySize(capRange *csi.CapacityRange) (int64, error) { if capRange == nil { diff --git a/pkg/linode-bs/deploy/kubernetes/05-csi-storageclass.yaml b/pkg/linode-bs/deploy/kubernetes/05-csi-storageclass.yaml index 2c87f88d..121954fa 100644 --- a/pkg/linode-bs/deploy/kubernetes/05-csi-storageclass.yaml +++ b/pkg/linode-bs/deploy/kubernetes/05-csi-storageclass.yaml @@ -3,8 +3,6 @@ apiVersion: storage.k8s.io/v1 metadata: name: linode-block-storage namespace: kube-system - annotations: - storageclass.kubernetes.io/is-default-class: "true" provisioner: linodebs.csi.linode.com --- kind: StorageClass @@ -14,3 +12,4 @@ metadata: namespace: kube-system provisioner: linodebs.csi.linode.com reclaimPolicy: Retain +allowVolumeExpansion: true \ No newline at end of file diff --git a/pkg/linode-bs/deploy/releases/linode-blockstorage-csi-driver-v1.1.0.yaml b/pkg/linode-bs/deploy/releases/linode-blockstorage-csi-driver-v1.1.0.yaml new file mode 100644 index 00000000..e837fe11 --- /dev/null +++ b/pkg/linode-bs/deploy/releases/linode-blockstorage-csi-driver-v1.1.0.yaml @@ -0,0 +1,522 @@ +# pkg/linode-bs/deploy/kubernetes/01-csi-nodeinfo.yaml +# Requires CSINodeInfo feature gate (alpha in 1.12) +# xref: https://raw.githubusercontent.com/kubernetes/csi-api/master/pkg/crd/manifests/csidriver.yaml +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: csinodeinfos.csi.storage.k8s.io + labels: + addonmanager.kubernetes.io/mode: Reconcile +spec: + group: csi.storage.k8s.io + version: v1alpha1 + names: + kind: CSINodeInfo + plural: csinodeinfos + scope: Cluster + validation: + openAPIV3Schema: + properties: + spec: + description: Specification of CSINodeInfo + properties: + drivers: + description: List of CSI drivers running on the node and their specs. + type: array + items: + properties: + name: + description: The CSI driver that this object refers to. + type: string + nodeID: + description: The node from the driver point of view. + type: string + topologyKeys: + description: List of keys supported by the driver. + items: + type: string + type: array + status: + description: Status of CSINodeInfo + properties: + drivers: + description: List of CSI drivers running on the node and their statuses. + type: array + items: + properties: + name: + description: The CSI driver that this object refers to. + type: string + available: + description: Whether the CSI driver is installed. + type: boolean + volumePluginMechanism: + description: Indicates to external components the required mechanism + to use for any in-tree plugins replaced by this driver. + pattern: in-tree|csi + type: string + +--- +# pkg/linode-bs/deploy/kubernetes/02-csi-driver.yaml +# Requires CSIDriverRegistry feature gate (alpha in 1.12) +# xref: https://raw.githubusercontent.com/kubernetes/csi-api/master/pkg/crd/manifests/csinodeinfo.yaml +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: csidrivers.csi.storage.k8s.io + labels: + addonmanager.kubernetes.io/mode: Reconcile +spec: + version: v1alpha1 + 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 +--- +# pkg/linode-bs/deploy/kubernetes/03-accounts-roles-bindings.yaml +##### Node Service Account, Roles, RoleBindings +apiVersion: v1 +kind: ServiceAccount +metadata: + name: csi-node-sa + namespace: kube-system + +--- + +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: driver-registrar-role + namespace: kube-system +rules: +- apiGroups: [""] + resources: ["events"] + verbs: ["get", "list", "watch", "create", "update", "patch"] + + +--- + +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: driver-registrar-binding + namespace: kube-system +subjects: +- kind: ServiceAccount + name: csi-node-sa + namespace: kube-system +roleRef: + kind: ClusterRole + name: driver-registrar-role + apiGroup: rbac.authorization.k8s.io + +--- +##### Controller Service Account, Roles, Rolebindings +apiVersion: v1 +kind: ServiceAccount +metadata: + name: csi-controller-sa + namespace: kube-system + +--- +# xref: https://github.com/kubernetes-csi/external-provisioner/blob/master/deploy/kubernetes/rbac.yaml +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: external-provisioner-role + namespace: kube-system +rules: +- apiGroups: [""] + resources: ["secrets"] + verbs: ["get", "list"] +- apiGroups: [""] + resources: ["persistentvolumes"] + verbs: ["get", "list", "watch", "create", "delete"] +- apiGroups: [""] + resources: ["persistentvolumeclaims"] + verbs: ["get", "list", "watch", "update"] +- apiGroups: ["storage.k8s.io"] + resources: ["storageclasses"] + verbs: ["get", "list", "watch"] +- apiGroups: [""] + resources: ["events"] + verbs: ["list", "watch", "create", "update", "patch"] +- apiGroups: ["snapshot.storage.k8s.io"] + resources: ["volumesnapshots"] + verbs: ["get", "list"] +- apiGroups: ["snapshot.storage.k8s.io"] + resources: ["volumesnapshotcontents"] + verbs: ["get", "list"] + +--- + +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: csi-controller-provisioner-binding + namespace: kube-system +subjects: +- kind: ServiceAccount + name: csi-controller-sa + namespace: kube-system +roleRef: + kind: ClusterRole + name: external-provisioner-role + apiGroup: rbac.authorization.k8s.io + +--- +# xref: https://github.com/kubernetes-csi/external-attacher/blob/master/deploy/kubernetes/rbac.yaml +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: external-attacher-role + namespace: kube-system +rules: +- apiGroups: [""] + resources: ["persistentvolumes"] + verbs: ["get", "list", "watch", "update"] +- apiGroups: [""] + resources: ["nodes"] + verbs: ["get", "list", "watch"] +- apiGroups: ["csi.storage.k8s.io"] + resources: ["csinodeinfos"] + verbs: ["get", "list", "watch"] +- apiGroups: ["storage.k8s.io"] + resources: ["volumeattachments"] + verbs: ["get", "list", "watch", "update"] + +--- + +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: csi-controller-attacher-binding + namespace: kube-system +subjects: +- kind: ServiceAccount + name: csi-controller-sa + namespace: kube-system +roleRef: + kind: ClusterRole + name: external-attacher-role + apiGroup: rbac.authorization.k8s.io + +--- +# xref: https://github.com/kubernetes-csi/external-snapshotter/blob/master/deploy/kubernetes/rbac.yaml +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: external-snapshotter-role + namespace: kube-system +rules: +- apiGroups: ["snapshot.storage.k8s.io"] + resources: ["volumesnapshotclasses"] + verbs: ["get", "list", "watch"] +- apiGroups: ["snapshot.storage.k8s.io"] + resources: ["volumesnapshotcontents"] + verbs: ["create", "get", "list", "watch", "update", "delete"] +- apiGroups: ["snapshot.storage.k8s.io"] + resources: ["volumesnapshots"] + verbs: ["get", "list", "watch", "update"] +- apiGroups: ["apiextensions.k8s.io"] + resources: ["customresourcedefinitions"] + verbs: ["create", "list", "watch", "delete"] +- apiGroups: [""] + resources: ["events"] + verbs: ["list", "watch", "create", "update", "patch"] +- apiGroups: ["storage.k8s.io"] + resources: ["storageclasses"] + verbs: ["watch", "get", "list"] +- apiGroups: ["admissionregistration.k8s.io"] + resources: ["mutatingwebhookconfigurations"] + verbs: ["create"] + +--- + +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: csi-controller-snapshotter-binding + namespace: kube-system +subjects: +- kind: ServiceAccount + name: csi-controller-sa + namespace: kube-system +roleRef: + kind: ClusterRole + name: external-snapshotter-role + apiGroup: rbac.authorization.k8s.io + +--- +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: 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-controller-cluster-registrar-binding + namespace: kube-system +subjects: +- kind: ServiceAccount + name: csi-controller-sa + namespace: kube-system +roleRef: + kind: ClusterRole + name: cluster-driver-registrar-role + apiGroup: rbac.authorization.k8s.io + +--- +# pkg/linode-bs/deploy/kubernetes/05-csi-storageclass.yaml +kind: StorageClass +apiVersion: storage.k8s.io/v1 +metadata: + name: linode-block-storage + namespace: kube-system + annotations: + storageclass.kubernetes.io/is-default-class: "true" +provisioner: linodebs.csi.linode.com +--- +kind: StorageClass +apiVersion: storage.k8s.io/v1 +metadata: + name: linode-block-storage-retain + namespace: kube-system +provisioner: linodebs.csi.linode.com +reclaimPolicy: Retain + +--- +# pkg/linode-bs/deploy/kubernetes/06-ss-csi-linode-controller.yaml +kind: StatefulSet +apiVersion: apps/v1 +metadata: + name: csi-linode-controller + namespace: kube-system +spec: + serviceName: "csi-linode" + replicas: 1 + selector: + matchLabels: + app: csi-linode-controller + template: + metadata: + labels: + app: csi-linode-controller + role: csi-linode + spec: + serviceAccount: csi-controller-sa + containers: + - name: csi-provisioner + image: quay.io/k8scsi/csi-provisioner:v1.1.0 + args: + - "--volume-name-prefix=pvc" + - "--volume-name-uuid-length=16" + - "--csi-address=$(ADDRESS)" + - "--v=5" + env: + - name: ADDRESS + value: /var/lib/csi/sockets/pluginproxy/csi.sock + imagePullPolicy: "Always" + volumeMounts: + - name: socket-dir + mountPath: /var/lib/csi/sockets/pluginproxy/ + - name: csi-attacher + image: quay.io/k8scsi/csi-attacher:v1.0.1 + args: + - "--v=5" + - "--csi-address=$(ADDRESS)" + env: + - name: ADDRESS + value: /var/lib/csi/sockets/pluginproxy/csi.sock + imagePullPolicy: "Always" + 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: linode-csi-plugin + image: sanjid/linode-blockstorage-csi-driver:canary + args : + - "--endpoint=$(CSI_ENDPOINT)" + - "--token=$(LINODE_TOKEN)" + - "--url=$(LINODE_API_URL)" + - "--node=$(NODE_NAME)" + - "--bs-prefix=$(LINODE_BS_PREFIX)" + - "--v=10" + env: + - name: CSI_ENDPOINT + value: unix:///var/lib/csi/sockets/pluginproxy/csi.sock + - name: LINODE_API_URL + value: https://api.linode.com/v4 + - name: LINODE_BS_PREFIX + value: + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: LINODE_TOKEN + valueFrom: + secretKeyRef: + name: linode + key: token + imagePullPolicy: "Always" + volumeMounts: + - name: socket-dir + mountPath: /var/lib/csi/sockets/pluginproxy/ + volumes: + - name: socket-dir + emptyDir: {} + +--- +# pkg/linode-bs/deploy/kubernetes/07-ds-csi-linode-node.yaml +kind: DaemonSet +apiVersion: apps/v1 +metadata: + name: csi-linode-node + namespace: kube-system +spec: + selector: + matchLabels: + app: csi-linode-node + template: + metadata: + labels: + app: csi-linode-node + role: csi-linode + spec: + serviceAccount: csi-node-sa + hostNetwork: true + containers: + - name: driver-registrar + image: quay.io/k8scsi/csi-node-driver-registrar:v1.1.0 + args: + - "--v=5" + - "--csi-address=$(ADDRESS)" + - "--kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)" + lifecycle: + preStop: + exec: + command: ["/bin/sh", "-c", "rm -rf /registration/linodebs.csi.linode.com /registration/linodebs.csi.linode.com-reg.sock"] + env: + - name: ADDRESS + value: /csi/csi.sock + - name: DRIVER_REG_SOCK_PATH + value: /var/lib/kubelet/plugins/linodebs.csi.linode.com/csi.sock + - name: KUBE_NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + volumeMounts: + - name: plugin-dir + mountPath: /csi/ + - name: registration-dir + mountPath: /registration/ + - name: csi-linode-plugin + image: sanjid/linode-blockstorage-csi-driver:canary + args : + - "--endpoint=$(CSI_ENDPOINT)" + - "--token=$(LINODE_TOKEN)" + - "--url=$(LINODE_API_URL)" + - "--node=$(NODE_NAME)" + - "--v=10" + env: + - name: CSI_ENDPOINT + value: unix:///csi/csi.sock + - name: LINODE_API_URL + value: https://api.linode.com/v4 + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: LINODE_TOKEN + valueFrom: + secretKeyRef: + name: linode + key: token + imagePullPolicy: "Always" + securityContext: + privileged: true + capabilities: + add: ["SYS_ADMIN"] + allowPrivilegeEscalation: true + volumeMounts: + - name: plugin-dir + mountPath: /csi + - name: pods-mount-dir + mountPath: /var/lib/kubelet + # needed so that any mounts setup inside this container are + # propagated back to the host machine. + mountPropagation: "Bidirectional" + - mountPath: /dev + name: device-dir + volumes: + - name: registration-dir + hostPath: + path: /var/lib/kubelet/plugins_registry/ + type: DirectoryOrCreate + - name: kubelet-dir + hostPath: + path: /var/lib/kubelet + type: Directory + - name: plugin-dir + hostPath: + path: /var/lib/kubelet/plugins/linodebs.csi.linode.com + type: DirectoryOrCreate + - name: pods-mount-dir + hostPath: + path: /var/lib/kubelet + type: Directory + - name: device-dir + hostPath: + path: /dev + # The following mounts are required to trigger host udevadm from container + - name: udev-rules-etc + hostPath: + path: /etc/udev + type: Directory + - name: udev-rules-lib + hostPath: + path: /lib/udev + type: Directory + - name: udev-socket + hostPath: + path: /run/udev + type: Directory + - name: sys + hostPath: + path: /sys + type: Directory + +--- diff --git a/pkg/linode-bs/driver.go b/pkg/linode-bs/driver.go index 8c7dc611..be7f61e8 100644 --- a/pkg/linode-bs/driver.go +++ b/pkg/linode-bs/driver.go @@ -18,6 +18,7 @@ import ( "fmt" "regexp" "strconv" + "sync" "github.com/container-storage-interface/spec/lib/go/csi" linodeclient "github.com/linode/linode-blockstorage-csi-driver/pkg/linode-client" @@ -42,6 +43,9 @@ type LinodeDriver struct { vcap []*csi.VolumeCapability_AccessMode cscap []*csi.ControllerServiceCapability nscap []*csi.NodeServiceCapability + + readyMu sync.Mutex // protects ready + ready bool } const linodeBSPrefixLength = 12 @@ -82,12 +86,14 @@ func (linodeDriver *LinodeDriver) SetupLinodeDriver(linodeClient linodeclient.Li // csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT, // csi.ControllerServiceCapability_RPC_LIST_SNAPSHOTS, csi.ControllerServiceCapability_RPC_PUBLISH_READONLY, + csi.ControllerServiceCapability_RPC_EXPAND_VOLUME, } if err := linodeDriver.AddControllerServiceCapabilities(csc); err != nil { return err } ns := []csi.NodeServiceCapability_RPC_Type{ csi.NodeServiceCapability_RPC_STAGE_UNSTAGE_VOLUME, + csi.NodeServiceCapability_RPC_EXPAND_VOLUME, } if err := linodeDriver.AddNodeServiceCapabilities(ns); err != nil { return err @@ -175,6 +181,8 @@ func (linodeDriver *LinodeDriver) Run(endpoint string) { glog.V(4).Infof("BS Volume Prefix: %v", linodeDriver.bsPrefix) } + linodeDriver.ready = true + //Start the nonblocking GRPC s := NewNonBlockingGRPCServer() // TODO(#34): Only start specific servers based on a flag. diff --git a/pkg/linode-bs/examples/kubernetes/csi-pvc.yaml b/pkg/linode-bs/examples/kubernetes/csi-pvc.yaml index f66d64da..c8e1cf1a 100644 --- a/pkg/linode-bs/examples/kubernetes/csi-pvc.yaml +++ b/pkg/linode-bs/examples/kubernetes/csi-pvc.yaml @@ -8,4 +8,4 @@ spec: resources: requests: storage: 10Gi - storageClassName: linode-block-storage + storageClassName: linode-block-storage-expand diff --git a/pkg/linode-bs/identityserver.go b/pkg/linode-bs/identityserver.go index 0f13525f..af2d21e1 100644 --- a/pkg/linode-bs/identityserver.go +++ b/pkg/linode-bs/identityserver.go @@ -16,6 +16,7 @@ package linodebs import ( csi "github.com/container-storage-interface/spec/lib/go/csi" + "github.com/golang/protobuf/ptypes/wrappers" "github.com/golang/glog" "golang.org/x/net/context" "google.golang.org/grpc/codes" @@ -58,11 +59,25 @@ func (linodeIdentity *LinodeIdentityServer) GetPluginCapabilities(ctx context.Co }, }, }, + { + Type: &csi.PluginCapability_VolumeExpansion_{ + VolumeExpansion: &csi.PluginCapability_VolumeExpansion{ + Type: csi.PluginCapability_VolumeExpansion_ONLINE, + }, + }, + }, }, }, nil } func (linodeIdentity *LinodeIdentityServer) Probe(ctx context.Context, req *csi.ProbeRequest) (*csi.ProbeResponse, error) { glog.V(4).Infof("Probe called with args: %#v", req) - return &csi.ProbeResponse{}, nil + linodeIdentity.Driver.readyMu.Lock() + defer linodeIdentity.Driver.readyMu.Unlock() + + return &csi.ProbeResponse{ + Ready: &wrappers.BoolValue{ + Value: true, + }, + }, nil } diff --git a/pkg/linode-bs/nodeserver.go b/pkg/linode-bs/nodeserver.go index 3d0fb6a8..47a37778 100644 --- a/pkg/linode-bs/nodeserver.go +++ b/pkg/linode-bs/nodeserver.go @@ -268,6 +268,14 @@ func (ns *LinodeNodeServer) NodeUnstageVolume(ctx context.Context, req *csi.Node return &csi.NodeUnstageVolumeResponse{}, nil } +func (ns *LinodeNodeServer) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandVolumeRequest) (*csi.NodeExpandVolumeResponse, error) { + glog.V(4).Infof("NodeExpandVolume called with req: %#v", req) + + return &csi.NodeExpandVolumeResponse{ + CapacityBytes: req.CapacityRange.RequiredBytes, + }, nil +} + func (ns *LinodeNodeServer) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) { glog.V(4).Infof("NodeGetCapabilities called with req: %#v", req) diff --git a/pkg/linode-client/linode-client.go b/pkg/linode-client/linode-client.go index f4c9f1fb..bcc9fd44 100644 --- a/pkg/linode-client/linode-client.go +++ b/pkg/linode-client/linode-client.go @@ -24,6 +24,8 @@ type LinodeClient interface { WaitForVolumeLinodeID(context.Context, int, *int, int) (*linodego.Volume, error) WaitForVolumeStatus(context.Context, int, linodego.VolumeStatus, int) (*linodego.Volume, error) DeleteVolume(context.Context, int) error + + ResizeVolume(context.Context, int, int) error } func NewLinodeClient(token, uaPrefix string, url string) *linodego.Client { From c0d1e1554d306cd36b59d4bd63440bcdb3b5fa78 Mon Sep 17 00:00:00 2001 From: sanjid133 Date: Tue, 30 Apr 2019 17:14:17 +0600 Subject: [PATCH 05/24] volume expand working with kube1.14 --- pkg/linode-bs/controllerserver.go | 13 +++++++--- .../kubernetes/05-csi-storageclass.yaml | 6 ++--- ...linode-blockstorage-csi-driver-v1.1.0.yaml | 24 ++++++++++++++----- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/pkg/linode-bs/controllerserver.go b/pkg/linode-bs/controllerserver.go index c425f505..77d4cbba 100644 --- a/pkg/linode-bs/controllerserver.go +++ b/pkg/linode-bs/controllerserver.go @@ -452,7 +452,7 @@ func (linodeCS *LinodeControllerServer) ListSnapshots(ctx context.Context, req * } func (linodeCS *LinodeControllerServer) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) { - volumeID, statusErr := common.VolumeIdAsInt("ControllerUnpublishVolume", req) + volumeID, statusErr := common.VolumeIdAsInt("ControllerExpandVolume", req) if statusErr != nil { return nil, statusErr } @@ -475,8 +475,6 @@ func (linodeCS *LinodeControllerServer) ControllerExpandVolume(ctx context.Conte return &csi.ControllerExpandVolumeResponse{}, nil } return nil, status.Error(codes.Internal, err.Error()) - } else if vol.LinodeID != nil { - return nil, status.Error(codes.FailedPrecondition, "DeleteVolume Volume in use") } if vol.Size > int(size/gigabyte) { @@ -487,6 +485,15 @@ func (linodeCS *LinodeControllerServer) ControllerExpandVolume(ctx context.Conte return nil, status.Error(codes.Internal, err.Error()) } + vol, err = linodeCS.CloudProvider.WaitForVolumeStatus(ctx, vol.ID, linodego.VolumeActive, waitTimeout) + + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + glog.V(4).Infoln("volume active", map[string]interface{}{"vol": vol}) + + resp := &csi.ControllerExpandVolumeResponse{ CapacityBytes: size, NodeExpansionRequired: false, diff --git a/pkg/linode-bs/deploy/kubernetes/05-csi-storageclass.yaml b/pkg/linode-bs/deploy/kubernetes/05-csi-storageclass.yaml index 121954fa..17c66ac4 100644 --- a/pkg/linode-bs/deploy/kubernetes/05-csi-storageclass.yaml +++ b/pkg/linode-bs/deploy/kubernetes/05-csi-storageclass.yaml @@ -8,8 +8,8 @@ provisioner: linodebs.csi.linode.com kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: - name: linode-block-storage-retain + name: linode-block-storage-expand namespace: kube-system provisioner: linodebs.csi.linode.com -reclaimPolicy: Retain -allowVolumeExpansion: true \ No newline at end of file +reclaimPolicy: Delete +allowVolumeExpansion: true diff --git a/pkg/linode-bs/deploy/releases/linode-blockstorage-csi-driver-v1.1.0.yaml b/pkg/linode-bs/deploy/releases/linode-blockstorage-csi-driver-v1.1.0.yaml index e837fe11..a541d9eb 100644 --- a/pkg/linode-bs/deploy/releases/linode-blockstorage-csi-driver-v1.1.0.yaml +++ b/pkg/linode-bs/deploy/releases/linode-blockstorage-csi-driver-v1.1.0.yaml @@ -149,8 +149,8 @@ rules: resources: ["persistentvolumes"] verbs: ["get", "list", "watch", "create", "delete"] - apiGroups: [""] - resources: ["persistentvolumeclaims"] - verbs: ["get", "list", "watch", "update"] + resources: ["persistentvolumeclaims", "persistentvolumeclaims/status"] + verbs: ["get", "list", "watch", "update", "patch"] - apiGroups: ["storage.k8s.io"] resources: ["storageclasses"] verbs: ["get", "list", "watch"] @@ -199,7 +199,7 @@ rules: verbs: ["get", "list", "watch"] - apiGroups: ["storage.k8s.io"] resources: ["volumeattachments"] - verbs: ["get", "list", "watch", "update"] + verbs: ["create", "get", "list", "watch", "update"] --- @@ -270,7 +270,7 @@ metadata: name: cluster-driver-registrar-role rules: - apiGroups: ["csi.storage.k8s.io"] - resources: ["csidrivers"] + resources: ["csidrivers", "volumeattachments"] verbs: ["create", "delete"] --- @@ -302,10 +302,11 @@ provisioner: linodebs.csi.linode.com kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: - name: linode-block-storage-retain + name: linode-block-storage-expand namespace: kube-system provisioner: linodebs.csi.linode.com -reclaimPolicy: Retain +reclaimPolicy: Delete +allowVolumeExpansion: true --- # pkg/linode-bs/deploy/kubernetes/06-ss-csi-linode-controller.yaml @@ -366,6 +367,17 @@ spec: volumeMounts: - name: socket-dir mountPath: /var/lib/csi/sockets/pluginproxy/ + - name: linode-csi-resizer + image: quay.io/k8scsi/csi-resizer:v0.1.0 + args: + - "--v=5" + - "--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: linode-csi-plugin image: sanjid/linode-blockstorage-csi-driver:canary args : From 55590cf3753a81506f75f050cfc342bbef8f3ffd Mon Sep 17 00:00:00 2001 From: sanjid133 Date: Fri, 17 May 2019 16:17:31 +0600 Subject: [PATCH 06/24] revendor --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index d2b286db..e0a5afaf 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f // indirect github.com/hashicorp/golang-lru v0.5.0 // indirect github.com/json-iterator/go v1.1.5 // indirect - github.com/kubernetes-csi/csi-test v1.1.0 + github.com/kubernetes-csi/csi-test v2.0.0+incompatible github.com/linode/linodego v0.7.0 github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect diff --git a/go.sum b/go.sum index e3d54ed5..de235644 100644 --- a/go.sum +++ b/go.sum @@ -41,6 +41,8 @@ github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCV github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kubernetes-csi/csi-test v1.1.0 h1:a7CfGqhGDs0h7AZt1f6LTIUzBazcRf6eBdTUBXB4xE4= github.com/kubernetes-csi/csi-test v1.1.0/go.mod h1:YxJ4UiuPWIhMBkxUKY5c267DyA0uDZ/MtAimhx/2TA0= +github.com/kubernetes-csi/csi-test v2.0.0+incompatible h1:ia04uVFUM/J9n/v3LEMn3rEG6FmKV5BH9QLw7H68h44= +github.com/kubernetes-csi/csi-test v2.0.0+incompatible/go.mod h1:YxJ4UiuPWIhMBkxUKY5c267DyA0uDZ/MtAimhx/2TA0= github.com/linode/linodego v0.7.0 h1:03zIycZla2QvoLvaqQiLSbjj91yBm+NSibDtJenuEBo= github.com/linode/linodego v0.7.0/go.mod h1:ga11n3ivecUrPCHN0rANxKmfWBJVkOXfLMZinAbj2sY= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= From 3dc55fac3794975e1124f3bc3d048563b84ae38a Mon Sep 17 00:00:00 2001 From: sanjid133 Date: Fri, 17 May 2019 17:36:42 +0600 Subject: [PATCH 07/24] Fixed following error: - should fail when an invalid starting_token is passed - should fail when the starting_token is greater than total number of vols --- go.sum | 2 -- pkg/linode-bs/controllerserver.go | 24 +++++++++++++++--------- pkg/linode-bs/driver_test.go | 18 +++--------------- 3 files changed, 18 insertions(+), 26 deletions(-) diff --git a/go.sum b/go.sum index de235644..ea0bca1b 100644 --- a/go.sum +++ b/go.sum @@ -39,8 +39,6 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO github.com/json-iterator/go v1.1.5 h1:gL2yXlmiIo4+t+y32d4WGwOjKGYcGOuyrg46vadswDE= github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kubernetes-csi/csi-test v1.1.0 h1:a7CfGqhGDs0h7AZt1f6LTIUzBazcRf6eBdTUBXB4xE4= -github.com/kubernetes-csi/csi-test v1.1.0/go.mod h1:YxJ4UiuPWIhMBkxUKY5c267DyA0uDZ/MtAimhx/2TA0= github.com/kubernetes-csi/csi-test v2.0.0+incompatible h1:ia04uVFUM/J9n/v3LEMn3rEG6FmKV5BH9QLw7H68h44= github.com/kubernetes-csi/csi-test v2.0.0+incompatible/go.mod h1:YxJ4UiuPWIhMBkxUKY5c267DyA0uDZ/MtAimhx/2TA0= github.com/linode/linodego v0.7.0 h1:03zIycZla2QvoLvaqQiLSbjj91yBm+NSibDtJenuEBo= diff --git a/pkg/linode-bs/controllerserver.go b/pkg/linode-bs/controllerserver.go index 77d4cbba..fad02380 100644 --- a/pkg/linode-bs/controllerserver.go +++ b/pkg/linode-bs/controllerserver.go @@ -348,19 +348,20 @@ func (linodeCS *LinodeControllerServer) ListVolumes(ctx context.Context, req *cs nextToken := "" listOpts := linodego.NewListOptions(0, "") - if req.GetMaxEntries() > 0 { - if startingToken == "" { - listOpts.Page = 1 - } else { - startingPage, errParse := strconv.ParseInt(startingToken, 10, 64) - if errParse != nil { - return nil, status.Error(codes.Aborted, fmt.Sprintf("Invalid starting token %v", startingToken)) - } - listOpts.Page = int(startingPage) + if startingToken != "" { + startingPage, errParse := strconv.ParseInt(startingToken, 10, 64) + if errParse != nil { + return nil, status.Error(codes.Aborted, fmt.Sprintf("Invalid starting token %v", startingToken)) } + + listOpts.Page = int(startingPage) nextToken = strconv.Itoa(listOpts.Page + 1) } + if req.GetMaxEntries() > 0 { + nextToken = strconv.Itoa(int(req.GetMaxEntries())) + } + glog.V(4).Infoln("list volumes called", map[string]interface{}{ "list_opts": listOpts, "req_starting_token": req.StartingToken, @@ -373,6 +374,11 @@ func (linodeCS *LinodeControllerServer) ListVolumes(ctx context.Context, req *cs if err != nil { return nil, err } + if listOpts.Page > len(volumes) { + return nil, status.Error(codes.Aborted, fmt.Sprintf("Starting token is greater than total number of vols")) + } + + var entries []*csi.ListVolumesResponse_Entry for _, vol := range volumes { diff --git a/pkg/linode-bs/driver_test.go b/pkg/linode-bs/driver_test.go index d9e56390..e007b510 100644 --- a/pkg/linode-bs/driver_test.go +++ b/pkg/linode-bs/driver_test.go @@ -2,7 +2,6 @@ package linodebs import ( "encoding/json" - "io/ioutil" "math/rand" "net/http" "net/http/httptest" @@ -13,7 +12,7 @@ import ( "github.com/linode/linode-blockstorage-csi-driver/pkg/linode-client" "github.com/linode/linode-blockstorage-csi-driver/pkg/metadata" - mountmanager "github.com/linode/linode-blockstorage-csi-driver/pkg/mount-manager" + "github.com/linode/linode-blockstorage-csi-driver/pkg/mount-manager" "strconv" @@ -79,21 +78,10 @@ func TestDriverSuite(t *testing.T) { go linodeDriver.Run(endpoint) - mntDir, err := ioutil.TempDir("", "mnt") - if err != nil { - t.Fatal(err) - } - defer os.RemoveAll(mntDir) - - mntStageDir, err := ioutil.TempDir("", "mnt-stage") - if err != nil { - t.Fatal(err) - } - defer os.RemoveAll(mntStageDir) cfg := &sanity.Config{ - StagingPath: mntStageDir, - TargetPath: mntDir, + TargetPath: os.TempDir() + "/csi-target", + StagingPath: os.TempDir() + "/csi-staging", Address: endpoint, } From eb42a1cc7172210fa8f35bbdf62fa40e7359859d Mon Sep 17 00:00:00 2001 From: sanjid133 Date: Mon, 20 May 2019 14:37:54 +0600 Subject: [PATCH 08/24] fix test --- pkg/linode-bs/controllerserver.go | 4 ++++ pkg/linode-bs/driver_test.go | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/pkg/linode-bs/controllerserver.go b/pkg/linode-bs/controllerserver.go index fad02380..f7e7371a 100644 --- a/pkg/linode-bs/controllerserver.go +++ b/pkg/linode-bs/controllerserver.go @@ -397,6 +397,10 @@ func (linodeCS *LinodeControllerServer) ListVolumes(ctx context.Context, req *cs }, }, }) + if len(entries) == int(req.MaxEntries) { + nextToken = strconv.Itoa(int(req.MaxEntries)) + break + } } resp := &csi.ListVolumesResponse{ diff --git a/pkg/linode-bs/driver_test.go b/pkg/linode-bs/driver_test.go index e007b510..71375491 100644 --- a/pkg/linode-bs/driver_test.go +++ b/pkg/linode-bs/driver_test.go @@ -122,7 +122,17 @@ func (f *fakeAPI) ServeHTTP(w http.ResponseWriter, r *http.Request) { res := 0 data := []linodego.Volume{} + var filters map[string]string + hf := r.Header.Get("X-Filter") + if hf != "" { + _= json.Unmarshal([]byte(hf), &filters) + } + for _, vol := range f.volumes { + + if filters["label"] != "" && filters["label"] != vol.Label { + continue + } data = append(data, vol) } resp := linodego.VolumesPagedResponse{ From 02e1cab2c390aa75f57247460067d10c3e32b56c Mon Sep 17 00:00:00 2001 From: phillc <15082+phillc@users.noreply.github.com> Date: Fri, 21 Aug 2020 11:49:51 -0400 Subject: [PATCH 09/24] Converge makefile with CCM --- Makefile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 67c902d0..479d1950 100644 --- a/Makefile +++ b/Makefile @@ -35,16 +35,17 @@ vet: fmt test: vet go test -v ./... -cover -.PHONY: linode -linode: test +.PHONY: build-linux +build-linux: test CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-X main.vendorVersion=$(REV) -extldflags "-static"' -o _output/linode ./app/linode -.PHONY: linode-container -linode-container: linode +.PHONY: docker-build +docker-build: build-linux docker build -t $(IMAGE_TAG) -f ./app/linode/Dockerfile . -.PHONY: push -push: linode-container +.PHONY: docker-push +docker-push: + echo "[reminder] Did you run `make docker-build`?" docker push $(IMAGE_TAG) .PHONY: verify From f16c05dfc6e95b693bd2a0a34ed14493c5a9fca4 Mon Sep 17 00:00:00 2001 From: phillc <15082+phillc@users.noreply.github.com> Date: Fri, 21 Aug 2020 14:17:21 -0400 Subject: [PATCH 10/24] Remove unnecessary use of fmt.Sprintf --- pkg/linode-bs/controllerserver.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/linode-bs/controllerserver.go b/pkg/linode-bs/controllerserver.go index 08074edc..8eef9b6d 100644 --- a/pkg/linode-bs/controllerserver.go +++ b/pkg/linode-bs/controllerserver.go @@ -375,7 +375,7 @@ func (linodeCS *LinodeControllerServer) ListVolumes(ctx context.Context, req *cs return nil, err } if listOpts.Page > len(volumes) { - return nil, status.Error(codes.Aborted, fmt.Sprintf("Starting token is greater than total number of vols")) + return nil, status.Error(codes.Aborted, "Starting token is greater than total number of vols") } var entries []*csi.ListVolumesResponse_Entry From 56a81ec2a5bbc43d9ba144487342cf19c686d70c Mon Sep 17 00:00:00 2001 From: phillc <15082+phillc@users.noreply.github.com> Date: Fri, 21 Aug 2020 14:53:54 -0400 Subject: [PATCH 11/24] docker-build in travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a470d0ab..37f1caf3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,7 +31,7 @@ install: script: - make test - - make linode-container + - make docker-build - golangci-lint run - travis_wait 20 roveralls -ignore e2e - goveralls -coverprofile=roveralls.coverprofile -service=travis-ci -ignore=csi_driver_test.go,e2e_suite_test.go From 6cb5ffba2011036d654339ea9a63bc379859226b Mon Sep 17 00:00:00 2001 From: phillc <15082+phillc@users.noreply.github.com> Date: Mon, 24 Aug 2020 09:55:52 -0400 Subject: [PATCH 12/24] Split release manifest script - for use in e2e test suite --- e2e/Makefile | 16 ++++++++++------ hack/generate-yaml.sh | 27 +++++++++++++++++++++++++++ hack/release-yaml.sh | 15 +-------------- 3 files changed, 38 insertions(+), 20 deletions(-) create mode 100755 hack/generate-yaml.sh diff --git a/e2e/Makefile b/e2e/Makefile index a0c91de8..9e566f56 100644 --- a/e2e/Makefile +++ b/e2e/Makefile @@ -1,16 +1,20 @@ export GO111MODULE=on -IMG ?= linode/linode-blockstorage-csi-driver:latest -imports: $(GOPATH)/bin/goimports - goimports -w test +REGISTRY_NAME=index.docker.io/linode +IMAGE_NAME=linode-blockstorage-csi-driver +IMAGE_VERSION=canary +IMAGE_TAG=$(REGISTRY_NAME)/$(IMAGE_NAME):$(IMAGE_VERSION) -.PHONY: test reuse-and-test clean +.PHONY: test reuse-and-test clean check-token install-terraform test-manifest + +test-manifest: + ../hack/generate-yaml.sh $(IMAGE_VERSION) > test/manifest/linode-blockstorage-csi-driver.yaml reuse-and-test: SUITE_ARGS='--reuse' -test reuse-and-test: $(GOPATH)/bin/ginkgo check-token +test reuse-and-test: $(GOPATH)/bin/ginkgo check-token test-manifest go list -m; \ - ginkgo -r --v --progress --trace --cover $(TEST_ARGS) -- --v=3 --image=${IMG} $(SUITE_ARGS); \ + ginkgo -r --v --progress --trace --cover $(TEST_ARGS) -- --v=3 --image=${IMAGE_TAG} $(SUITE_ARGS) clean: check-token cd test; \ diff --git a/hack/generate-yaml.sh b/hack/generate-yaml.sh new file mode 100755 index 00000000..21756bd3 --- /dev/null +++ b/hack/generate-yaml.sh @@ -0,0 +1,27 @@ +#!/bin/bash -e +set -o pipefail +# Generate manifests for deployment on Kubernetes + +# A tag name _must_ be supplied as the first argument +TAG="${1}" +if [[ -z "${TAG}" ]]; then + echo "Tag name to release must be supplied as the first argument" + echo "e.g. $ hack/release-yaml.sh v1.0.0" + exit 1 +fi + +# Get the last manifest in the folder +cd $(dirname "$0")/../ +manifests=pkg/linode-bs/deploy/kubernetes/0 +last="$(ls -dq "${manifests}"* | tail -n 1)" + +# Build release manifest +for manifest in "${manifests}"*; do + echo "# ${manifest}" + echo "$(cat ${manifest})" | sed -e "s|{{ .Values.image.tag }}|"${TAG}"|" + + # Don't add the separator if it's the last manifest + if [[ "${manifest}" != "${last}" ]]; then + echo -e "---" + fi +done diff --git a/hack/release-yaml.sh b/hack/release-yaml.sh index 895f2a3c..175a46c1 100755 --- a/hack/release-yaml.sh +++ b/hack/release-yaml.sh @@ -14,20 +14,7 @@ RELEASES="pkg/linode-bs/deploy/releases" TAGGED_RELEASE="linode-blockstorage-csi-driver-${TAG}.yaml" GENERIC_RELEASE="linode-blockstorage-csi-driver.yaml" -# Get the last manifest in the folder -manifests=pkg/linode-bs/deploy/kubernetes/0 -last="$(ls -dq "${manifests}"* | tail -n 1)" - -# Build release manifest -for manifest in "${manifests}"*; do - echo "# ${manifest}" - echo "$(cat ${manifest})" | sed -e "s|{{ .Values.image.tag }}|"${TAG}"|" - - # Don't add the separator if it's the last manifest - if [[ "${manifest}" != "${last}" ]]; then - echo -e "---" - fi -done > "${RELEASES}/${TAGGED_RELEASE}" +$(dirname "$0")/generate-yaml.sh "$1" > "${RELEASES}/${TAGGED_RELEASE}" # Create generic manifest from tagged release manifest cp "${RELEASES}/${TAGGED_RELEASE}" "${RELEASES}/${GENERIC_RELEASE}" From 4af1119a2a2d9dbb25e75b8e58e6c370fd1c5836 Mon Sep 17 00:00:00 2001 From: phillc <15082+phillc@users.noreply.github.com> Date: Mon, 24 Aug 2020 16:54:20 -0400 Subject: [PATCH 13/24] Redundant tests --- e2e/test/csi_driver_test.go | 42 ------------------------------------- go.mod | 12 ++++++----- go.sum | 28 ++++++++++++++++++------- 3 files changed, 27 insertions(+), 55 deletions(-) diff --git a/e2e/test/csi_driver_test.go b/e2e/test/csi_driver_test.go index c6361af8..b17d5586 100644 --- a/e2e/test/csi_driver_test.go +++ b/e2e/test/csi_driver_test.go @@ -94,26 +94,6 @@ var _ = Describe("CSIDriver", func() { readFile(file) }) }) - - Context("10Gi Storage", func() { - BeforeEach(func() { - size = "10Gi" - }) - It("should write and read", func() { - writeFile(file) - readFile(file) - }) - }) - - Context("20Gi Storage", func() { - BeforeEach(func() { - size = "20Gi" - }) - It("should write and read", func() { - writeFile(file) - readFile(file) - }) - }) }) }) }) @@ -163,28 +143,6 @@ var _ = Describe("CSIDriver", func() { readFile(file) }) }) - - Context("Expanding Storage from 10Gi to 20Gi", func() { - BeforeEach(func() { - size = "10Gi" - }) - It("should write and read", func() { - writeFile(file) - expandVolume("20Gi") - readFile(file) - }) - }) - - Context("Expanding Storage from 20Gi to 25Gi", func() { - BeforeEach(func() { - size = "20Gi" - }) - It("should write and read", func() { - writeFile(file) - expandVolume("25Gi") - readFile(file) - }) - }) }) }) }) diff --git a/go.mod b/go.mod index bb7ce71c..210a1dd2 100644 --- a/go.mod +++ b/go.mod @@ -12,10 +12,11 @@ require ( github.com/golang/protobuf v1.2.0 github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c // indirect github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf // indirect + github.com/google/uuid v1.1.1 // indirect github.com/googleapis/gnostic v0.2.0 // indirect github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f // indirect github.com/hashicorp/golang-lru v0.5.0 // indirect - github.com/json-iterator/go v1.1.5 // indirect + github.com/json-iterator/go v1.1.6 // indirect github.com/kubernetes-csi/csi-test v2.0.0+incompatible github.com/linode/linodego v0.10.0 github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect @@ -25,7 +26,6 @@ require ( github.com/onsi/gomega v1.4.3 // indirect github.com/pborman/uuid v1.2.0 // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_golang v0.9.1 // indirect github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 // indirect github.com/prometheus/common v0.0.0-20181120120127-aeab699e26f4 // indirect @@ -34,14 +34,16 @@ require ( github.com/spf13/pflag v1.0.3 // indirect github.com/stevvooe/resumable v0.0.0-20180830230917-22b14a53ba50 // indirect github.com/stretchr/objx v0.1.1 // indirect - github.com/stretchr/testify v1.2.2 // indirect - golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 // indirect - golang.org/x/net v0.0.0-20181114220301-adae6a3d119a + github.com/stretchr/testify v1.3.0 // indirect + golang.org/x/crypto v0.0.0-20190422183909-d864b10871cd // indirect + golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 golang.org/x/oauth2 v0.0.0-20181120190819-8f65e3013eba // indirect + golang.org/x/sync v0.0.0-20190423024810-112230192c58 // indirect golang.org/x/time v0.0.0-20181108054448-85acf8d2951c // indirect google.golang.org/grpc v1.16.0 gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/resty.v1 v1.10.2 // indirect + gopkg.in/yaml.v2 v2.3.0 // indirect k8s.io/api v0.0.0-20181121071145-b7bd5f2d334c // indirect k8s.io/apiextensions-apiserver v0.0.0-20181123033937-b8ea0ae3837a // indirect k8s.io/apimachinery v0.0.0-20181127025237-2b1284ed4c93 diff --git a/go.sum b/go.sum index 0b589e05..81fcf78e 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,7 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24 github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/container-storage-interface/spec v1.1.0 h1:qPsTqtR1VUPvMPeK0UnCZMtXaKGyyLPG8gj/wG6VqMs= github.com/container-storage-interface/spec v1.1.0/go.mod h1:6URME8mwIBbpVyZV93Ce5St17xBiQJQY67NDsuohiy4= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dnaeon/go-vcr v0.0.0-20180814043457-aafff18a5cc2/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= @@ -29,6 +30,8 @@ github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf h1:+RRA9JqSOZFfKrOeq github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/uuid v1.0.0 h1:b4Gk+7WdP/d3HZH8EJsZpvV7EtDOgaZLtnaNGIu1adA= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gnostic v0.2.0 h1:l6N3VoaVzTncYYW+9yOz2LJJammFZGBO13sqgEhpy9g= github.com/googleapis/gnostic v0.2.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f h1:ShTPMJQes6tubcjzGMODIVG5hlrCeImaBnZzKF2N8SM= @@ -37,8 +40,8 @@ github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCO github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/json-iterator/go v1.1.5 h1:gL2yXlmiIo4+t+y32d4WGwOjKGYcGOuyrg46vadswDE= -github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -80,27 +83,34 @@ github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/stevvooe/resumable v0.0.0-20180830230917-22b14a53ba50 h1:4bT0pPowCpQImewr+BjzfUKcuFW+KVyB8d1OF3b6oTI= github.com/stevvooe/resumable v0.0.0-20180830230917-22b14a53ba50/go.mod h1:1pdIZTAHUz+HDKDVZ++5xg/duPlhKAIzw9qy42CWYp4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190422183909-d864b10871cd h1:sMHc2rZHuzQmrbVoSpt9HgerkXPyIeCSO6k0zUMGfFk= +golang.org/x/crypto v0.0.0-20190422183909-d864b10871cd/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/net v0.0.0-20180611182652-db08ff08e862/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181011144130-49bb7cea24b1/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a h1:gOpx8G595UYyvj8UK4+OFyY4rx037g3fmfhe5SasG3U= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181120190819-8f65e3013eba h1:YDkOrzGLLYybtuP6ZgebnO4OWYEYVMFSniazXsxrFN8= golang.org/x/oauth2 v0.0.0-20181120190819-8f65e3013eba/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e h1:o3PsSEY8E4eXWkXrIP9YJALUkVZqzHJT5DOasTyn8Vs= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c h1:fqgJT0MGcGpPgpWU7VRdRjuArfcOvC4AoJmILihzhDg= @@ -127,6 +137,8 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkep gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= k8s.io/api v0.0.0-20181121071145-b7bd5f2d334c h1:aSW17ws1n3Y/gxcAggEFSs+UJlzpE3+stTPLQSiVEno= k8s.io/api v0.0.0-20181121071145-b7bd5f2d334c/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA= From ab46ac6c78935a23650867f73a133e95ad86be70 Mon Sep 17 00:00:00 2001 From: phillc <15082+phillc@users.noreply.github.com> Date: Tue, 25 Aug 2020 10:16:06 -0400 Subject: [PATCH 14/24] Translate the manifest into pieces --- e2e/test/csi_driver_test.go | 2 +- .../linode-blockstorage-csi-driver.yaml | 568 +++++++++--------- .../03-accounts-roles-bindings.yaml | 6 +- .../06-ss-csi-linode-controller.yaml | 15 +- 4 files changed, 314 insertions(+), 277 deletions(-) diff --git a/e2e/test/csi_driver_test.go b/e2e/test/csi_driver_test.go index b17d5586..096e1c88 100644 --- a/e2e/test/csi_driver_test.go +++ b/e2e/test/csi_driver_test.go @@ -107,7 +107,7 @@ var _ = Describe("CSIDriver", func() { Expect(err).NotTo(HaveOccurred()) By("Creating Persistent Volume Claim") - pvc = f.GetPersistentVolumeClaimObject(size, "linode-block-storage-expand") + pvc = f.GetPersistentVolumeClaimObject(size, "linode-block-storage") err = f.CreatePersistentVolumeClaim(pvc) Expect(err).NotTo(HaveOccurred()) diff --git a/e2e/test/manifest/linode-blockstorage-csi-driver.yaml b/e2e/test/manifest/linode-blockstorage-csi-driver.yaml index e0ac33aa..28fcb955 100644 --- a/e2e/test/manifest/linode-blockstorage-csi-driver.yaml +++ b/e2e/test/manifest/linode-blockstorage-csi-driver.yaml @@ -55,7 +55,6 @@ spec: to use for any in-tree plugins replaced by this driver. pattern: in-tree|csi type: string - --- # pkg/linode-bs/deploy/kubernetes/02-csi-driver.yaml # Requires CSIDriverRegistry feature gate (alpha in 1.12) @@ -96,36 +95,33 @@ kind: ServiceAccount metadata: name: csi-node-sa namespace: kube-system - --- - kind: ClusterRole apiVersion: rbac.authorization.k8s.io/v1 metadata: name: driver-registrar-role namespace: kube-system rules: -- apiGroups: [""] - resources: ["events"] - verbs: ["get", "list", "watch", "create", "update", "patch"] - - + - apiGroups: [""] + resources: ["events"] + verbs: ["get", "list", "watch", "create", "update", "patch"] + - apiGroups: [""] + resources: ["nodes"] + verbs: ["get", "list", "watch"] --- - kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: driver-registrar-binding namespace: kube-system subjects: -- kind: ServiceAccount - name: csi-node-sa - namespace: kube-system + - kind: ServiceAccount + name: csi-node-sa + namespace: kube-system roleRef: kind: ClusterRole name: driver-registrar-role apiGroup: rbac.authorization.k8s.io - --- ##### Controller Service Account, Roles, Rolebindings apiVersion: v1 @@ -133,7 +129,6 @@ kind: ServiceAccount metadata: name: csi-controller-sa namespace: kube-system - --- # xref: https://github.com/kubernetes-csi/external-provisioner/blob/master/deploy/kubernetes/rbac.yaml kind: ClusterRole @@ -142,44 +137,41 @@ metadata: name: external-provisioner-role namespace: kube-system rules: -- apiGroups: [""] - resources: ["secrets"] - verbs: ["get", "list"] -- apiGroups: [""] - resources: ["persistentvolumes"] - verbs: ["get", "list", "watch", "create", "delete"] -- apiGroups: [""] - resources: ["persistentvolumeclaims", "persistentvolumeclaims/status"] - verbs: ["get", "list", "watch", "update", "patch"] -- apiGroups: ["storage.k8s.io"] - resources: ["storageclasses"] - verbs: ["get", "list", "watch"] -- apiGroups: [""] - resources: ["events"] - verbs: ["list", "watch", "create", "update", "patch"] -- apiGroups: ["snapshot.storage.k8s.io"] - resources: ["volumesnapshots"] - verbs: ["get", "list"] -- apiGroups: ["snapshot.storage.k8s.io"] - resources: ["volumesnapshotcontents"] - verbs: ["get", "list"] - + - apiGroups: [""] + resources: ["secrets"] + verbs: ["get", "list"] + - apiGroups: [""] + resources: ["persistentvolumes"] + verbs: ["get", "list", "watch", "create", "delete"] + - apiGroups: [""] + resources: ["persistentvolumeclaims", "persistentvolumeclaims/status"] + verbs: ["get", "list", "watch", "update", "patch"] + - apiGroups: ["storage.k8s.io"] + resources: ["storageclasses"] + verbs: ["get", "list", "watch"] + - apiGroups: [""] + resources: ["events"] + verbs: ["list", "watch", "create", "update", "patch"] + - apiGroups: ["snapshot.storage.k8s.io"] + resources: ["volumesnapshots"] + verbs: ["get", "list"] + - apiGroups: ["snapshot.storage.k8s.io"] + resources: ["volumesnapshotcontents"] + verbs: ["get", "list"] --- - kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: csi-controller-provisioner-binding namespace: kube-system subjects: -- kind: ServiceAccount - name: csi-controller-sa - namespace: kube-system + - kind: ServiceAccount + name: csi-controller-sa + namespace: kube-system roleRef: kind: ClusterRole name: external-provisioner-role apiGroup: rbac.authorization.k8s.io - --- # xref: https://github.com/kubernetes-csi/external-attacher/blob/master/deploy/kubernetes/rbac.yaml kind: ClusterRole @@ -188,35 +180,32 @@ metadata: name: external-attacher-role namespace: kube-system rules: -- apiGroups: [""] - resources: ["persistentvolumes"] - verbs: ["get", "list", "watch", "update"] -- apiGroups: [""] - resources: ["nodes"] - verbs: ["get", "list", "watch"] -- apiGroups: ["csi.storage.k8s.io"] - resources: ["csinodeinfos"] - verbs: ["get", "list", "watch"] -- apiGroups: ["storage.k8s.io"] - resources: ["volumeattachments"] - verbs: ["create", "get", "list", "watch", "update"] - + - apiGroups: [""] + resources: ["persistentvolumes"] + verbs: ["get", "list", "watch", "update"] + - apiGroups: [""] + resources: ["nodes"] + verbs: ["get", "list", "watch"] + - apiGroups: ["csi.storage.k8s.io"] + resources: ["csinodeinfos"] + verbs: ["get", "list", "watch"] + - apiGroups: ["storage.k8s.io"] + resources: ["volumeattachments"] + verbs: ["create", "get", "list", "watch", "update"] --- - kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: csi-controller-attacher-binding namespace: kube-system subjects: -- kind: ServiceAccount - name: csi-controller-sa - namespace: kube-system + - kind: ServiceAccount + name: csi-controller-sa + namespace: kube-system roleRef: kind: ClusterRole name: external-attacher-role apiGroup: rbac.authorization.k8s.io - --- # xref: https://github.com/kubernetes-csi/external-snapshotter/blob/master/deploy/kubernetes/rbac.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -246,48 +235,29 @@ rules: - apiGroups: ["admissionregistration.k8s.io"] resources: ["mutatingwebhookconfigurations"] verbs: ["create"] - --- - kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: csi-controller-snapshotter-binding namespace: kube-system subjects: -- kind: ServiceAccount - name: csi-controller-sa - namespace: kube-system + - kind: ServiceAccount + name: csi-controller-sa + namespace: kube-system roleRef: kind: ClusterRole name: external-snapshotter-role apiGroup: rbac.authorization.k8s.io - ---- -kind: ClusterRole -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: cluster-driver-registrar-role -rules: -- apiGroups: ["csi.storage.k8s.io"] - resources: ["csidrivers", "volumeattachments"] - verbs: ["create", "delete"] --- - -kind: ClusterRoleBinding -apiVersion: rbac.authorization.k8s.io/v1 +# pkg/linode-bs/deploy/kubernetes/04-csi-driver-instance.yaml +apiVersion: csi.storage.k8s.io/v1alpha1 +kind: CSIDriver metadata: - name: csi-controller-cluster-registrar-binding - namespace: kube-system -subjects: -- kind: ServiceAccount - name: csi-controller-sa - namespace: kube-system -roleRef: - kind: ClusterRole - name: cluster-driver-registrar-role - apiGroup: rbac.authorization.k8s.io - + name: linodebs.csi.linode.com +spec: + attachRequired: true + podInfoOnMountVersion: "v1" --- # pkg/linode-bs/deploy/kubernetes/05-csi-storageclass.yaml kind: StorageClass @@ -295,19 +265,19 @@ apiVersion: storage.k8s.io/v1 metadata: name: linode-block-storage namespace: kube-system - annotations: - storageclass.kubernetes.io/is-default-class: "true" provisioner: linodebs.csi.linode.com +allowVolumeExpansion: true --- kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: - name: linode-block-storage-expand + name: linode-block-storage-retain namespace: kube-system + annotations: + storageclass.kubernetes.io/is-default-class: "true" provisioner: linodebs.csi.linode.com -reclaimPolicy: Delete +reclaimPolicy: Retain allowVolumeExpansion: true - --- # pkg/linode-bs/deploy/kubernetes/06-ss-csi-linode-controller.yaml kind: StatefulSet @@ -328,89 +298,102 @@ spec: role: csi-linode spec: serviceAccount: csi-controller-sa + initContainers: + - name: init + image: bitnami/kubectl:1.16.3-debian-10-r36 + command: + - /scripts/get-linode-id.sh + env: + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + volumeMounts: + - name: linode-info + mountPath: /linode-info + - name: get-linode-id + mountPath: /scripts containers: - - name: csi-provisioner - image: quay.io/k8scsi/csi-provisioner:v1.1.0 - args: - - "--volume-name-prefix=pvc" - - "--volume-name-uuid-length=16" - - "--csi-address=$(ADDRESS)" - - "--v=5" - env: - - name: ADDRESS - value: /var/lib/csi/sockets/pluginproxy/csi.sock - imagePullPolicy: "Always" - volumeMounts: - - name: socket-dir - mountPath: /var/lib/csi/sockets/pluginproxy/ - - name: csi-attacher - image: quay.io/k8scsi/csi-attacher:v1.0.1 - args: - - "--v=5" - - "--csi-address=$(ADDRESS)" - env: - - name: ADDRESS - value: /var/lib/csi/sockets/pluginproxy/csi.sock - imagePullPolicy: "Always" - 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: linode-csi-resizer - image: quay.io/k8scsi/csi-resizer:v0.1.0 - args: - - "--v=5" - - "--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: linode-csi-plugin - image: linode/linode-blockstorage-csi-driver:canary - args : - - "--endpoint=$(CSI_ENDPOINT)" - - "--token=$(LINODE_TOKEN)" - - "--url=$(LINODE_API_URL)" - - "--node=$(NODE_NAME)" - - "--bs-prefix=$(LINODE_BS_PREFIX)" - - "--v=10" - env: - - name: CSI_ENDPOINT - value: unix:///var/lib/csi/sockets/pluginproxy/csi.sock - - name: LINODE_API_URL - value: https://api.linode.com/v4 - - name: LINODE_BS_PREFIX - value: - - name: NODE_NAME - valueFrom: - fieldRef: - fieldPath: spec.nodeName - - name: LINODE_TOKEN - valueFrom: - secretKeyRef: - name: linode - key: token - imagePullPolicy: "Always" - volumeMounts: - - name: socket-dir - mountPath: /var/lib/csi/sockets/pluginproxy/ + - name: csi-provisioner + image: quay.io/k8scsi/csi-provisioner:v1.1.0 + args: + - "--volume-name-prefix=pvc" + - "--volume-name-uuid-length=16" + - "--csi-address=$(ADDRESS)" + - "--v=2" + env: + - name: ADDRESS + value: /var/lib/csi/sockets/pluginproxy/csi.sock + imagePullPolicy: "Always" + volumeMounts: + - name: socket-dir + mountPath: /var/lib/csi/sockets/pluginproxy/ + - name: csi-attacher + image: quay.io/k8scsi/csi-attacher:v1.1.0 + args: + - "--v=2" + - "--csi-address=$(ADDRESS)" + env: + - name: ADDRESS + value: /var/lib/csi/sockets/pluginproxy/csi.sock + imagePullPolicy: "Always" + volumeMounts: + - name: socket-dir + mountPath: /var/lib/csi/sockets/pluginproxy/ + - name: linode-csi-resizer + image: quay.io/k8scsi/csi-resizer:v0.1.0 + args: + - "--v=2" + - "--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: linode-csi-plugin + image: linode/linode-blockstorage-csi-driver:canary + args : + - "--endpoint=$(CSI_ENDPOINT)" + - "--token=$(LINODE_TOKEN)" + - "--url=$(LINODE_API_URL)" + - "--node=$(NODE_NAME)" + - "--bs-prefix=$(LINODE_BS_PREFIX)" + - "--v=2" + env: + - name: CSI_ENDPOINT + value: unix:///var/lib/csi/sockets/pluginproxy/csi.sock + - name: LINODE_API_URL + value: https://api.linode.com/v4 + - name: LINODE_BS_PREFIX + value: + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: LINODE_TOKEN + valueFrom: + secretKeyRef: + name: linode + key: token + imagePullPolicy: "Always" + volumeMounts: + - name: linode-info + mountPath: /linode-info + - name: get-linode-id + mountPath: /scripts + - name: socket-dir + mountPath: /var/lib/csi/sockets/pluginproxy/ volumes: - - name: socket-dir - emptyDir: {} - + - name: socket-dir + emptyDir: {} + - name: linode-info + emptyDir: {} + - name: get-linode-id + configMap: + name: get-linode-id + # octal mode 755 + defaultMode: 493 --- # pkg/linode-bs/deploy/kubernetes/07-ds-csi-linode-node.yaml kind: DaemonSet @@ -429,106 +412,149 @@ spec: role: csi-linode spec: serviceAccount: csi-node-sa + initContainers: + - name: init + image: bitnami/kubectl:1.16.3-debian-10-r36 + command: + - /scripts/get-linode-id.sh + env: + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + volumeMounts: + - name: linode-info + mountPath: /linode-info + - name: get-linode-id + mountPath: /scripts hostNetwork: true containers: - - name: driver-registrar - image: quay.io/k8scsi/csi-node-driver-registrar:v1.1.0 - args: - - "--v=5" - - "--csi-address=$(ADDRESS)" - - "--kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)" - lifecycle: - preStop: - exec: - command: ["/bin/sh", "-c", "rm -rf /registration/linodebs.csi.linode.com /registration/linodebs.csi.linode.com-reg.sock"] - env: - - name: ADDRESS - value: /csi/csi.sock - - name: DRIVER_REG_SOCK_PATH - value: /var/lib/kubelet/plugins/linodebs.csi.linode.com/csi.sock - - name: KUBE_NODE_NAME - valueFrom: - fieldRef: - fieldPath: spec.nodeName - volumeMounts: - - name: plugin-dir - mountPath: /csi/ + - name: driver-registrar + image: quay.io/k8scsi/driver-registrar:v1.0-canary + args: + - "--v=2" + - "--csi-address=$(ADDRESS)" + - "--mode=node-register" + - "--driver-requires-attachment=true" + - "--pod-info-mount-version=\"v1\"" + - "--kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)" + env: + - name: ADDRESS + value: /csi/csi.sock + - name: DRIVER_REG_SOCK_PATH + value: /var/lib/kubelet/plugins/linodebs.csi.linode.com/csi.sock + - name: KUBE_NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + volumeMounts: + - name: plugin-dir + mountPath: /csi/ + - name: registration-dir + mountPath: /registration/ + - name: csi-linode-plugin + image: linode/linode-blockstorage-csi-driver:canary + args : + - "--endpoint=$(CSI_ENDPOINT)" + - "--token=$(LINODE_TOKEN)" + - "--url=$(LINODE_API_URL)" + - "--node=$(NODE_NAME)" + - "--v=2" + env: + - name: CSI_ENDPOINT + value: unix:///csi/csi.sock + - name: LINODE_API_URL + value: https://api.linode.com/v4 + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: LINODE_TOKEN + valueFrom: + secretKeyRef: + name: linode + key: token + imagePullPolicy: "Always" + securityContext: + privileged: true + capabilities: + add: ["SYS_ADMIN"] + allowPrivilegeEscalation: true + volumeMounts: + - name: linode-info + mountPath: /linode-info + - name: get-linode-id + mountPath: /scripts + - name: plugin-dir + mountPath: /csi + - name: pods-mount-dir + mountPath: /var/lib/kubelet + # needed so that any mounts setup inside this container are + # propagated back to the host machine. + mountPropagation: "Bidirectional" + - mountPath: /dev + name: device-dir + volumes: + - name: linode-info + emptyDir: {} + - name: get-linode-id + configMap: + name: get-linode-id + defaultMode: 493 - name: registration-dir - mountPath: /registration/ - - name: csi-linode-plugin - image: linode/linode-blockstorage-csi-driver:canary - args : - - "--endpoint=$(CSI_ENDPOINT)" - - "--token=$(LINODE_TOKEN)" - - "--url=$(LINODE_API_URL)" - - "--node=$(NODE_NAME)" - - "--v=10" - env: - - name: CSI_ENDPOINT - value: unix:///csi/csi.sock - - name: LINODE_API_URL - value: https://api.linode.com/v4 - - name: NODE_NAME - valueFrom: - fieldRef: - fieldPath: spec.nodeName - - name: LINODE_TOKEN - valueFrom: - secretKeyRef: - name: linode - key: token - imagePullPolicy: "Always" - securityContext: - privileged: true - capabilities: - add: ["SYS_ADMIN"] - allowPrivilegeEscalation: true - volumeMounts: + hostPath: + path: /var/lib/kubelet/plugins_registry/ + type: DirectoryOrCreate + - name: kubelet-dir + hostPath: + path: /var/lib/kubelet + type: Directory - name: plugin-dir - mountPath: /csi + hostPath: + path: /var/lib/kubelet/plugins/linodebs.csi.linode.com + type: DirectoryOrCreate - name: pods-mount-dir - mountPath: /var/lib/kubelet - # needed so that any mounts setup inside this container are - # propagated back to the host machine. - mountPropagation: "Bidirectional" - - mountPath: /dev - name: device-dir - volumes: - - name: registration-dir - hostPath: - path: /var/lib/kubelet/plugins_registry/ - type: DirectoryOrCreate - - name: kubelet-dir - hostPath: - path: /var/lib/kubelet - type: Directory - - name: plugin-dir - hostPath: - path: /var/lib/kubelet/plugins/linodebs.csi.linode.com - type: DirectoryOrCreate - - name: pods-mount-dir - hostPath: - path: /var/lib/kubelet - type: Directory - - name: device-dir - hostPath: - path: /dev - # The following mounts are required to trigger host udevadm from container - - name: udev-rules-etc - hostPath: - path: /etc/udev - type: Directory - - name: udev-rules-lib - hostPath: - path: /lib/udev - type: Directory - - name: udev-socket - hostPath: - path: /run/udev - type: Directory - - name: sys - hostPath: - path: /sys - type: Directory - + hostPath: + path: /var/lib/kubelet + type: Directory + - name: device-dir + hostPath: + path: /dev + # The following mounts are required to trigger host udevadm from container + - name: udev-rules-etc + hostPath: + path: /etc/udev + type: Directory + - name: udev-rules-lib + hostPath: + path: /lib/udev + type: Directory + - name: udev-socket + hostPath: + path: /run/udev + type: Directory + - name: sys + hostPath: + path: /sys + type: Directory --- +# pkg/linode-bs/deploy/kubernetes/08-cm-get-linode-id.yaml +apiVersion: v1 +kind: ConfigMap +metadata: + name: get-linode-id + namespace: kube-system + labels: + app: csi-linode +data: + get-linode-id.sh: |- + #!/bin/bash -efu + id="$(kubectl get node/"${NODE_NAME}" -o jsonpath='{.spec.providerID}')" + if [[ ! -z "${id}" ]]; then + echo "${id}" + echo -n "${id:9}" > /linode-info/linode-id + exit 0 + fi + echo "Provider ID not found" + # Exit here so that we wait for the CCM to initialize the provider ID + exit 1 diff --git a/pkg/linode-bs/deploy/kubernetes/03-accounts-roles-bindings.yaml b/pkg/linode-bs/deploy/kubernetes/03-accounts-roles-bindings.yaml index 6c85e031..c468640b 100644 --- a/pkg/linode-bs/deploy/kubernetes/03-accounts-roles-bindings.yaml +++ b/pkg/linode-bs/deploy/kubernetes/03-accounts-roles-bindings.yaml @@ -53,8 +53,8 @@ rules: resources: ["persistentvolumes"] verbs: ["get", "list", "watch", "create", "delete"] - apiGroups: [""] - resources: ["persistentvolumeclaims"] - verbs: ["get", "list", "watch", "update"] + resources: ["persistentvolumeclaims", "persistentvolumeclaims/status"] + verbs: ["get", "list", "watch", "update", "patch"] - apiGroups: ["storage.k8s.io"] resources: ["storageclasses"] verbs: ["get", "list", "watch"] @@ -100,7 +100,7 @@ rules: verbs: ["get", "list", "watch"] - apiGroups: ["storage.k8s.io"] resources: ["volumeattachments"] - verbs: ["get", "list", "watch", "update"] + verbs: ["create", "get", "list", "watch", "update"] --- kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 diff --git a/pkg/linode-bs/deploy/kubernetes/06-ss-csi-linode-controller.yaml b/pkg/linode-bs/deploy/kubernetes/06-ss-csi-linode-controller.yaml index e7e78d8f..9733b4cb 100644 --- a/pkg/linode-bs/deploy/kubernetes/06-ss-csi-linode-controller.yaml +++ b/pkg/linode-bs/deploy/kubernetes/06-ss-csi-linode-controller.yaml @@ -33,7 +33,7 @@ spec: mountPath: /scripts containers: - name: csi-provisioner - image: quay.io/k8scsi/csi-provisioner:v1.0.0 + image: quay.io/k8scsi/csi-provisioner:v1.1.0 args: - "--volume-name-prefix=pvc" - "--volume-name-uuid-length=16" @@ -47,7 +47,7 @@ spec: - name: socket-dir mountPath: /var/lib/csi/sockets/pluginproxy/ - name: csi-attacher - image: quay.io/k8scsi/csi-attacher:v1.0.0 + image: quay.io/k8scsi/csi-attacher:v1.1.0 args: - "--v=2" - "--csi-address=$(ADDRESS)" @@ -58,6 +58,17 @@ spec: volumeMounts: - name: socket-dir mountPath: /var/lib/csi/sockets/pluginproxy/ + - name: linode-csi-resizer + image: quay.io/k8scsi/csi-resizer:v0.1.0 + args: + - "--v=2" + - "--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: linode-csi-plugin image: linode/linode-blockstorage-csi-driver:{{ .Values.image.tag }} args : From 91d49e89e9d2379f1b4bccd9db12286095fef299 Mon Sep 17 00:00:00 2001 From: phillc <15082+phillc@users.noreply.github.com> Date: Tue, 25 Aug 2020 17:15:11 -0400 Subject: [PATCH 15/24] Add patch to rbac for persistentvolumes --- e2e/test/manifest/linode-blockstorage-csi-driver.yaml | 2 +- pkg/linode-bs/deploy/kubernetes/03-accounts-roles-bindings.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/test/manifest/linode-blockstorage-csi-driver.yaml b/e2e/test/manifest/linode-blockstorage-csi-driver.yaml index 28fcb955..84f991e8 100644 --- a/e2e/test/manifest/linode-blockstorage-csi-driver.yaml +++ b/e2e/test/manifest/linode-blockstorage-csi-driver.yaml @@ -142,7 +142,7 @@ rules: verbs: ["get", "list"] - apiGroups: [""] resources: ["persistentvolumes"] - verbs: ["get", "list", "watch", "create", "delete"] + verbs: ["get", "list", "watch", "create", "delete", "patch"] - apiGroups: [""] resources: ["persistentvolumeclaims", "persistentvolumeclaims/status"] verbs: ["get", "list", "watch", "update", "patch"] diff --git a/pkg/linode-bs/deploy/kubernetes/03-accounts-roles-bindings.yaml b/pkg/linode-bs/deploy/kubernetes/03-accounts-roles-bindings.yaml index c468640b..b0af9c9c 100644 --- a/pkg/linode-bs/deploy/kubernetes/03-accounts-roles-bindings.yaml +++ b/pkg/linode-bs/deploy/kubernetes/03-accounts-roles-bindings.yaml @@ -51,7 +51,7 @@ rules: verbs: ["get", "list"] - apiGroups: [""] resources: ["persistentvolumes"] - verbs: ["get", "list", "watch", "create", "delete"] + verbs: ["get", "list", "watch", "create", "delete", "patch"] - apiGroups: [""] resources: ["persistentvolumeclaims", "persistentvolumeclaims/status"] verbs: ["get", "list", "watch", "update", "patch"] From ab79193395556e7dbd41f9de626f713c9e71b543 Mon Sep 17 00:00:00 2001 From: phillc <15082+phillc@users.noreply.github.com> Date: Wed, 26 Aug 2020 08:10:35 -0400 Subject: [PATCH 16/24] Ignore generated manifest in e2e tests --- e2e/test/.gitignore | 2 + e2e/test/manifest/.gitkeep | 0 .../linode-blockstorage-csi-driver.yaml | 560 ------------------ 3 files changed, 2 insertions(+), 560 deletions(-) create mode 100644 e2e/test/manifest/.gitkeep delete mode 100644 e2e/test/manifest/linode-blockstorage-csi-driver.yaml diff --git a/e2e/test/.gitignore b/e2e/test/.gitignore index fc3ef35d..82c873da 100644 --- a/e2e/test/.gitignore +++ b/e2e/test/.gitignore @@ -4,3 +4,5 @@ cluster.tf terraform* .terraform +manifest/linode-blockstorage-csi-driver.yaml + diff --git a/e2e/test/manifest/.gitkeep b/e2e/test/manifest/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/e2e/test/manifest/linode-blockstorage-csi-driver.yaml b/e2e/test/manifest/linode-blockstorage-csi-driver.yaml deleted file mode 100644 index 84f991e8..00000000 --- a/e2e/test/manifest/linode-blockstorage-csi-driver.yaml +++ /dev/null @@ -1,560 +0,0 @@ -# pkg/linode-bs/deploy/kubernetes/01-csi-nodeinfo.yaml -# Requires CSINodeInfo feature gate (alpha in 1.12) -# xref: https://raw.githubusercontent.com/kubernetes/csi-api/master/pkg/crd/manifests/csidriver.yaml -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - name: csinodeinfos.csi.storage.k8s.io - labels: - addonmanager.kubernetes.io/mode: Reconcile -spec: - group: csi.storage.k8s.io - version: v1alpha1 - names: - kind: CSINodeInfo - plural: csinodeinfos - scope: Cluster - validation: - openAPIV3Schema: - properties: - spec: - description: Specification of CSINodeInfo - properties: - drivers: - description: List of CSI drivers running on the node and their specs. - type: array - items: - properties: - name: - description: The CSI driver that this object refers to. - type: string - nodeID: - description: The node from the driver point of view. - type: string - topologyKeys: - description: List of keys supported by the driver. - items: - type: string - type: array - status: - description: Status of CSINodeInfo - properties: - drivers: - description: List of CSI drivers running on the node and their statuses. - type: array - items: - properties: - name: - description: The CSI driver that this object refers to. - type: string - available: - description: Whether the CSI driver is installed. - type: boolean - volumePluginMechanism: - description: Indicates to external components the required mechanism - to use for any in-tree plugins replaced by this driver. - pattern: in-tree|csi - type: string ---- -# pkg/linode-bs/deploy/kubernetes/02-csi-driver.yaml -# Requires CSIDriverRegistry feature gate (alpha in 1.12) -# xref: https://raw.githubusercontent.com/kubernetes/csi-api/master/pkg/crd/manifests/csinodeinfo.yaml -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - name: csidrivers.csi.storage.k8s.io - labels: - addonmanager.kubernetes.io/mode: Reconcile -spec: - version: v1alpha1 - 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 ---- -# pkg/linode-bs/deploy/kubernetes/03-accounts-roles-bindings.yaml -##### Node Service Account, Roles, RoleBindings -apiVersion: v1 -kind: ServiceAccount -metadata: - name: csi-node-sa - namespace: kube-system ---- -kind: ClusterRole -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: driver-registrar-role - namespace: kube-system -rules: - - apiGroups: [""] - resources: ["events"] - verbs: ["get", "list", "watch", "create", "update", "patch"] - - apiGroups: [""] - resources: ["nodes"] - verbs: ["get", "list", "watch"] ---- -kind: ClusterRoleBinding -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: driver-registrar-binding - namespace: kube-system -subjects: - - kind: ServiceAccount - name: csi-node-sa - namespace: kube-system -roleRef: - kind: ClusterRole - name: driver-registrar-role - apiGroup: rbac.authorization.k8s.io ---- -##### Controller Service Account, Roles, Rolebindings -apiVersion: v1 -kind: ServiceAccount -metadata: - name: csi-controller-sa - namespace: kube-system ---- -# xref: https://github.com/kubernetes-csi/external-provisioner/blob/master/deploy/kubernetes/rbac.yaml -kind: ClusterRole -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: external-provisioner-role - namespace: kube-system -rules: - - apiGroups: [""] - resources: ["secrets"] - verbs: ["get", "list"] - - apiGroups: [""] - resources: ["persistentvolumes"] - verbs: ["get", "list", "watch", "create", "delete", "patch"] - - apiGroups: [""] - resources: ["persistentvolumeclaims", "persistentvolumeclaims/status"] - verbs: ["get", "list", "watch", "update", "patch"] - - apiGroups: ["storage.k8s.io"] - resources: ["storageclasses"] - verbs: ["get", "list", "watch"] - - apiGroups: [""] - resources: ["events"] - verbs: ["list", "watch", "create", "update", "patch"] - - apiGroups: ["snapshot.storage.k8s.io"] - resources: ["volumesnapshots"] - verbs: ["get", "list"] - - apiGroups: ["snapshot.storage.k8s.io"] - resources: ["volumesnapshotcontents"] - verbs: ["get", "list"] ---- -kind: ClusterRoleBinding -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: csi-controller-provisioner-binding - namespace: kube-system -subjects: - - kind: ServiceAccount - name: csi-controller-sa - namespace: kube-system -roleRef: - kind: ClusterRole - name: external-provisioner-role - apiGroup: rbac.authorization.k8s.io ---- -# xref: https://github.com/kubernetes-csi/external-attacher/blob/master/deploy/kubernetes/rbac.yaml -kind: ClusterRole -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: external-attacher-role - namespace: kube-system -rules: - - apiGroups: [""] - resources: ["persistentvolumes"] - verbs: ["get", "list", "watch", "update"] - - apiGroups: [""] - resources: ["nodes"] - verbs: ["get", "list", "watch"] - - apiGroups: ["csi.storage.k8s.io"] - resources: ["csinodeinfos"] - verbs: ["get", "list", "watch"] - - apiGroups: ["storage.k8s.io"] - resources: ["volumeattachments"] - verbs: ["create", "get", "list", "watch", "update"] ---- -kind: ClusterRoleBinding -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: csi-controller-attacher-binding - namespace: kube-system -subjects: - - kind: ServiceAccount - name: csi-controller-sa - namespace: kube-system -roleRef: - kind: ClusterRole - name: external-attacher-role - apiGroup: rbac.authorization.k8s.io ---- -# xref: https://github.com/kubernetes-csi/external-snapshotter/blob/master/deploy/kubernetes/rbac.yaml -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: external-snapshotter-role - namespace: kube-system -rules: -- apiGroups: ["snapshot.storage.k8s.io"] - resources: ["volumesnapshotclasses"] - verbs: ["get", "list", "watch"] -- apiGroups: ["snapshot.storage.k8s.io"] - resources: ["volumesnapshotcontents"] - verbs: ["create", "get", "list", "watch", "update", "delete"] -- apiGroups: ["snapshot.storage.k8s.io"] - resources: ["volumesnapshots"] - verbs: ["get", "list", "watch", "update"] -- apiGroups: ["apiextensions.k8s.io"] - resources: ["customresourcedefinitions"] - verbs: ["create", "list", "watch", "delete"] -- apiGroups: [""] - resources: ["events"] - verbs: ["list", "watch", "create", "update", "patch"] -- apiGroups: ["storage.k8s.io"] - resources: ["storageclasses"] - verbs: ["watch", "get", "list"] -- apiGroups: ["admissionregistration.k8s.io"] - resources: ["mutatingwebhookconfigurations"] - verbs: ["create"] ---- -kind: ClusterRoleBinding -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: csi-controller-snapshotter-binding - namespace: kube-system -subjects: - - kind: ServiceAccount - name: csi-controller-sa - namespace: kube-system -roleRef: - kind: ClusterRole - name: external-snapshotter-role - apiGroup: rbac.authorization.k8s.io ---- -# pkg/linode-bs/deploy/kubernetes/04-csi-driver-instance.yaml -apiVersion: csi.storage.k8s.io/v1alpha1 -kind: CSIDriver -metadata: - name: linodebs.csi.linode.com -spec: - attachRequired: true - podInfoOnMountVersion: "v1" ---- -# pkg/linode-bs/deploy/kubernetes/05-csi-storageclass.yaml -kind: StorageClass -apiVersion: storage.k8s.io/v1 -metadata: - name: linode-block-storage - namespace: kube-system -provisioner: linodebs.csi.linode.com -allowVolumeExpansion: true ---- -kind: StorageClass -apiVersion: storage.k8s.io/v1 -metadata: - name: linode-block-storage-retain - namespace: kube-system - annotations: - storageclass.kubernetes.io/is-default-class: "true" -provisioner: linodebs.csi.linode.com -reclaimPolicy: Retain -allowVolumeExpansion: true ---- -# pkg/linode-bs/deploy/kubernetes/06-ss-csi-linode-controller.yaml -kind: StatefulSet -apiVersion: apps/v1 -metadata: - name: csi-linode-controller - namespace: kube-system -spec: - serviceName: "csi-linode" - replicas: 1 - selector: - matchLabels: - app: csi-linode-controller - template: - metadata: - labels: - app: csi-linode-controller - role: csi-linode - spec: - serviceAccount: csi-controller-sa - initContainers: - - name: init - image: bitnami/kubectl:1.16.3-debian-10-r36 - command: - - /scripts/get-linode-id.sh - env: - - name: NODE_NAME - valueFrom: - fieldRef: - fieldPath: spec.nodeName - volumeMounts: - - name: linode-info - mountPath: /linode-info - - name: get-linode-id - mountPath: /scripts - containers: - - name: csi-provisioner - image: quay.io/k8scsi/csi-provisioner:v1.1.0 - args: - - "--volume-name-prefix=pvc" - - "--volume-name-uuid-length=16" - - "--csi-address=$(ADDRESS)" - - "--v=2" - env: - - name: ADDRESS - value: /var/lib/csi/sockets/pluginproxy/csi.sock - imagePullPolicy: "Always" - volumeMounts: - - name: socket-dir - mountPath: /var/lib/csi/sockets/pluginproxy/ - - name: csi-attacher - image: quay.io/k8scsi/csi-attacher:v1.1.0 - args: - - "--v=2" - - "--csi-address=$(ADDRESS)" - env: - - name: ADDRESS - value: /var/lib/csi/sockets/pluginproxy/csi.sock - imagePullPolicy: "Always" - volumeMounts: - - name: socket-dir - mountPath: /var/lib/csi/sockets/pluginproxy/ - - name: linode-csi-resizer - image: quay.io/k8scsi/csi-resizer:v0.1.0 - args: - - "--v=2" - - "--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: linode-csi-plugin - image: linode/linode-blockstorage-csi-driver:canary - args : - - "--endpoint=$(CSI_ENDPOINT)" - - "--token=$(LINODE_TOKEN)" - - "--url=$(LINODE_API_URL)" - - "--node=$(NODE_NAME)" - - "--bs-prefix=$(LINODE_BS_PREFIX)" - - "--v=2" - env: - - name: CSI_ENDPOINT - value: unix:///var/lib/csi/sockets/pluginproxy/csi.sock - - name: LINODE_API_URL - value: https://api.linode.com/v4 - - name: LINODE_BS_PREFIX - value: - - name: NODE_NAME - valueFrom: - fieldRef: - fieldPath: spec.nodeName - - name: LINODE_TOKEN - valueFrom: - secretKeyRef: - name: linode - key: token - imagePullPolicy: "Always" - volumeMounts: - - name: linode-info - mountPath: /linode-info - - name: get-linode-id - mountPath: /scripts - - name: socket-dir - mountPath: /var/lib/csi/sockets/pluginproxy/ - volumes: - - name: socket-dir - emptyDir: {} - - name: linode-info - emptyDir: {} - - name: get-linode-id - configMap: - name: get-linode-id - # octal mode 755 - defaultMode: 493 ---- -# pkg/linode-bs/deploy/kubernetes/07-ds-csi-linode-node.yaml -kind: DaemonSet -apiVersion: apps/v1 -metadata: - name: csi-linode-node - namespace: kube-system -spec: - selector: - matchLabels: - app: csi-linode-node - template: - metadata: - labels: - app: csi-linode-node - role: csi-linode - spec: - serviceAccount: csi-node-sa - initContainers: - - name: init - image: bitnami/kubectl:1.16.3-debian-10-r36 - command: - - /scripts/get-linode-id.sh - env: - - name: NODE_NAME - valueFrom: - fieldRef: - fieldPath: spec.nodeName - volumeMounts: - - name: linode-info - mountPath: /linode-info - - name: get-linode-id - mountPath: /scripts - hostNetwork: true - containers: - - name: driver-registrar - image: quay.io/k8scsi/driver-registrar:v1.0-canary - args: - - "--v=2" - - "--csi-address=$(ADDRESS)" - - "--mode=node-register" - - "--driver-requires-attachment=true" - - "--pod-info-mount-version=\"v1\"" - - "--kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)" - env: - - name: ADDRESS - value: /csi/csi.sock - - name: DRIVER_REG_SOCK_PATH - value: /var/lib/kubelet/plugins/linodebs.csi.linode.com/csi.sock - - name: KUBE_NODE_NAME - valueFrom: - fieldRef: - fieldPath: spec.nodeName - volumeMounts: - - name: plugin-dir - mountPath: /csi/ - - name: registration-dir - mountPath: /registration/ - - name: csi-linode-plugin - image: linode/linode-blockstorage-csi-driver:canary - args : - - "--endpoint=$(CSI_ENDPOINT)" - - "--token=$(LINODE_TOKEN)" - - "--url=$(LINODE_API_URL)" - - "--node=$(NODE_NAME)" - - "--v=2" - env: - - name: CSI_ENDPOINT - value: unix:///csi/csi.sock - - name: LINODE_API_URL - value: https://api.linode.com/v4 - - name: NODE_NAME - valueFrom: - fieldRef: - fieldPath: spec.nodeName - - name: LINODE_TOKEN - valueFrom: - secretKeyRef: - name: linode - key: token - imagePullPolicy: "Always" - securityContext: - privileged: true - capabilities: - add: ["SYS_ADMIN"] - allowPrivilegeEscalation: true - volumeMounts: - - name: linode-info - mountPath: /linode-info - - name: get-linode-id - mountPath: /scripts - - name: plugin-dir - mountPath: /csi - - name: pods-mount-dir - mountPath: /var/lib/kubelet - # needed so that any mounts setup inside this container are - # propagated back to the host machine. - mountPropagation: "Bidirectional" - - mountPath: /dev - name: device-dir - volumes: - - name: linode-info - emptyDir: {} - - name: get-linode-id - configMap: - name: get-linode-id - defaultMode: 493 - - name: registration-dir - hostPath: - path: /var/lib/kubelet/plugins_registry/ - type: DirectoryOrCreate - - name: kubelet-dir - hostPath: - path: /var/lib/kubelet - type: Directory - - name: plugin-dir - hostPath: - path: /var/lib/kubelet/plugins/linodebs.csi.linode.com - type: DirectoryOrCreate - - name: pods-mount-dir - hostPath: - path: /var/lib/kubelet - type: Directory - - name: device-dir - hostPath: - path: /dev - # The following mounts are required to trigger host udevadm from container - - name: udev-rules-etc - hostPath: - path: /etc/udev - type: Directory - - name: udev-rules-lib - hostPath: - path: /lib/udev - type: Directory - - name: udev-socket - hostPath: - path: /run/udev - type: Directory - - name: sys - hostPath: - path: /sys - type: Directory ---- -# pkg/linode-bs/deploy/kubernetes/08-cm-get-linode-id.yaml -apiVersion: v1 -kind: ConfigMap -metadata: - name: get-linode-id - namespace: kube-system - labels: - app: csi-linode -data: - get-linode-id.sh: |- - #!/bin/bash -efu - id="$(kubectl get node/"${NODE_NAME}" -o jsonpath='{.spec.providerID}')" - if [[ ! -z "${id}" ]]; then - echo "${id}" - echo -n "${id:9}" > /linode-info/linode-id - exit 0 - fi - echo "Provider ID not found" - # Exit here so that we wait for the CCM to initialize the provider ID - exit 1 From aabbf8433e5e6d28ab1b6eecef1e8449b3c8c57d Mon Sep 17 00:00:00 2001 From: phillc <15082+phillc@users.noreply.github.com> Date: Thu, 27 Aug 2020 09:42:57 -0400 Subject: [PATCH 17/24] Update linodego for page_size --- go.mod | 7 ++---- go.sum | 37 +++++++++++++++--------------- pkg/linode-bs/driver_test.go | 12 ++++------ pkg/linode-client/linode-client.go | 4 +--- 4 files changed, 25 insertions(+), 35 deletions(-) diff --git a/go.mod b/go.mod index 210a1dd2..c7bdbdd0 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,6 @@ require ( github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 // indirect github.com/container-storage-interface/spec v1.1.0 github.com/davecgh/go-spew v1.1.1 // indirect - github.com/dnaeon/go-vcr v0.0.0-20180920040454-5637cf3d8a31 // indirect github.com/docker/distribution v2.6.2+incompatible // indirect github.com/gogo/protobuf v1.1.1 // indirect github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b @@ -18,7 +17,7 @@ require ( github.com/hashicorp/golang-lru v0.5.0 // indirect github.com/json-iterator/go v1.1.6 // indirect github.com/kubernetes-csi/csi-test v2.0.0+incompatible - github.com/linode/linodego v0.10.0 + github.com/linode/linodego v0.21.0 github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.1 // indirect @@ -36,13 +35,11 @@ require ( github.com/stretchr/objx v0.1.1 // indirect github.com/stretchr/testify v1.3.0 // indirect golang.org/x/crypto v0.0.0-20190422183909-d864b10871cd // indirect - golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 - golang.org/x/oauth2 v0.0.0-20181120190819-8f65e3013eba // indirect + golang.org/x/net v0.0.0-20190628185345-da137c7871d7 golang.org/x/sync v0.0.0-20190423024810-112230192c58 // indirect golang.org/x/time v0.0.0-20181108054448-85acf8d2951c // indirect google.golang.org/grpc v1.16.0 gopkg.in/inf.v0 v0.9.1 // indirect - gopkg.in/resty.v1 v1.10.2 // indirect gopkg.in/yaml.v2 v2.3.0 // indirect k8s.io/api v0.0.0-20181121071145-b7bd5f2d334c // indirect k8s.io/apiextensions-apiserver v0.0.0-20181123033937-b8ea0ae3837a // indirect diff --git a/go.sum b/go.sum index 81fcf78e..5091f7c1 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,5 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= @@ -7,13 +8,12 @@ github.com/container-storage-interface/spec v1.1.0/go.mod h1:6URME8mwIBbpVyZV93C github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dnaeon/go-vcr v0.0.0-20180814043457-aafff18a5cc2/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= -github.com/dnaeon/go-vcr v0.0.0-20180920040454-5637cf3d8a31 h1:Dzuw9GtbmllUqEcoHfScT9YpKFUssSiZ5PgZkIGf/YQ= -github.com/dnaeon/go-vcr v0.0.0-20180920040454-5637cf3d8a31/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= github.com/docker/distribution v2.6.2+incompatible h1:4FI6af79dfCS/CYb+RRtkSHw3q1L/bnDjG1PcPZtQhM= github.com/docker/distribution v2.6.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/go-resty/resty/v2 v2.1.1-0.20191201195748-d7b97669fe48 h1:JVrqSeQfdhYRFk24TvhTZWU0q8lfCojxZQFi3Ou7+uY= +github.com/go-resty/resty/v2 v2.1.1-0.20191201195748-d7b97669fe48/go.mod h1:dZGr0i9PLlaaTD4H/hoZIDjQ+r6xq8mgbRzHZf7f2J8= github.com/gogo/protobuf v1.1.1 h1:72R+M5VuhED/KujmZVcIquuo8mBgX4oVda//DQb3PXo= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= @@ -26,6 +26,8 @@ github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c h1:964Od4U6p2jUkFxvCydnIczKteheJEzHRToSGK3Bnlw= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf h1:+RRA9JqSOZFfKrOeqr2z77+8R2RKyh8PG66dcu1V0ck= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/uuid v1.0.0 h1:b4Gk+7WdP/d3HZH8EJsZpvV7EtDOgaZLtnaNGIu1adA= @@ -43,15 +45,10 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kubernetes-csi/csi-test v2.0.0+incompatible h1:ia04uVFUM/J9n/v3LEMn3rEG6FmKV5BH9QLw7H68h44= github.com/kubernetes-csi/csi-test v2.0.0+incompatible/go.mod h1:YxJ4UiuPWIhMBkxUKY5c267DyA0uDZ/MtAimhx/2TA0= -github.com/linode/linodego v0.10.0 h1:AMdb82HVgY8o3mjBXJcUv9B+fnJjfDMn2rNRGbX+jvM= -github.com/linode/linodego v0.10.0/go.mod h1:cziNP7pbvE3mXIPneHj0oRY8L1WtGEIKlZ8LANE4eXA= +github.com/linode/linodego v0.21.0 h1:XykohqzVIV6hvjBn03cj7FGxYARFSrlfJodQrtHynqk= +github.com/linode/linodego v0.21.0/go.mod h1:UTpq1JUZD0CZsJ8rt+0CRkqbzrp1MbGakVPt2DXY5Mk= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= @@ -92,17 +89,20 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20190422183909-d864b10871cd h1:sMHc2rZHuzQmrbVoSpt9HgerkXPyIeCSO6k0zUMGfFk= golang.org/x/crypto v0.0.0-20190422183909-d864b10871cd/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/net v0.0.0-20180611182652-db08ff08e862/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181011144130-49bb7cea24b1/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190628185345-da137c7871d7 h1:rTIdg5QFRR7XCaK4LCjBiPbx8j4DQRpdYMnGn/bJUEU= +golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20181120190819-8f65e3013eba h1:YDkOrzGLLYybtuP6ZgebnO4OWYEYVMFSniazXsxrFN8= -golang.org/x/oauth2 v0.0.0-20181120190819-8f65e3013eba/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -116,23 +116,22 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c h1:fqgJT0MGcGpPgpWU7VRdRjuArfcOvC4AoJmILihzhDg= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0 h1:igQkv0AAhEIvTEpD5LIpAfav2eeVO9HBTjvKHVJPRSs= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/grpc v1.16.0 h1:dz5IJGuC2BB7qXR5AyHNwAUBhZscK2xVez7mznh72sY= google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= -gopkg.in/resty.v1 v1.9.1/go.mod h1:vo52Hzryw9PnPHcJfPsBiFW62XhNx5OczbV9y+IMpgc= -gopkg.in/resty.v1 v1.10.2 h1:0kn7/nSP3fjAddBOjnYDq0rmyvVFvuk4iFtWQUWptjc= -gopkg.in/resty.v1 v1.10.2/go.mod h1:nrgQYbPhkRfn2BfT32NNTLfq3K9NuHRB0MsAcA9weWY= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= diff --git a/pkg/linode-bs/driver_test.go b/pkg/linode-bs/driver_test.go index 8611545c..149f9635 100644 --- a/pkg/linode-bs/driver_test.go +++ b/pkg/linode-bs/driver_test.go @@ -12,7 +12,7 @@ import ( linodeclient "github.com/linode/linode-blockstorage-csi-driver/pkg/linode-client" "github.com/linode/linode-blockstorage-csi-driver/pkg/metadata" - "github.com/linode/linode-blockstorage-csi-driver/pkg/mount-manager" + mountmanager "github.com/linode/linode-blockstorage-csi-driver/pkg/mount-manager" "strconv" @@ -54,8 +54,6 @@ func TestDriverSuite(t *testing.T) { ID: 123, Status: "running", Hypervisor: "kvm", - CreatedStr: "2018-01-01T00:01:01", - UpdatedStr: "2018-01-01T00:01:01", }, } @@ -242,6 +240,7 @@ func (f *fakeAPI) ServeHTTP(w http.ResponseWriter, r *http.Request) { id := rand.Intn(99999) name := v.Label path := fmt.Sprintf("/dev/disk/by-id/scsi-0Linode_Volume_%v", name) + now := time.Now() vol = linodego.Volume{ ID: id, Region: v.Region, @@ -249,11 +248,8 @@ func (f *fakeAPI) ServeHTTP(w http.ResponseWriter, r *http.Request) { Size: v.Size, FilesystemPath: path, Status: linodego.VolumeActive, - Created: time.Now(), - Updated: time.Now(), - - CreatedStr: time.Now().Format("2006-01-02T15:04:05"), - UpdatedStr: time.Now().Format("2006-01-02T15:04:05"), + Created: &now, + Updated: &now, } f.volumes[strconv.Itoa(id)] = vol diff --git a/pkg/linode-client/linode-client.go b/pkg/linode-client/linode-client.go index 1d7a1969..b2eb87c8 100644 --- a/pkg/linode-client/linode-client.go +++ b/pkg/linode-client/linode-client.go @@ -2,7 +2,6 @@ package linodeclient import ( "context" - "fmt" "github.com/linode/linodego" ) @@ -26,8 +25,7 @@ type LinodeClient interface { ResizeVolume(context.Context, int, int) error } -func NewLinodeClient(token, uaPrefix string, url string) *linodego.Client { - ua := fmt.Sprintf("%s linodego/%s", uaPrefix, linodego.Version) +func NewLinodeClient(token, ua string, url string) *linodego.Client { // Use linodego built-in http client which supports setting root CA cert linodeClient := linodego.NewClient(nil) linodeClient.SetUserAgent(ua) From 4391d5e5edd7a9555bfb7b78caa3abed3ea189ab Mon Sep 17 00:00:00 2001 From: phillc <15082+phillc@users.noreply.github.com> Date: Mon, 31 Aug 2020 16:54:53 -0400 Subject: [PATCH 18/24] update csi-test - I saw a few changelog entries around MaxEntries and pagination --- go.mod | 17 +++------ go.sum | 74 +++++++++++++++++++++++++++--------- pkg/linode-bs/driver_test.go | 9 ++--- 3 files changed, 63 insertions(+), 37 deletions(-) diff --git a/go.mod b/go.mod index c7bdbdd0..71c03edc 100644 --- a/go.mod +++ b/go.mod @@ -2,43 +2,36 @@ module github.com/linode/linode-blockstorage-csi-driver require ( github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 // indirect - github.com/container-storage-interface/spec v1.1.0 - github.com/davecgh/go-spew v1.1.1 // indirect + github.com/container-storage-interface/spec v1.2.0 github.com/docker/distribution v2.6.2+incompatible // indirect github.com/gogo/protobuf v1.1.1 // indirect github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b github.com/golang/groupcache v0.0.0-20181024230925-c65c006176ff // indirect - github.com/golang/protobuf v1.2.0 + github.com/golang/protobuf v1.3.2 github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c // indirect github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf // indirect - github.com/google/uuid v1.1.1 // indirect github.com/googleapis/gnostic v0.2.0 // indirect github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f // indirect github.com/hashicorp/golang-lru v0.5.0 // indirect github.com/json-iterator/go v1.1.6 // indirect - github.com/kubernetes-csi/csi-test v2.0.0+incompatible + github.com/kubernetes-csi/csi-test/v3 v3.1.1 github.com/linode/linodego v0.21.0 github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.1 // indirect - github.com/onsi/ginkgo v1.7.0 // indirect - github.com/onsi/gomega v1.4.3 // indirect github.com/pborman/uuid v1.2.0 // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/prometheus/client_golang v0.9.1 // indirect - github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 // indirect github.com/prometheus/common v0.0.0-20181120120127-aeab699e26f4 // indirect github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d // indirect github.com/spf13/afero v1.1.2 // indirect github.com/spf13/pflag v1.0.3 // indirect github.com/stevvooe/resumable v0.0.0-20180830230917-22b14a53ba50 // indirect - github.com/stretchr/objx v0.1.1 // indirect github.com/stretchr/testify v1.3.0 // indirect golang.org/x/crypto v0.0.0-20190422183909-d864b10871cd // indirect - golang.org/x/net v0.0.0-20190628185345-da137c7871d7 - golang.org/x/sync v0.0.0-20190423024810-112230192c58 // indirect + golang.org/x/net v0.0.0-20191112182307-2180aed22343 golang.org/x/time v0.0.0-20181108054448-85acf8d2951c // indirect - google.golang.org/grpc v1.16.0 + google.golang.org/grpc v1.25.1 gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.3.0 // indirect k8s.io/api v0.0.0-20181121071145-b7bd5f2d334c // indirect diff --git a/go.sum b/go.sum index 5091f7c1..9ecb71bd 100644 --- a/go.sum +++ b/go.sum @@ -1,15 +1,19 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/container-storage-interface/spec v1.1.0 h1:qPsTqtR1VUPvMPeK0UnCZMtXaKGyyLPG8gj/wG6VqMs= -github.com/container-storage-interface/spec v1.1.0/go.mod h1:6URME8mwIBbpVyZV93Ce5St17xBiQJQY67NDsuohiy4= +github.com/container-storage-interface/spec v1.2.0 h1:bD9KIVgaVKKkQ/UbVUY9kCaH/CJbhNxe0eeB4JeJV2s= +github.com/container-storage-interface/spec v1.2.0/go.mod h1:6URME8mwIBbpVyZV93Ce5St17xBiQJQY67NDsuohiy4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/docker/distribution v2.6.2+incompatible h1:4FI6af79dfCS/CYb+RRtkSHw3q1L/bnDjG1PcPZtQhM= github.com/docker/distribution v2.6.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/go-resty/resty/v2 v2.1.1-0.20191201195748-d7b97669fe48 h1:JVrqSeQfdhYRFk24TvhTZWU0q8lfCojxZQFi3Ou7+uY= @@ -20,12 +24,15 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekf github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20181024230925-c65c006176ff h1:kOkM9whyQYodu09SJ6W3NCsHG7crFaJILQ22Gozp3lg= github.com/golang/groupcache v0.0.0-20181024230925-c65c006176ff/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c h1:964Od4U6p2jUkFxvCydnIczKteheJEzHRToSGK3Bnlw= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf h1:+RRA9JqSOZFfKrOeqr2z77+8R2RKyh8PG66dcu1V0ck= @@ -44,9 +51,10 @@ github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kubernetes-csi/csi-test v2.0.0+incompatible h1:ia04uVFUM/J9n/v3LEMn3rEG6FmKV5BH9QLw7H68h44= -github.com/kubernetes-csi/csi-test v2.0.0+incompatible/go.mod h1:YxJ4UiuPWIhMBkxUKY5c267DyA0uDZ/MtAimhx/2TA0= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kubernetes-csi/csi-test/v3 v3.1.1 h1:mFxPbUf7pti663WTCsfaT3YRPVIzy0yLx8HWbVKfN4I= +github.com/kubernetes-csi/csi-test/v3 v3.1.1/go.mod h1:UWxYP5cDlD6iSNVKEiLFqfJnJinuhtI7MLt61rQQOfI= github.com/linode/linodego v0.21.0 h1:XykohqzVIV6hvjBn03cj7FGxYARFSrlfJodQrtHynqk= github.com/linode/linodego v0.21.0/go.mod h1:UTpq1JUZD0CZsJ8rt+0CRkqbzrp1MbGakVPt2DXY5Mk= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= @@ -56,10 +64,10 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs= -github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU= -github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/ginkgo v1.10.3 h1:OoxbjfXVZyod1fmWYhI7SEyaD8B00ynP3T+D5GiyHOY= +github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v1.7.1 h1:K0jcRCwNQM3vFGh1ppMtDh/+7ApJrjldlX8fA0jDTLQ= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= @@ -68,12 +76,14 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.9.1 h1:K47Rk0v/fkEfwfQet2KWhscE0cJzjgCCDBG2KHZoVno= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 h1:idejC8f05m9MGOsuEi1ATq9shN03HrxNkD/luQvxCv8= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.0.0-20181120120127-aeab699e26f4 h1:JN8iUqOgmRYninFWhPhdVhcxlJez35ZKpjibROwPiNA= github.com/prometheus/common v0.0.0-20181120120127-aeab699e26f4/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d h1:GoAlyOgbOEIFdaDqxJVlbOQ1DtGmZWs/Qau0hIlk+WQ= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/robertkrimen/otto v0.0.0-20191219234010-c382bd3c16ff/go.mod h1:xvqspoSXJTIpemEonrMDFq6XzwHYYgToXWj5eRX1OtY= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= @@ -83,25 +93,34 @@ github.com/stevvooe/resumable v0.0.0-20180830230917-22b14a53ba50/go.mod h1:1pdIZ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190422183909-d864b10871cd h1:sMHc2rZHuzQmrbVoSpt9HgerkXPyIeCSO6k0zUMGfFk= golang.org/x/crypto v0.0.0-20190422183909-d864b10871cd/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190628185345-da137c7871d7 h1:rTIdg5QFRR7XCaK4LCjBiPbx8j4DQRpdYMnGn/bJUEU= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191112182307-2180aed22343 h1:00ohfJ4K98s3m6BGUoBd8nyfp4Yl0GoIKvw5abItTjI= +golang.org/x/net v0.0.0-20191112182307-2180aed22343/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -111,11 +130,21 @@ golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191113165036-4c7a9d0fe056 h1:dHtDnRWQtSx0Hjq9kvKFpBh9uPPKfQN70NZZmvssGwk= +golang.org/x/sys v0.0.0-20191113165036-4c7a9d0fe056/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c h1:fqgJT0MGcGpPgpWU7VRdRjuArfcOvC4AoJmILihzhDg= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0 h1:igQkv0AAhEIvTEpD5LIpAfav2eeVO9HBTjvKHVJPRSs= @@ -124,21 +153,28 @@ google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO50 google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/grpc v1.16.0 h1:dz5IJGuC2BB7qXR5AyHNwAUBhZscK2xVez7mznh72sY= -google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20191114150713-6bbd007550de h1:dFEMUWudT9iV1JMk6i6NwbfIw2V/2VDFyDYCZFypRxE= +google.golang.org/genproto v0.0.0-20191114150713-6bbd007550de/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1 h1:wdKvqQk7IttEw92GoRyKG2IDrUIpgpj6H6m81yfeMW0= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/sourcemap.v1 v1.0.5/go.mod h1:2RlvNNSMglmRrcvhfuzp4hQHwOtjxlbjX7UPY/GXb78= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= k8s.io/api v0.0.0-20181121071145-b7bd5f2d334c h1:aSW17ws1n3Y/gxcAggEFSs+UJlzpE3+stTPLQSiVEno= k8s.io/api v0.0.0-20181121071145-b7bd5f2d334c/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA= k8s.io/apiextensions-apiserver v0.0.0-20181123033937-b8ea0ae3837a h1:xXTIgv/BSwLchnzhGTsKn3LcIeUubWhnbqXRwst2TLo= diff --git a/pkg/linode-bs/driver_test.go b/pkg/linode-bs/driver_test.go index 149f9635..bf67e985 100644 --- a/pkg/linode-bs/driver_test.go +++ b/pkg/linode-bs/driver_test.go @@ -19,7 +19,7 @@ import ( "fmt" "strings" - "github.com/kubernetes-csi/csi-test/pkg/sanity" + "github.com/kubernetes-csi/csi-test/v3/pkg/sanity" "github.com/linode/linodego" ) @@ -76,11 +76,8 @@ func TestDriverSuite(t *testing.T) { go linodeDriver.Run(endpoint) - cfg := &sanity.Config{ - TargetPath: os.TempDir() + "/csi-target", - StagingPath: os.TempDir() + "/csi-staging", - Address: endpoint, - } + cfg := sanity.NewTestConfig() + cfg.Address = endpoint sanity.Test(t, cfg) } From 46ec408087322a42f072d44cbcc548c3afae8b2d Mon Sep 17 00:00:00 2001 From: phillc <15082+phillc@users.noreply.github.com> Date: Tue, 1 Sep 2020 10:29:12 -0400 Subject: [PATCH 19/24] Update pagination of volumes - CSI test was flopping on test that is actually disabled in newer csi-test version - max entries dictates page size, and auto assume next page is next token --- pkg/linode-bs/controllerserver.go | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/pkg/linode-bs/controllerserver.go b/pkg/linode-bs/controllerserver.go index 8eef9b6d..6d78f858 100644 --- a/pkg/linode-bs/controllerserver.go +++ b/pkg/linode-bs/controllerserver.go @@ -348,6 +348,10 @@ func (linodeCS *LinodeControllerServer) ListVolumes(ctx context.Context, req *cs nextToken := "" listOpts := linodego.NewListOptions(0, "") + if req.GetMaxEntries() > 0 { + listOpts.PageSize = int(req.GetMaxEntries()) + } + if startingToken != "" { startingPage, errParse := strconv.ParseInt(startingToken, 10, 64) if errParse != nil { @@ -358,10 +362,6 @@ func (linodeCS *LinodeControllerServer) ListVolumes(ctx context.Context, req *cs nextToken = strconv.Itoa(listOpts.Page + 1) } - if req.GetMaxEntries() > 0 { - nextToken = strconv.Itoa(int(req.GetMaxEntries())) - } - glog.V(4).Infoln("list volumes called", map[string]interface{}{ "list_opts": listOpts, "req_starting_token": req.StartingToken, @@ -374,10 +374,6 @@ func (linodeCS *LinodeControllerServer) ListVolumes(ctx context.Context, req *cs if err != nil { return nil, err } - if listOpts.Page > len(volumes) { - return nil, status.Error(codes.Aborted, "Starting token is greater than total number of vols") - } - var entries []*csi.ListVolumesResponse_Entry for _, vol := range volumes { key := common.CreateLinodeVolumeKey(vol.ID, vol.Label) @@ -395,10 +391,6 @@ func (linodeCS *LinodeControllerServer) ListVolumes(ctx context.Context, req *cs }, }, }) - if len(entries) == int(req.MaxEntries) { - nextToken = strconv.Itoa(int(req.MaxEntries)) - break - } } resp := &csi.ListVolumesResponse{ From 09075f52fc5471e2b1eb8bd4cde104d3248d2efd Mon Sep 17 00:00:00 2001 From: phillc <15082+phillc@users.noreply.github.com> Date: Tue, 1 Sep 2020 12:45:06 -0400 Subject: [PATCH 20/24] Update go version in travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 37f1caf3..ccce4a36 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ env: - GO111MODULE=on go: - - 1.11.5 + - 1.13.x - tip cache: From 1c769f63e251a3feb752d01e631b87de4380baec Mon Sep 17 00:00:00 2001 From: phillc <15082+phillc@users.noreply.github.com> Date: Tue, 1 Sep 2020 13:40:49 -0400 Subject: [PATCH 21/24] Remove overalls from travis - that integration hasn't been working - intent to replace in the future --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ccce4a36..a43d6ff1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,5 +33,3 @@ script: - make test - make docker-build - golangci-lint run - - travis_wait 20 roveralls -ignore e2e - - goveralls -coverprofile=roveralls.coverprofile -service=travis-ci -ignore=csi_driver_test.go,e2e_suite_test.go From 6255b8c85a21960a237f208a6deff45f6f3f1d7d Mon Sep 17 00:00:00 2001 From: phillc <15082+phillc@users.noreply.github.com> Date: Tue, 1 Sep 2020 15:59:17 -0400 Subject: [PATCH 22/24] csi-test v3 enforces idempotency --- pkg/linode-bs/controllerserver.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/pkg/linode-bs/controllerserver.go b/pkg/linode-bs/controllerserver.go index 6d78f858..696c267f 100644 --- a/pkg/linode-bs/controllerserver.go +++ b/pkg/linode-bs/controllerserver.go @@ -208,12 +208,9 @@ func (linodeCS *LinodeControllerServer) ControllerPublishVolume(ctx context.Cont } return nil, status.Error(codes.Internal, err.Error()) } else if volume.LinodeID != nil { - /** - TODO(displague) existing volume on node is not ok unless checking publish caps are identical if *volume.LinodeID == linodeID { return &csi.ControllerPublishVolumeResponse{}, nil } - **/ return nil, status.Error(codes.AlreadyExists, fmt.Sprintf("Volume with id %d already attached to node %d", volumeID, *volume.LinodeID)) } From 7b304eeeba3ea01b7e227e7169c5e821d2aba5a6 Mon Sep 17 00:00:00 2001 From: phillc <15082+phillc@users.noreply.github.com> Date: Tue, 1 Sep 2020 16:31:10 -0400 Subject: [PATCH 23/24] Remove guard on 404 while looking for volume --- pkg/linode-bs/controllerserver.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/pkg/linode-bs/controllerserver.go b/pkg/linode-bs/controllerserver.go index 696c267f..e113fad4 100644 --- a/pkg/linode-bs/controllerserver.go +++ b/pkg/linode-bs/controllerserver.go @@ -468,9 +468,6 @@ func (linodeCS *LinodeControllerServer) ControllerExpandVolume(ctx context.Conte var vol *linodego.Volume if vol, err = linodeCS.CloudProvider.GetVolume(ctx, volumeID); err != nil { - if apiErr, ok := err.(*linodego.Error); ok && apiErr.Code == 404 { - return &csi.ControllerExpandVolumeResponse{}, nil - } return nil, status.Error(codes.Internal, err.Error()) } From 13b22e1537dda177de058fbf168ecdcf2dfe84d3 Mon Sep 17 00:00:00 2001 From: phillc <15082+phillc@users.noreply.github.com> Date: Tue, 1 Sep 2020 17:14:53 -0400 Subject: [PATCH 24/24] Lock mutex on write, and read value --- pkg/linode-bs/driver.go | 2 ++ pkg/linode-bs/identityserver.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/linode-bs/driver.go b/pkg/linode-bs/driver.go index be7f61e8..deabb6e3 100644 --- a/pkg/linode-bs/driver.go +++ b/pkg/linode-bs/driver.go @@ -181,7 +181,9 @@ func (linodeDriver *LinodeDriver) Run(endpoint string) { glog.V(4).Infof("BS Volume Prefix: %v", linodeDriver.bsPrefix) } + linodeDriver.readyMu.Lock() linodeDriver.ready = true + linodeDriver.readyMu.Unlock() //Start the nonblocking GRPC s := NewNonBlockingGRPCServer() diff --git a/pkg/linode-bs/identityserver.go b/pkg/linode-bs/identityserver.go index 6f8cf254..a2aaa43b 100644 --- a/pkg/linode-bs/identityserver.go +++ b/pkg/linode-bs/identityserver.go @@ -77,7 +77,7 @@ func (linodeIdentity *LinodeIdentityServer) Probe(ctx context.Context, req *csi. return &csi.ProbeResponse{ Ready: &wrappers.BoolValue{ - Value: true, + Value: linodeIdentity.Driver.ready, }, }, nil }