From b10e0f9235bef7010f60d77e379c69965afd0411 Mon Sep 17 00:00:00 2001 From: Anusha Ramineni Date: Tue, 27 Aug 2019 14:26:15 +0530 Subject: [PATCH] Fix static check errors --- .../src/k8s.io/legacy-cloud-providers/go.mod | 2 +- .../openstack/util/mount/mount.go | 32 ------------------- .../openstack/util/mount/mount_linux.go | 12 +++---- 3 files changed, 7 insertions(+), 39 deletions(-) diff --git a/staging/src/k8s.io/legacy-cloud-providers/go.mod b/staging/src/k8s.io/legacy-cloud-providers/go.mod index 8ec7c26636d..94dcb406d93 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/go.mod +++ b/staging/src/k8s.io/legacy-cloud-providers/go.mod @@ -23,8 +23,8 @@ require ( github.com/vmware/govmomi v0.20.1 golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8 golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 - google.golang.org/api v0.6.1-0.20190607001116-5213b8090861 golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f + google.golang.org/api v0.6.1-0.20190607001116-5213b8090861 gopkg.in/gcfg.v1 v1.2.0 gopkg.in/warnings.v0 v0.1.1 // indirect k8s.io/api v0.0.0 diff --git a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount.go b/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount.go index 4e8924ab4cd..0b72656f5a2 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount.go +++ b/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount.go @@ -186,36 +186,6 @@ func (mounter *SafeFormatAndMount) FormatAndMount(source string, target string, return mounter.formatAndMount(source, target, fstype, options) } -// getMountRefsByDev finds all references to the device provided -// by mountPath; returns a list of paths. -// Note that mountPath should be path after the evaluation of any symbolic links. -func getMountRefsByDev(mounter Interface, mountPath string) ([]string, error) { - mps, err := mounter.List() - if err != nil { - return nil, err - } - - // Finding the device mounted to mountPath - diskDev := "" - for i := range mps { - if mountPath == mps[i].Path { - diskDev = mps[i].Device - break - } - } - - // Find all references to the device. - var refs []string - for i := range mps { - if mps[i].Device == diskDev || mps[i].Device == mountPath { - if mps[i].Path != mountPath { - refs = append(refs, mps[i].Path) - } - } - } - return refs, nil -} - // GetDeviceNameFromMount when given a mnt point, find the device from /proc/mounts // returns the device name, reference count, and error code. func GetDeviceNameFromMount(mounter Interface, mountPath string) (string, int, error) { @@ -318,9 +288,7 @@ func isBind(options []string) (bool, []string, []string) { switch option { case "bind": bind = true - break case "remount": - break default: bindRemountOpts = append(bindRemountOpts, option) } diff --git a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount_linux.go b/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount_linux.go index 69f93425f06..79671b23b51 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount_linux.go +++ b/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount_linux.go @@ -137,11 +137,11 @@ func (mounter *Mounter) doMount(mounterPath string, mountCmd string, source stri // systemd-mount is not used because it's too new for older distros // (CentOS 7, Debian Jessie). mountCmd, mountArgs = addSystemdScope("systemd-run", target, mountCmd, mountArgs) - } else { - // No systemd-run on the host (or we failed to check it), assume kubelet - // does not run as a systemd service. - // No code here, mountCmd and mountArgs are already populated. - } + } //else { + // No systemd-run on the host (or we failed to check it), assume kubelet + // does not run as a systemd service. + // No code here, mountCmd and mountArgs are already populated. + //} klog.V(4).Infof("Mounting cmd (%s) with arguments (%s)", mountCmd, mountArgs) command := exec.Command(mountCmd, mountArgs...) @@ -413,11 +413,11 @@ func (mounter *Mounter) MakeDir(pathname string) error { // MakeFile creates a file with permissions 0644 at the specified path. func (mounter *Mounter) MakeFile(pathname string) error { f, err := os.OpenFile(pathname, os.O_CREATE, os.FileMode(0644)) - defer f.Close() if err != nil { if !os.IsExist(err) { return err } + defer f.Close() } return nil }