diff --git a/pkg/cephfs/cephuser.go b/pkg/cephfs/cephuser.go index 57201cc6e..13ae53071 100644 --- a/pkg/cephfs/cephuser.go +++ b/pkg/cephfs/cephuser.go @@ -96,7 +96,7 @@ func createCephUser(volOptions *volumeOptions, adminCr *credentials, volId volum "osd", caps.Osd, } - if err := execCommandJson(&ents, "ceph", args[:]...); err != nil { + if err := execCommandJSON(&ents, "ceph", args[:]...); err != nil { return nil, fmt.Errorf("error creating ceph user: %v", err) } diff --git a/pkg/cephfs/driver.go b/pkg/cephfs/driver.go index 6995ab91c..d28b282dc 100644 --- a/pkg/cephfs/driver.go +++ b/pkg/cephfs/driver.go @@ -26,8 +26,10 @@ import ( ) const ( + // PluginFolder is the kubelet plugin directory for cephfs plugin PluginFolder = "/var/lib/kubelet/plugins/csi-cephfsplugin" - Version = "0.3.0" + // Version of the cephfs csi driver + Version = "0.3.0" ) type cephfsDriver struct { @@ -46,6 +48,7 @@ var ( DefaultVolumeMounter string ) +// NewCephFSDriver provides a remote csi cephfs driver object. func NewCephFSDriver() *cephfsDriver { return &cephfsDriver{} } diff --git a/pkg/cephfs/util.go b/pkg/cephfs/util.go index 0e0efeddc..faebe127f 100644 --- a/pkg/cephfs/util.go +++ b/pkg/cephfs/util.go @@ -53,7 +53,7 @@ func execCommandAndValidate(program string, args ...string) error { return nil } -func execCommandJson(v interface{}, program string, args ...string) error { +func execCommandJSON(v interface{}, program string, args ...string) error { out, err := execCommand(program, args...) if err != nil { diff --git a/pkg/util/k8scmcache.go b/pkg/util/k8scmcache.go index f1e27ba3c..92117fa10 100644 --- a/pkg/util/k8scmcache.go +++ b/pkg/util/k8scmcache.go @@ -119,33 +119,32 @@ func (k8scm *K8sCMCache) Create(identifier string, data interface{}) error { if cm != nil && err == nil { glog.V(4).Infof("k8s-cm-cache: configmap already exists, skipping configmap creation") return nil - } else { - dataJson, err := json.Marshal(data) - if err != nil { - return errors.Wrap(err, "k8s-cm-cache: marshal error") - } - cm := &v1.ConfigMap{ - ObjectMeta: metav1.ObjectMeta{ - Name: identifier, - Namespace: k8scm.Namespace, - Labels: map[string]string{ - csiMetadataLabelAttr: cmLabel, - }, - }, - Data: map[string]string{}, - } - cm.Data[cmDataKey] = string(dataJson) - - _, err = k8scm.Client.CoreV1().ConfigMaps(k8scm.Namespace).Create(cm) - if err != nil { - if apierrs.IsAlreadyExists(err) { - glog.V(4).Infof("k8s-cm-cache: configmap already exists") - return nil - } - return errors.Wrapf(err, "k8s-cm-cache: couldn't persist %s metadata as configmap", identifier) - } - } + dataJSON, err := json.Marshal(data) + if err != nil { + return errors.Wrap(err, "k8s-cm-cache: marshal error") + } + cm = &v1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{ + Name: identifier, + Namespace: k8scm.Namespace, + Labels: map[string]string{ + csiMetadataLabelAttr: cmLabel, + }, + }, + Data: map[string]string{}, + } + cm.Data[cmDataKey] = string(dataJSON) + + _, err = k8scm.Client.CoreV1().ConfigMaps(k8scm.Namespace).Create(cm) + if err != nil { + if apierrs.IsAlreadyExists(err) { + glog.V(4).Infof("k8s-cm-cache: configmap already exists") + return nil + } + return errors.Wrapf(err, "k8s-cm-cache: couldn't persist %s metadata as configmap", identifier) + } + glog.V(4).Infof("k8s-cm-cache: configmap %s successfully created\n", identifier) return nil }