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

Fix golint failures of pkg/volume/nfs #76944

Merged
merged 1 commit into from
May 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion hack/.golint_failures
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ pkg/volume/csi/fake
pkg/volume/git_repo
pkg/volume/host_path
pkg/volume/iscsi
pkg/volume/nfs
pkg/volume/photon_pd
pkg/volume/portworx
pkg/volume/rbd
Expand Down
28 changes: 14 additions & 14 deletions pkg/volume/nfs/nfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
utilstrings "k8s.io/utils/strings"
)

// This is the primary entrypoint for volume plugins.
// ProbeVolumePlugins is the primary entrypoint for volume plugins.
// The volumeConfig arg provides the ability to configure recycler behavior. It is implemented as a pointer to allow nils.
// The nfsPlugin is used to store the volumeConfig and give it, when needed, to the func that creates NFS Recyclers.
// Tests that exercise recycling should not use this func but instead use ProbeRecyclablePlugins() to override default behavior.
Expand Down Expand Up @@ -224,21 +224,21 @@ type nfsMounter struct {

var _ volume.Mounter = &nfsMounter{}

func (b *nfsMounter) GetAttributes() volume.Attributes {
func (nfsMounter *nfsMounter) GetAttributes() volume.Attributes {
return volume.Attributes{
ReadOnly: b.readOnly,
ReadOnly: nfsMounter.readOnly,
Managed: false,
SupportsSELinux: false,
}
}

// SetUp attaches the disk and bind mounts to the volume path.
func (b *nfsMounter) SetUp(fsGroup *int64) error {
return b.SetUpAt(b.GetPath(), fsGroup)
func (nfsMounter *nfsMounter) SetUp(fsGroup *int64) error {
return nfsMounter.SetUpAt(nfsMounter.GetPath(), fsGroup)
}

func (b *nfsMounter) SetUpAt(dir string, fsGroup *int64) error {
notMnt, err := mount.IsNotMountPoint(b.mounter, dir)
func (nfsMounter *nfsMounter) SetUpAt(dir string, fsGroup *int64) error {
notMnt, err := mount.IsNotMountPoint(nfsMounter.mounter, dir)
klog.V(4).Infof("NFS mount set up: %s %v %v", dir, !notMnt, err)
if err != nil && !os.IsNotExist(err) {
return err
Expand All @@ -249,25 +249,25 @@ func (b *nfsMounter) SetUpAt(dir string, fsGroup *int64) error {
if err := os.MkdirAll(dir, 0750); err != nil {
return err
}
source := fmt.Sprintf("%s:%s", b.server, b.exportPath)
source := fmt.Sprintf("%s:%s", nfsMounter.server, nfsMounter.exportPath)
options := []string{}
if b.readOnly {
if nfsMounter.readOnly {
options = append(options, "ro")
}
mountOptions := util.JoinMountOptions(b.mountOptions, options)
err = b.mounter.Mount(source, dir, "nfs", mountOptions)
mountOptions := util.JoinMountOptions(nfsMounter.mountOptions, options)
err = nfsMounter.mounter.Mount(source, dir, "nfs", mountOptions)
if err != nil {
notMnt, mntErr := mount.IsNotMountPoint(b.mounter, dir)
notMnt, mntErr := mount.IsNotMountPoint(nfsMounter.mounter, dir)
if mntErr != nil {
klog.Errorf("IsNotMountPoint check failed: %v", mntErr)
return err
}
if !notMnt {
if mntErr = b.mounter.Unmount(dir); mntErr != nil {
if mntErr = nfsMounter.mounter.Unmount(dir); mntErr != nil {
klog.Errorf("Failed to unmount: %v", mntErr)
return err
}
notMnt, mntErr := mount.IsNotMountPoint(b.mounter, dir)
notMnt, mntErr := mount.IsNotMountPoint(nfsMounter.mounter, dir)
if mntErr != nil {
klog.Errorf("IsNotMountPoint check failed: %v", mntErr)
return err
Expand Down