mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
fix golint failures of pkg/volume/nfs
This commit is contained in:
parent
4ec29a1a2b
commit
d6d329b0eb
@ -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
|
||||
|
@ -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.
|
||||
@ -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
|
||||
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user