Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fixes for v0.6 #1

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions deploy/csi-ecfsplugin-attacher.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ spec:

---
kind: StatefulSet
apiVersion: apps/v1beta1
apiVersion: apps/v1
metadata:
name: csi-ecfsplugin-attacher
spec:
serviceName: "csi-ecfsplugin-attacher"
replicas: 1
selector:
matchLabels:
app: "csi-ecfsplugin-attacher"
template:
metadata:
labels:
Expand All @@ -27,7 +30,7 @@ spec:
serviceAccount: csi-attacher
containers:
- name: csi-ecfsplugin-attacher
image: gcr.io/gke-release/csi-attacher:v1.0.1-gke.0
image: gcr.io/gke-release/csi-attacher:v2.2.0-gke.0
args:
- "--v=10"
# - "--v=5"
Expand Down
7 changes: 5 additions & 2 deletions deploy/csi-ecfsplugin-provisioner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ spec:

---
kind: StatefulSet
apiVersion: apps/v1beta1
apiVersion: apps/v1
metadata:
name: csi-ecfsplugin-provisioner
spec:
serviceName: "csi-ecfsplugin-provisioner"
replicas: 1
selector:
matchLabels:
app: "csi-ecfsplugin-provisioner"
template:
metadata:
labels:
Expand All @@ -27,7 +30,7 @@ spec:
serviceAccount: csi-provisioner
containers:
- name: csi-provisioner
image: gcr.io/gke-release/csi-provisioner:v1.0.1-gke.0
image: gcr.io/gke-release/csi-provisioner:v1.6.0-gke.0
args:
- "--provisioner=csi-ecfsplugin"
- "--csi-address=$(ADDRESS)"
Expand Down
6 changes: 3 additions & 3 deletions deploy/snapshotclass.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apiVersion: snapshot.storage.k8s.io/v1alpha1
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotClass
metadata:
name: csi-ecfs-snapclass
snapshotter: csi-ecfsplugin
driver: csi-ecfsplugin
deletionPolicy: Delete
parameters:
retention: "4"

2 changes: 1 addition & 1 deletion deploy/teardown-plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ done

popd

# Delete CRDs crated by external-snapshotter
# Delete CRDs created by external-snapshotter
exec_cmd kubectl delete crd volumesnapshotclasses.snapshot.storage.k8s.io volumesnapshotcontents.snapshot.storage.k8s.io volumesnapshots.snapshot.storage.k8s.io
4 changes: 2 additions & 2 deletions deploy/templates/csi-attacher-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ metadata:
rules:
- apiGroups: [""]
resources: ["persistentvolumes"]
verbs: ["get", "list", "watch", "update"]
verbs: ["get", "list", "watch", "update", "patch"]
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get", "list", "watch"]
Expand All @@ -31,7 +31,7 @@ rules:
verbs: ["get", "list", "watch"]
- apiGroups: ["storage.k8s.io"]
resources: ["volumeattachments"]
verbs: ["get", "list", "watch", "update"]
verbs: ["get", "list", "watch", "update", "patch"]

---
kind: ClusterRoleBinding
Expand Down
2 changes: 1 addition & 1 deletion deploy/templates/csi-ecfsplugin.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
kind: DaemonSet
apiVersion: apps/v1beta2
apiVersion: apps/v1
metadata:
name: csi-ecfsplugin
spec:
Expand Down
5 changes: 4 additions & 1 deletion deploy/templates/csi-snapshotter-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ rules:
verbs: ["get", "list", "watch"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshotcontents"]
verbs: ["create", "get", "list", "watch", "update", "delete"]
verbs: ["create", "get", "list", "watch", "update", "delete", "patch"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshotcontents/status"]
verbs: ["update", "patch"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshots"]
verbs: ["get", "list", "watch", "update"]
Expand Down
6 changes: 3 additions & 3 deletions deploy/templates/csi-snapshotter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ spec:
---
# TODO: It is recommended that sidecar containers External-Snapshotter and External-Provisioner be deployed together with CSI driver in a StatefulSet.
kind: StatefulSet
apiVersion: apps/v1beta1
apiVersion: apps/v1
metadata:
name: csi-snapshotter
spec:
Expand All @@ -60,10 +60,10 @@ spec:
serviceAccount: csi-snapshotter
containers:
- name: csi-snapshotter
image: quay.io/k8scsi/csi-snapshotter:v1.0.1
image: gcr.io/gke-release/csi-snapshotter:v2.1.1-gke.0
args:
- "--csi-address=$(ADDRESS)"
- "--connection-timeout=15s"
- "--timeout=1m"
# - "--v=5"
- "--v=10"
env:
Expand Down
3 changes: 2 additions & 1 deletion deploy/templates/storageclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ parameters: # Note - only string values are accepted in parameters
permissions: "777"
# Default volume size
defaultVolumeSize: "100GiB"

# Volume access. Supported values: read_write, read_only, list_only, no_access
access: "read_write"
# Volume capacity percentage to be used as the soft quota. Default: 100
softQuotaPct: "75"

# === eFaaS options ===

Expand Down
2 changes: 1 addition & 1 deletion docs/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ $ PLUGIN_TAG=v0.0.1 make all

### Dependency management

This project uses [dep](https://github.com/golang/dep) as it dependency management tool.
This project uses [dep](https://github.com/golang/dep) as its dependency management tool.

After cloning the project, it is recommended to run `dep ensure`.

Expand Down
25 changes: 25 additions & 0 deletions examples/collect-all-logs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

: ${NAMESPACE:="elastifile-csi"}
: ${LOGDIR:="/tmp/csi-logs-"$(date +%s)}
: ${TARBALL:="/tmp/csi-logs.tgz"}
: ${LOGSCRIPT:="${LOGDIR}/fetch-logs.sh"}

mkdir -p ${LOGDIR}
pushd ${LOGDIR}

export NAMESPACE
kubectl get pod -n ${NAMESPACE} -o go-template='{{range .items}}{{$podName := .metadata.name}}{{range .status.containerStatuses}}{{if ge .restartCount 1}}{{print "kubectl logs -p " $podName " -c " .name " -n $NAMESPACE > " $podName "--" .name "-prev.log\n"}}{{end}}{{end}}{{end}}' > ${LOGSCRIPT}
kubectl get pod -n ${NAMESPACE} -o go-template='{{range .items}}{{$podName := .metadata.name}}{{range .status.containerStatuses}}{{print "kubectl logs " $podName " -c " .name " -n $NAMESPACE > " $podName "--" .name ".log\n"}}{{end}}{{end}}' >> ${LOGSCRIPT}

bash -x ${LOGSCRIPT}

cd ..
tar czvf ${TARBALL} $(basename ${LOGDIR})

popd

rm -rf ${LOGDIR}

echo Done - logs were saved as ${TARBALL}

8 changes: 8 additions & 0 deletions examples/demo-job.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

MYPATH=$(dirname $0)
source ${MYPATH}/../deploy/functions.sh

assert_cmd ${MYPATH}/create-job.sh
assert_cmd ${MYPATH}/delete-job.sh

7 changes: 3 additions & 4 deletions examples/snapshot.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
apiVersion: snapshot.storage.k8s.io/v1alpha1
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
name: demo-snap
spec:
snapshotClassName: csi-ecfs-snapclass
volumeSnapshotClassName: csi-ecfs-snapclass
source:
name: demo-pvc
kind: PersistentVolumeClaim
persistentVolumeClaimName: demo-pvc
5 changes: 3 additions & 2 deletions images/plugin/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:16.04
FROM ubuntu:18.04
LABEL maintainers="[email protected]"
LABEL description="Elastifile CSI Plugin"

Expand All @@ -10,6 +10,7 @@ RUN apt-get update && \
apt-get -y install nfs-common telnet curl

RUN chmod +x /ecfsplugin && \
mkdir -p /var/log/elastifile
mkdir -p /var/log/elastifile && \
mkdir -p /run/sendsigs.omit.d

ENTRYPOINT ["/entrypoint.sh", "/ecfsplugin"]
15 changes: 9 additions & 6 deletions src/ecfs/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,17 @@ func (c *VolumeCache) Get(volumeName string) (cachedVolume *CachedVolume, cacheH

func (c *VolumeCache) Set(volumeName string, isReady bool, operationFailure error) (err error) {
if *c == nil {
*c = make(VolumeCache)
glog.V(log.TRACE).Infof("ecfs: Creating persistent resource for volume %v in Set", volumeName)
err = c.Create(volumeName)
if err != nil {
return errors.WrapPrefix(err, fmt.Sprintf(
"Failed to create volume cache entry in Set. Volume=%v to isReady=%v operationFailure=%v",
volumeName, isReady, operationFailure), 0)
}
}

(*c)[volumeName] = &CachedVolume{
ID: volumeName,
Error: operationFailure,
IsReady: isReady,
}
(*c)[volumeName].IsReady = isReady
(*c)[volumeName].Error = operationFailure

err = (*c)[volumeName].persistentResource.KeepAlive()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion src/ecfs/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func getCreateVolumeResponse(volumeId volumeHandleType, volOptions *volumeOption
return &csi.CreateVolumeResponse{
Volume: &csi.Volume{
VolumeId: string(volumeId),
CapacityBytes: int64(volOptions.Capacity),
CapacityBytes: volOptions.Capacity,
VolumeContext: req.GetParameters(),
},
}
Expand Down
2 changes: 1 addition & 1 deletion src/ecfs/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
)

const (
Version = "0.6.1"
Version = "0.6.5"
)

type ecfsDriver struct {
Expand Down
2 changes: 1 addition & 1 deletion src/ecfs/emanage-helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (ems *emanageClient) GetClient() *emanageClient {
}

func (ems *emanageClient) GetDcByName(dcName string) (*emanage.DataContainer, error) {
glog.V(log.DEBUG).Infof("ecfs: GetDcByName - getting DCs from ECFS management")
glog.V(log.DEBUG).Infof("ecfs: GetDcByName %v - getting DCs from ECFS management", dcName)
dcs, err := ems.GetClient().DataContainers.GetAll(nil)
if err != nil {
return nil, errors.WrapPrefix(err, "Failed to list Data Containers", 0)
Expand Down
15 changes: 6 additions & 9 deletions src/ecfs/mounter.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,7 @@ func getNfsExportEcfs(volId volumeHandleType) (nfsExport string, err error) {
return
}

var emsClient emanageClient
dc, export, err := emsClient.GetDcDefaultExportByVolumeId(volId)
if err != nil {
err = errors.WrapPrefix(err, fmt.Sprintf("Failed to get DC/export for Volume Id %s", volId), 0)
return
}

return fmt.Sprintf("%v:%v/%v", nfsAddr, dc.Name, export.Name), nil
return fmt.Sprintf("%v:%v/%v", nfsAddr, string(volId), volumeExportName), nil
}

func getNfsExportEfaas(volId volumeHandleType) (nfsExport string, err error) {
Expand Down Expand Up @@ -108,7 +101,11 @@ func mountEcfs(mountPoint string, volId volumeHandleType, mountFlags []string) (

err = mountNfs(args...)
if err != nil {
return errors.WrapPrefix(err, "Failed to mount ECFS export", 0)
if isErrorAlreadyMounted(err) && isWorkaround("b/153705643") {
glog.V(log.DEBUG).Infof("ecfs: Mount point %v is already mounted", mountPoint)
} else {
return errors.WrapPrefix(err, "Failed to mount ECFS export", 0)
}
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion src/ecfs/persistent_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,4 +306,4 @@ func (pr *PersistentResource) Delete() (err error) {
// TODO: Add background keepalive thread per resource being actively worked on

// TODO: Decide what to do with existing DCs whose volumes were deleted (e.g. due to existing data/snapshots)
// Deleting all snapshots and their exports makes sense, but existing data is something that needs PM's decision
// Deleting all snapshots and their exports makes sense, but existing data is something that needs PM's decision
14 changes: 14 additions & 0 deletions src/ecfs/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,20 @@ func isErrorDoesNotExist(err error) bool {
return false
}

func isErrorAlreadyMounted(err error) bool {
var errorMessages = []string{
"already mounted",
}

for _, text := range errorMessages {
if strings.Contains(err.Error(), text) {
glog.V(log.VERBOSE_DEBUG).Infof("ecfs: Error means that the path is already mounted: %v", err)
return true
}
}
return false
}

func isWorkaround(desc string) bool {
glog.Warningf("USING WORKAROUND FOR %v", desc)
return true
Expand Down
16 changes: 2 additions & 14 deletions src/ecfs/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,14 @@ func exportExists(emsClient *emanageClient, exportName string, opt *volumeOption

func createDc(emsClient *emanageClient, opt *volumeOptions) (*emanage.DataContainer, error) {
dc, err := emsClient.DataContainers.Create(string(opt.VolumeId), dcPolicy, &emanage.DcCreateOpts{
// TODO: Consider setting soft quota at a %% of capacity (to be set via storageclass)
SoftQuota: int(opt.Capacity),
HardQuota: int(opt.Capacity),
HardQuota: opt.Capacity,
SoftQuota: opt.Capacity * int64(opt.SoftQuotaPct) / 100,
DirPermissions: opt.ExportPermissions,
})
return &dc, err
}

func createExportForVolume(emsClient *emanageClient, volOptions *volumeOptions) (export emanage.Export, err error) {
found, export, err := exportExists(emsClient, volumeExportName, volOptions)
if err != nil {
err = errors.WrapPrefix(err, fmt.Sprintf("Failed to check if export %v exists on DC %v (%v)",
volumeExportName, volOptions.DataContainer.Id, volOptions.DataContainer.Name), 0)
return
}
if found {
glog.V(log.DEBUG).Infof("ecfs: Export %v for volume %v already exists - nothing to do", volumeExportName, volOptions.VolumeId)
return
}

exportOpt := &emanage.ExportCreateForVolumeOpts{
DcId: int(volOptions.DataContainer.Id),
Path: "/",
Expand Down
15 changes: 15 additions & 0 deletions src/ecfs/volumeoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package main

import (
"fmt"
"strconv"

"github.com/container-storage-interface/spec/lib/go/csi"
Expand Down Expand Up @@ -46,6 +47,7 @@ type volumeOptions struct {
ExportGid optional.Int
Access string // read_write/read_only/list_only/no_access
ClientRules string // [{"sourceRange": "all", "accessRights": "readWrite"}]
SoftQuotaPct int // Capacity percentage to be used as a soft quota
}

func extractOptionString(paramName StorageClassCustomParameter, options map[string]string) (value string, err error) {
Expand All @@ -70,6 +72,7 @@ const (
DefaultVolumeSize StorageClassCustomParameter = "defaultVolumeSize"
Access StorageClassCustomParameter = "access"
ClientRules StorageClassCustomParameter = "clientRules"
SoftQuotaPct StorageClassCustomParameter = "softQuotaPct"
)

// newVolumeOptions translates CreateVolumeRequest parameters to volumeOptions
Expand Down Expand Up @@ -174,6 +177,18 @@ func newVolumeOptions(req *csi.CreateVolumeRequest) (*volumeOptions, error) {
}
opts.ClientRules = paramStr

// SoftQuotaPct
if paramStr, err = extractOptionString(SoftQuotaPct, volParams); err != nil {
paramStr = "100"
}
if opts.SoftQuotaPct, err = strconv.Atoi(paramStr); err != nil {
return nil, errors.Wrap(err, 0)
}
if opts.SoftQuotaPct < 0 || opts.SoftQuotaPct > 100 {
return nil, errors.WrapPrefix(err, fmt.Sprintf(
"Invalid soft quota percentage: %v", opts.SoftQuotaPct), 0)
}

glog.V(log.DEBUG).Infof("ecfs: Current volume options: %+v", opts)
return opts, nil
}
Loading