Merge pull request #112238 from demoManito/feat/optimize-ifelse

Optimize: correction code specification
This commit is contained in:
Kubernetes Prow Robot 2022-09-19 05:29:22 -07:00 committed by GitHub
commit 64a38b165e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 19 deletions

View File

@ -211,7 +211,9 @@ func (attacher *awsElasticBlockStoreAttacher) MountDevice(spec *volume.Spec, dev
mounter := attacher.host.GetMounter(awsElasticBlockStorePluginName)
notMnt, err := mounter.IsLikelyNotMountPoint(deviceMountPath)
if err != nil {
if os.IsNotExist(err) {
if !os.IsNotExist(err) {
return err
}
dir := deviceMountPath
if runtime.GOOS == "windows" {
// On Windows, FormatAndMount will mklink (create a symbolic link) at deviceMountPath later, so don't create a
@ -225,9 +227,6 @@ func (attacher *awsElasticBlockStoreAttacher) MountDevice(spec *volume.Spec, dev
return fmt.Errorf("making dir %s failed with %s", dir, err)
}
notMnt = true
} else {
return err
}
}
volumeSource, readOnly, err := getVolumeSource(spec)
@ -235,7 +234,7 @@ func (attacher *awsElasticBlockStoreAttacher) MountDevice(spec *volume.Spec, dev
return err
}
options := []string{}
var options []string
if readOnly {
options = append(options, "ro")
}

View File

@ -534,10 +534,10 @@ func (c *awsElasticBlockStoreProvisioner) Provision(selectedNode *v1.Node, allow
pv.Spec.AccessModes = c.plugin.GetAccessModes()
}
requirements := make([]v1.NodeSelectorRequirement, 0)
requirements := make([]v1.NodeSelectorRequirement, 0, len(labels))
if len(labels) != 0 {
if pv.Labels == nil {
pv.Labels = make(map[string]string)
pv.Labels = make(map[string]string, len(labels))
}
for k, v := range labels {
pv.Labels[k] = v

View File

@ -218,7 +218,7 @@ func verifyDevicePath(devicePaths []string) (string, error) {
// This is more interesting on GCE (where we are able to identify volumes under /dev/disk-by-id)
// Here it is mostly about applying the partition path
func getDiskByIDPaths(volumeID aws.KubernetesVolumeID, partition string, devicePath string) []string {
devicePaths := []string{}
var devicePaths []string
if devicePath != "" {
devicePaths = append(devicePaths, devicePath)
}