mirror of https://github.com/k3s-io/k3s
fix golint for pkg/volume/gce_pd
parent
fdf8d6a281
commit
7d68fd00e6
|
@ -92,7 +92,7 @@ go_library(
|
|||
"//pkg/volume/fc:go_default_library",
|
||||
"//pkg/volume/flexvolume:go_default_library",
|
||||
"//pkg/volume/flocker:go_default_library",
|
||||
"//pkg/volume/gce_pd:go_default_library",
|
||||
"//pkg/volume/gcepd:go_default_library",
|
||||
"//pkg/volume/glusterfs:go_default_library",
|
||||
"//pkg/volume/host_path:go_default_library",
|
||||
"//pkg/volume/iscsi:go_default_library",
|
||||
|
|
|
@ -38,7 +38,7 @@ import (
|
|||
"k8s.io/kubernetes/pkg/volume/fc"
|
||||
"k8s.io/kubernetes/pkg/volume/flexvolume"
|
||||
"k8s.io/kubernetes/pkg/volume/flocker"
|
||||
"k8s.io/kubernetes/pkg/volume/gce_pd"
|
||||
"k8s.io/kubernetes/pkg/volume/gcepd"
|
||||
"k8s.io/kubernetes/pkg/volume/glusterfs"
|
||||
"k8s.io/kubernetes/pkg/volume/host_path"
|
||||
"k8s.io/kubernetes/pkg/volume/iscsi"
|
||||
|
@ -67,7 +67,7 @@ func ProbeAttachableVolumePlugins() []volume.VolumePlugin {
|
|||
allPlugins := []volume.VolumePlugin{}
|
||||
|
||||
allPlugins = append(allPlugins, awsebs.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, gce_pd.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, gcepd.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, cinder.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, portworx.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, vsphere_volume.ProbeVolumePlugins()...)
|
||||
|
@ -96,7 +96,7 @@ func ProbeExpandableVolumePlugins(config kubectrlmgrconfig.VolumeConfiguration)
|
|||
allPlugins := []volume.VolumePlugin{}
|
||||
|
||||
allPlugins = append(allPlugins, awsebs.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, gce_pd.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, gcepd.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, cinder.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, portworx.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, vsphere_volume.ProbeVolumePlugins()...)
|
||||
|
@ -159,7 +159,7 @@ func ProbeControllerVolumePlugins(cloud cloudprovider.Interface, config kubectrl
|
|||
allPlugins = append(allPlugins, storageos.ProbeVolumePlugins()...)
|
||||
|
||||
allPlugins = append(allPlugins, awsebs.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, gce_pd.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, gcepd.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, cinder.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, vsphere_volume.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, azure_dd.ProbeVolumePlugins()...)
|
||||
|
|
|
@ -81,7 +81,7 @@ go_library(
|
|||
"//pkg/volume/fc:go_default_library",
|
||||
"//pkg/volume/flexvolume:go_default_library",
|
||||
"//pkg/volume/flocker:go_default_library",
|
||||
"//pkg/volume/gce_pd:go_default_library",
|
||||
"//pkg/volume/gcepd:go_default_library",
|
||||
"//pkg/volume/git_repo:go_default_library",
|
||||
"//pkg/volume/glusterfs:go_default_library",
|
||||
"//pkg/volume/host_path:go_default_library",
|
||||
|
|
|
@ -38,7 +38,7 @@ import (
|
|||
"k8s.io/kubernetes/pkg/volume/fc"
|
||||
"k8s.io/kubernetes/pkg/volume/flexvolume"
|
||||
"k8s.io/kubernetes/pkg/volume/flocker"
|
||||
"k8s.io/kubernetes/pkg/volume/gce_pd"
|
||||
"k8s.io/kubernetes/pkg/volume/gcepd"
|
||||
"k8s.io/kubernetes/pkg/volume/git_repo"
|
||||
"k8s.io/kubernetes/pkg/volume/glusterfs"
|
||||
"k8s.io/kubernetes/pkg/volume/host_path"
|
||||
|
@ -73,7 +73,7 @@ func ProbeVolumePlugins() []volume.VolumePlugin {
|
|||
// If/when it does, see kube-controller-manager/app/plugins.go for example of using volume.VolumeConfig
|
||||
allPlugins = append(allPlugins, awsebs.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, empty_dir.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, gce_pd.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, gcepd.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, git_repo.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, host_path.ProbeVolumePlugins(volume.VolumeConfig{})...)
|
||||
allPlugins = append(allPlugins, nfs.ProbeVolumePlugins(volume.VolumeConfig{})...)
|
||||
|
|
|
@ -392,7 +392,6 @@ pkg/volume/empty_dir
|
|||
pkg/volume/fc
|
||||
pkg/volume/flexvolume
|
||||
pkg/volume/flocker
|
||||
pkg/volume/gce_pd
|
||||
pkg/volume/git_repo
|
||||
pkg/volume/host_path
|
||||
pkg/volume/iscsi
|
||||
|
|
|
@ -213,7 +213,7 @@ go_test(
|
|||
"//pkg/volume:go_default_library",
|
||||
"//pkg/volume/awsebs:go_default_library",
|
||||
"//pkg/volume/azure_dd:go_default_library",
|
||||
"//pkg/volume/gce_pd:go_default_library",
|
||||
"//pkg/volume/gcepd:go_default_library",
|
||||
"//pkg/volume/host_path:go_default_library",
|
||||
"//pkg/volume/testing:go_default_library",
|
||||
"//pkg/volume/util:go_default_library",
|
||||
|
|
|
@ -70,7 +70,7 @@ import (
|
|||
"k8s.io/kubernetes/pkg/volume"
|
||||
"k8s.io/kubernetes/pkg/volume/awsebs"
|
||||
"k8s.io/kubernetes/pkg/volume/azure_dd"
|
||||
"k8s.io/kubernetes/pkg/volume/gce_pd"
|
||||
"k8s.io/kubernetes/pkg/volume/gcepd"
|
||||
_ "k8s.io/kubernetes/pkg/volume/host_path"
|
||||
volumetest "k8s.io/kubernetes/pkg/volume/testing"
|
||||
"k8s.io/kubernetes/pkg/volume/util"
|
||||
|
@ -314,7 +314,7 @@ func newTestKubeletWithImageList(
|
|||
allPlugins = append(allPlugins, plug)
|
||||
} else {
|
||||
allPlugins = append(allPlugins, awsebs.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, gce_pd.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, gcepd.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, azure_dd.ProbeVolumePlugins()...)
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ filegroup(
|
|||
"//pkg/volume/fc:all-srcs",
|
||||
"//pkg/volume/flexvolume:all-srcs",
|
||||
"//pkg/volume/flocker:all-srcs",
|
||||
"//pkg/volume/gce_pd:all-srcs",
|
||||
"//pkg/volume/gcepd:all-srcs",
|
||||
"//pkg/volume/git_repo:all-srcs",
|
||||
"//pkg/volume/glusterfs:all-srcs",
|
||||
"//pkg/volume/host_path:all-srcs",
|
||||
|
|
|
@ -15,7 +15,7 @@ go_library(
|
|||
"gce_pd_block.go",
|
||||
"gce_util.go",
|
||||
],
|
||||
importpath = "k8s.io/kubernetes/pkg/volume/gce_pd",
|
||||
importpath = "k8s.io/kubernetes/pkg/volume/gcepd",
|
||||
deps = [
|
||||
"//pkg/cloudprovider:go_default_library",
|
||||
"//pkg/cloudprovider/providers/gce:go_default_library",
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package gce_pd
|
||||
package gcepd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
@ -100,7 +100,7 @@ func (attacher *gcePersistentDiskAttacher) Attach(spec *volume.Spec, nodeName ty
|
|||
}
|
||||
}
|
||||
|
||||
return path.Join(diskByIdPath, diskGooglePrefix+pdName), nil
|
||||
return path.Join(diskByIDPath, diskGooglePrefix+pdName), nil
|
||||
}
|
||||
|
||||
func (attacher *gcePersistentDiskAttacher) VolumesAreAttached(specs []*volume.Spec, nodeName types.NodeName) (map[*volume.Spec]bool, error) {
|
||||
|
@ -160,7 +160,7 @@ func (attacher *gcePersistentDiskAttacher) WaitForAttach(spec *volume.Spec, devi
|
|||
}
|
||||
sdBeforeSet := sets.NewString(sdBefore...)
|
||||
|
||||
devicePaths := getDiskByIdPaths(pdName, partition)
|
||||
devicePaths := getDiskByIDPaths(pdName, partition)
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
|
@ -175,7 +175,7 @@ func (attacher *gcePersistentDiskAttacher) WaitForAttach(spec *volume.Spec, devi
|
|||
return path, nil
|
||||
}
|
||||
case <-timer.C:
|
||||
return "", fmt.Errorf("Could not find attached GCE PD %q. Timeout waiting for mount paths to be created.", pdName)
|
||||
return "", fmt.Errorf("could not find attached GCE PD %q. Timeout waiting for mount paths to be created", pdName)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package gce_pd
|
||||
package gcepd
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
@ -323,7 +323,7 @@ func (testcase *testcase) AttachDisk(diskName string, nodeName types.NodeName, r
|
|||
// testcase.attach looks uninitialized, test did not expect to call
|
||||
// AttachDisk
|
||||
testcase.t.Errorf("Unexpected AttachDisk call!")
|
||||
return errors.New("Unexpected AttachDisk call!")
|
||||
return errors.New("unexpected AttachDisk call")
|
||||
}
|
||||
|
||||
if expected.diskName != diskName {
|
||||
|
@ -358,7 +358,7 @@ func (testcase *testcase) DetachDisk(devicePath string, nodeName types.NodeName)
|
|||
// testcase.detach looks uninitialized, test did not expect to call
|
||||
// DetachDisk
|
||||
testcase.t.Errorf("Unexpected DetachDisk call!")
|
||||
return errors.New("Unexpected DetachDisk call!")
|
||||
return errors.New("unexpected DetachDisk call")
|
||||
}
|
||||
|
||||
if expected.devicePath != devicePath {
|
||||
|
@ -383,7 +383,7 @@ func (testcase *testcase) DiskIsAttached(diskName string, nodeName types.NodeNam
|
|||
// testcase.diskIsAttached looks uninitialized, test did not expect to
|
||||
// call DiskIsAttached
|
||||
testcase.t.Errorf("Unexpected DiskIsAttached call!")
|
||||
return false, errors.New("Unexpected DiskIsAttached call!")
|
||||
return false, errors.New("unexpected DiskIsAttached call")
|
||||
}
|
||||
|
||||
if expected.diskName != diskName {
|
|
@ -14,6 +14,6 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Package gce_pd contains the internal representation of GCE PersistentDisk
|
||||
// Package gcepd contains the internal representation of GCE PersistentDisk
|
||||
// volumes.
|
||||
package gce_pd // import "k8s.io/kubernetes/pkg/volume/gce_pd"
|
||||
package gcepd // import "k8s.io/kubernetes/pkg/volume/gcepd"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package gce_pd
|
||||
package gcepd
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
@ -39,7 +39,7 @@ import (
|
|||
"k8s.io/kubernetes/pkg/volume/util"
|
||||
)
|
||||
|
||||
// This is the primary entrypoint for volume plugins.
|
||||
// ProbeVolumePlugins is the primary entrypoint for volume plugins.
|
||||
func ProbeVolumePlugins() []volume.VolumePlugin {
|
||||
return []volume.VolumePlugin{&gcePersistentDiskPlugin{nil}}
|
||||
}
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package gce_pd
|
||||
package gcepd
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package gce_pd
|
||||
package gcepd
|
||||
|
||||
import (
|
||||
"os"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package gce_pd
|
||||
package gcepd
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package gce_pd
|
||||
package gcepd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
@ -39,7 +39,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
diskByIdPath = "/dev/disk/by-id/"
|
||||
diskByIDPath = "/dev/disk/by-id/"
|
||||
diskGooglePrefix = "google-"
|
||||
diskScsiGooglePrefix = "scsi-0Google_PersistentDisk_"
|
||||
diskPartitionSuffix = "-part"
|
||||
|
@ -61,14 +61,17 @@ const (
|
|||
var (
|
||||
// errorSleepDuration is modified only in unit tests and should be constant
|
||||
// otherwise.
|
||||
errorSleepDuration time.Duration = 5 * time.Second
|
||||
errorSleepDuration = 5 * time.Second
|
||||
|
||||
// regex to parse scsi_id output and extract the serial
|
||||
scsiRegex = regexp.MustCompile(scsiPattern)
|
||||
)
|
||||
|
||||
// GCEDiskUtil provides operation for GCE PD
|
||||
type GCEDiskUtil struct{}
|
||||
|
||||
// DeleteVolume deletes a GCE PD
|
||||
// Returns: error
|
||||
func (util *GCEDiskUtil) DeleteVolume(d *gcePersistentDiskDeleter) error {
|
||||
cloud, err := getCloudProvider(d.gcePersistentDisk.plugin.host.GetCloudProvider())
|
||||
if err != nil {
|
||||
|
@ -87,7 +90,7 @@ func (util *GCEDiskUtil) DeleteVolume(d *gcePersistentDiskDeleter) error {
|
|||
|
||||
// CreateVolume creates a GCE PD.
|
||||
// Returns: gcePDName, volumeSizeGB, labels, fsType, error
|
||||
func (gceutil *GCEDiskUtil) CreateVolume(c *gcePersistentDiskProvisioner, node *v1.Node, allowedTopologies []v1.TopologySelectorTerm) (string, int, map[string]string, string, error) {
|
||||
func (util *GCEDiskUtil) CreateVolume(c *gcePersistentDiskProvisioner, node *v1.Node, allowedTopologies []v1.TopologySelectorTerm) (string, int, map[string]string, string, error) {
|
||||
cloud, err := getCloudProvider(c.gcePersistentDisk.plugin.host.GetCloudProvider())
|
||||
if err != nil {
|
||||
return "", 0, nil, "", err
|
||||
|
@ -248,7 +251,7 @@ func getScsiSerial(devicePath, diskName string) (string, error) {
|
|||
"--whitelisted",
|
||||
fmt.Sprintf("--device=%v", devicePath)).CombinedOutput()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("scsi_id failed for device %q with %v.", devicePath, err)
|
||||
return "", fmt.Errorf("scsi_id failed for device %q with %v", devicePath, err)
|
||||
}
|
||||
|
||||
return parseScsiSerial(string(out))
|
||||
|
@ -265,10 +268,10 @@ func parseScsiSerial(output string) (string, error) {
|
|||
}
|
||||
|
||||
// Returns list of all /dev/disk/by-id/* paths for given PD.
|
||||
func getDiskByIdPaths(pdName string, partition string) []string {
|
||||
func getDiskByIDPaths(pdName string, partition string) []string {
|
||||
devicePaths := []string{
|
||||
path.Join(diskByIdPath, diskGooglePrefix+pdName),
|
||||
path.Join(diskByIdPath, diskScsiGooglePrefix+pdName),
|
||||
path.Join(diskByIDPath, diskGooglePrefix+pdName),
|
||||
path.Join(diskByIDPath, diskScsiGooglePrefix+pdName),
|
||||
}
|
||||
|
||||
if partition != "" {
|
||||
|
@ -305,7 +308,7 @@ func getCloudProvider(cloudProvider cloudprovider.Interface) (*gcecloud.GCECloud
|
|||
func udevadmChangeToNewDrives(sdBeforeSet sets.String) error {
|
||||
sdAfter, err := filepath.Glob(diskSDPattern)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error filepath.Glob(\"%s\"): %v\r\n", diskSDPattern, err)
|
||||
return fmt.Errorf("error filepath.Glob(\"%s\"): %v\r", diskSDPattern, err)
|
||||
}
|
||||
|
||||
for _, sd := range sdAfter {
|
||||
|
@ -326,13 +329,13 @@ func udevadmChangeToDrive(drivePath string) error {
|
|||
// Evaluate symlink, if any
|
||||
drive, err := filepath.EvalSymlinks(drivePath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("udevadmChangeToDrive: filepath.EvalSymlinks(%q) failed with %v.", drivePath, err)
|
||||
return fmt.Errorf("udevadmChangeToDrive: filepath.EvalSymlinks(%q) failed with %v", drivePath, err)
|
||||
}
|
||||
glog.V(5).Infof("udevadmChangeToDrive: symlink path is %q", drive)
|
||||
|
||||
// Check to make sure input is "/dev/sd*"
|
||||
if !strings.Contains(drive, diskSDPath) {
|
||||
return fmt.Errorf("udevadmChangeToDrive: expected input in the form \"%s\" but drive is %q.", diskSDPattern, drive)
|
||||
return fmt.Errorf("udevadmChangeToDrive: expected input in the form \"%s\" but drive is %q", diskSDPattern, drive)
|
||||
}
|
||||
|
||||
// Call "udevadm trigger --action=change --property-match=DEVNAME=/dev/sd..."
|
||||
|
@ -342,7 +345,7 @@ func udevadmChangeToDrive(drivePath string) error {
|
|||
"--action=change",
|
||||
fmt.Sprintf("--property-match=DEVNAME=%s", drive)).CombinedOutput()
|
||||
if err != nil {
|
||||
return fmt.Errorf("udevadmChangeToDrive: udevadm trigger failed for drive %q with %v.", drive, err)
|
||||
return fmt.Errorf("udevadmChangeToDrive: udevadm trigger failed for drive %q with %v", drive, err)
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package gce_pd
|
||||
package gcepd
|
||||
|
||||
import "testing"
|
||||
|
|
@ -822,7 +822,7 @@ k8s.io/kubernetes/pkg/volume/empty_dir,quinton-hoole,1,
|
|||
k8s.io/kubernetes/pkg/volume/fc,rrati,0,
|
||||
k8s.io/kubernetes/pkg/volume/flexvolume,Q-Lee,1,
|
||||
k8s.io/kubernetes/pkg/volume/flocker,jbeda,1,
|
||||
k8s.io/kubernetes/pkg/volume/gce_pd,saad-ali,0,
|
||||
k8s.io/kubernetes/pkg/volume/gcepd,saad-ali,0,
|
||||
k8s.io/kubernetes/pkg/volume/git_repo,davidopp,1,
|
||||
k8s.io/kubernetes/pkg/volume/glusterfs,tallclair,1,
|
||||
k8s.io/kubernetes/pkg/volume/host_path,jbeda,1,
|
||||
|
|
|
Loading…
Reference in New Issue