mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Merge pull request #92461 from Haleygo/001
update static check failed from pkg/volume/rbd
This commit is contained in:
		@@ -5,7 +5,6 @@ pkg/controller/replicaset
 | 
				
			|||||||
pkg/controller/resourcequota
 | 
					pkg/controller/resourcequota
 | 
				
			||||||
pkg/volume/azure_dd
 | 
					pkg/volume/azure_dd
 | 
				
			||||||
pkg/volume/gcepd
 | 
					pkg/volume/gcepd
 | 
				
			||||||
pkg/volume/rbd
 | 
					 | 
				
			||||||
pkg/volume/testing
 | 
					pkg/volume/testing
 | 
				
			||||||
test/e2e/autoscaling
 | 
					test/e2e/autoscaling
 | 
				
			||||||
test/e2e_node
 | 
					test/e2e_node
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -207,7 +207,7 @@ var _ volume.DeviceUnmounter = &rbdDetacher{}
 | 
				
			|||||||
// This method is idempotent, callers are responsible for retrying on failure.
 | 
					// This method is idempotent, callers are responsible for retrying on failure.
 | 
				
			||||||
func (detacher *rbdDetacher) UnmountDevice(deviceMountPath string) error {
 | 
					func (detacher *rbdDetacher) UnmountDevice(deviceMountPath string) error {
 | 
				
			||||||
	if pathExists, pathErr := mount.PathExists(deviceMountPath); pathErr != nil {
 | 
						if pathExists, pathErr := mount.PathExists(deviceMountPath); pathErr != nil {
 | 
				
			||||||
		return fmt.Errorf("Error checking if path exists: %v", pathErr)
 | 
							return fmt.Errorf("error checking if path exists: %v", pathErr)
 | 
				
			||||||
	} else if !pathExists {
 | 
						} else if !pathExists {
 | 
				
			||||||
		klog.Warningf("Warning: Unmount skipped because path does not exist: %v", deviceMountPath)
 | 
							klog.Warningf("Warning: Unmount skipped because path does not exist: %v", deviceMountPath)
 | 
				
			||||||
		return nil
 | 
							return nil
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -37,7 +37,6 @@ import (
 | 
				
			|||||||
	"k8s.io/apimachinery/pkg/util/uuid"
 | 
						"k8s.io/apimachinery/pkg/util/uuid"
 | 
				
			||||||
	clientset "k8s.io/client-go/kubernetes"
 | 
						clientset "k8s.io/client-go/kubernetes"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/volume"
 | 
						"k8s.io/kubernetes/pkg/volume"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/volume/util"
 | 
					 | 
				
			||||||
	volutil "k8s.io/kubernetes/pkg/volume/util"
 | 
						volutil "k8s.io/kubernetes/pkg/volume/util"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/volume/util/volumepathhandler"
 | 
						"k8s.io/kubernetes/pkg/volume/util/volumepathhandler"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@@ -199,7 +198,7 @@ func (plugin *rbdPlugin) ExpandVolumeDevice(spec *volume.Spec, newSize resource.
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (plugin *rbdPlugin) NodeExpand(resizeOptions volume.NodeResizeOptions) (bool, error) {
 | 
					func (plugin *rbdPlugin) NodeExpand(resizeOptions volume.NodeResizeOptions) (bool, error) {
 | 
				
			||||||
	fsVolume, err := util.CheckVolumeModeFilesystem(resizeOptions.VolumeSpec)
 | 
						fsVolume, err := volutil.CheckVolumeModeFilesystem(resizeOptions.VolumeSpec)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return false, fmt.Errorf("error checking VolumeMode: %v", err)
 | 
							return false, fmt.Errorf("error checking VolumeMode: %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -268,11 +267,11 @@ func (plugin *rbdPlugin) createMounterFromVolumeSpecAndPod(spec *volume.Spec, po
 | 
				
			|||||||
		// if secret is provideded, retrieve it
 | 
							// if secret is provideded, retrieve it
 | 
				
			||||||
		kubeClient := plugin.host.GetKubeClient()
 | 
							kubeClient := plugin.host.GetKubeClient()
 | 
				
			||||||
		if kubeClient == nil {
 | 
							if kubeClient == nil {
 | 
				
			||||||
			return nil, fmt.Errorf("Cannot get kube client")
 | 
								return nil, fmt.Errorf("cannot get kube client")
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		secrets, err := kubeClient.CoreV1().Secrets(secretNs).Get(context.TODO(), secretName, metav1.GetOptions{})
 | 
							secrets, err := kubeClient.CoreV1().Secrets(secretNs).Get(context.TODO(), secretName, metav1.GetOptions{})
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			err = fmt.Errorf("Couldn't get secret %v/%v err: %v", secretNs, secretName, err)
 | 
								err = fmt.Errorf("couldn't get secret %v/%v err: %v", secretNs, secretName, err)
 | 
				
			||||||
			return nil, err
 | 
								return nil, err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		for _, data := range secrets.Data {
 | 
							for _, data := range secrets.Data {
 | 
				
			||||||
@@ -301,11 +300,11 @@ func (plugin *rbdPlugin) NewMounter(spec *volume.Spec, pod *v1.Pod, _ volume.Vol
 | 
				
			|||||||
		// if secret is provideded, retrieve it
 | 
							// if secret is provideded, retrieve it
 | 
				
			||||||
		kubeClient := plugin.host.GetKubeClient()
 | 
							kubeClient := plugin.host.GetKubeClient()
 | 
				
			||||||
		if kubeClient == nil {
 | 
							if kubeClient == nil {
 | 
				
			||||||
			return nil, fmt.Errorf("Cannot get kube client")
 | 
								return nil, fmt.Errorf("cannot get kube client")
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		secrets, err := kubeClient.CoreV1().Secrets(secretNs).Get(context.TODO(), secretName, metav1.GetOptions{})
 | 
							secrets, err := kubeClient.CoreV1().Secrets(secretNs).Get(context.TODO(), secretName, metav1.GetOptions{})
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			err = fmt.Errorf("Couldn't get secret %v/%v err: %v", secretNs, secretName, err)
 | 
								err = fmt.Errorf("couldn't get secret %v/%v err: %v", secretNs, secretName, err)
 | 
				
			||||||
			return nil, err
 | 
								return nil, err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		for _, data := range secrets.Data {
 | 
							for _, data := range secrets.Data {
 | 
				
			||||||
@@ -483,11 +482,11 @@ func (plugin *rbdPlugin) NewBlockVolumeMapper(spec *volume.Spec, pod *v1.Pod, _
 | 
				
			|||||||
			// if secret is provideded, retrieve it
 | 
								// if secret is provideded, retrieve it
 | 
				
			||||||
			kubeClient := plugin.host.GetKubeClient()
 | 
								kubeClient := plugin.host.GetKubeClient()
 | 
				
			||||||
			if kubeClient == nil {
 | 
								if kubeClient == nil {
 | 
				
			||||||
				return nil, fmt.Errorf("Cannot get kube client")
 | 
									return nil, fmt.Errorf("cannot get kube client")
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			secrets, err := kubeClient.CoreV1().Secrets(secretNs).Get(context.TODO(), secretName, metav1.GetOptions{})
 | 
								secrets, err := kubeClient.CoreV1().Secrets(secretNs).Get(context.TODO(), secretName, metav1.GetOptions{})
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
				err = fmt.Errorf("Couldn't get secret %v/%v err: %v", secretNs, secretName, err)
 | 
									err = fmt.Errorf("couldn't get secret %v/%v err: %v", secretNs, secretName, err)
 | 
				
			||||||
				return nil, err
 | 
									return nil, err
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			for _, data := range secrets.Data {
 | 
								for _, data := range secrets.Data {
 | 
				
			||||||
@@ -862,7 +861,7 @@ func (c *rbdUnmounter) TearDown() error {
 | 
				
			|||||||
func (c *rbdUnmounter) TearDownAt(dir string) error {
 | 
					func (c *rbdUnmounter) TearDownAt(dir string) error {
 | 
				
			||||||
	klog.V(4).Infof("rbd: attempting to teardown at %s", dir)
 | 
						klog.V(4).Infof("rbd: attempting to teardown at %s", dir)
 | 
				
			||||||
	if pathExists, pathErr := mount.PathExists(dir); pathErr != nil {
 | 
						if pathExists, pathErr := mount.PathExists(dir); pathErr != nil {
 | 
				
			||||||
		return fmt.Errorf("Error checking if path exists: %v", pathErr)
 | 
							return fmt.Errorf("error checking if path exists: %v", pathErr)
 | 
				
			||||||
	} else if !pathExists {
 | 
						} else if !pathExists {
 | 
				
			||||||
		klog.Warningf("Warning: Unmount skipped because path does not exist: %v", dir)
 | 
							klog.Warningf("Warning: Unmount skipped because path does not exist: %v", dir)
 | 
				
			||||||
		return nil
 | 
							return nil
 | 
				
			||||||
@@ -996,7 +995,7 @@ func getVolumeSourceMonitors(spec *volume.Spec) ([]string, error) {
 | 
				
			|||||||
		return spec.PersistentVolume.Spec.RBD.CephMonitors, nil
 | 
							return spec.PersistentVolume.Spec.RBD.CephMonitors, nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return nil, fmt.Errorf("Spec does not reference a RBD volume type")
 | 
						return nil, fmt.Errorf("spec does not reference a RBD volume type")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func getVolumeSourceImage(spec *volume.Spec) (string, error) {
 | 
					func getVolumeSourceImage(spec *volume.Spec) (string, error) {
 | 
				
			||||||
@@ -1007,7 +1006,7 @@ func getVolumeSourceImage(spec *volume.Spec) (string, error) {
 | 
				
			|||||||
		return spec.PersistentVolume.Spec.RBD.RBDImage, nil
 | 
							return spec.PersistentVolume.Spec.RBD.RBDImage, nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return "", fmt.Errorf("Spec does not reference a RBD volume type")
 | 
						return "", fmt.Errorf("spec does not reference a RBD volume type")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func getVolumeSourceFSType(spec *volume.Spec) (string, error) {
 | 
					func getVolumeSourceFSType(spec *volume.Spec) (string, error) {
 | 
				
			||||||
@@ -1018,7 +1017,7 @@ func getVolumeSourceFSType(spec *volume.Spec) (string, error) {
 | 
				
			|||||||
		return spec.PersistentVolume.Spec.RBD.FSType, nil
 | 
							return spec.PersistentVolume.Spec.RBD.FSType, nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return "", fmt.Errorf("Spec does not reference a RBD volume type")
 | 
						return "", fmt.Errorf("spec does not reference a RBD volume type")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func getVolumeSourcePool(spec *volume.Spec) (string, error) {
 | 
					func getVolumeSourcePool(spec *volume.Spec) (string, error) {
 | 
				
			||||||
@@ -1029,7 +1028,7 @@ func getVolumeSourcePool(spec *volume.Spec) (string, error) {
 | 
				
			|||||||
		return spec.PersistentVolume.Spec.RBD.RBDPool, nil
 | 
							return spec.PersistentVolume.Spec.RBD.RBDPool, nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return "", fmt.Errorf("Spec does not reference a RBD volume type")
 | 
						return "", fmt.Errorf("spec does not reference a RBD volume type")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func getVolumeSourceUser(spec *volume.Spec) (string, error) {
 | 
					func getVolumeSourceUser(spec *volume.Spec) (string, error) {
 | 
				
			||||||
@@ -1040,7 +1039,7 @@ func getVolumeSourceUser(spec *volume.Spec) (string, error) {
 | 
				
			|||||||
		return spec.PersistentVolume.Spec.RBD.RadosUser, nil
 | 
							return spec.PersistentVolume.Spec.RBD.RadosUser, nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return "", fmt.Errorf("Spec does not reference a RBD volume type")
 | 
						return "", fmt.Errorf("spec does not reference a RBD volume type")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func getVolumeSourceKeyRing(spec *volume.Spec) (string, error) {
 | 
					func getVolumeSourceKeyRing(spec *volume.Spec) (string, error) {
 | 
				
			||||||
@@ -1051,7 +1050,7 @@ func getVolumeSourceKeyRing(spec *volume.Spec) (string, error) {
 | 
				
			|||||||
		return spec.PersistentVolume.Spec.RBD.Keyring, nil
 | 
							return spec.PersistentVolume.Spec.RBD.Keyring, nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return "", fmt.Errorf("Spec does not reference a RBD volume type")
 | 
						return "", fmt.Errorf("spec does not reference a RBD volume type")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func getVolumeSourceReadOnly(spec *volume.Spec) (bool, error) {
 | 
					func getVolumeSourceReadOnly(spec *volume.Spec) (bool, error) {
 | 
				
			||||||
@@ -1064,7 +1063,7 @@ func getVolumeSourceReadOnly(spec *volume.Spec) (bool, error) {
 | 
				
			|||||||
		return spec.ReadOnly, nil
 | 
							return spec.ReadOnly, nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return false, fmt.Errorf("Spec does not reference a RBD volume type")
 | 
						return false, fmt.Errorf("spec does not reference a RBD volume type")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func getVolumeAccessModes(spec *volume.Spec) ([]v1.PersistentVolumeAccessMode, error) {
 | 
					func getVolumeAccessModes(spec *volume.Spec) ([]v1.PersistentVolumeAccessMode, error) {
 | 
				
			||||||
@@ -1073,7 +1072,7 @@ func getVolumeAccessModes(spec *volume.Spec) ([]v1.PersistentVolumeAccessMode, e
 | 
				
			|||||||
		if spec.PersistentVolume.Spec.RBD != nil {
 | 
							if spec.PersistentVolume.Spec.RBD != nil {
 | 
				
			||||||
			return spec.PersistentVolume.Spec.AccessModes, nil
 | 
								return spec.PersistentVolume.Spec.AccessModes, nil
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return nil, fmt.Errorf("Spec does not reference a RBD volume type")
 | 
							return nil, fmt.Errorf("spec does not reference a RBD volume type")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return nil, nil
 | 
						return nil, nil
 | 
				
			||||||
@@ -1124,5 +1123,5 @@ func getSecretNameAndNamespace(spec *volume.Spec, defaultNamespace string) (stri
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		return "", "", nil
 | 
							return "", "", nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return "", "", fmt.Errorf("Spec does not reference an RBD volume type")
 | 
						return "", "", fmt.Errorf("spec does not reference an RBD volume type")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -86,8 +86,8 @@ func TestGetVolumeSpecFromGlobalMapPath(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	block := v1.PersistentVolumeBlock
 | 
						block := v1.PersistentVolumeBlock
 | 
				
			||||||
	specMode := spec.PersistentVolume.Spec.VolumeMode
 | 
						specMode := spec.PersistentVolume.Spec.VolumeMode
 | 
				
			||||||
	if &specMode == nil {
 | 
						if specMode == nil {
 | 
				
			||||||
		t.Errorf("Invalid volumeMode from GlobalMapPath spec: %v - %v", &specMode, block)
 | 
							t.Errorf("Invalid volumeMode from GlobalMapPath spec: %v - %v", specMode, block)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if *specMode != block {
 | 
						if *specMode != block {
 | 
				
			||||||
		t.Errorf("Invalid volumeMode from GlobalMapPath spec: %v - %v", *specMode, block)
 | 
							t.Errorf("Invalid volumeMode from GlobalMapPath spec: %v - %v", *specMode, block)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -373,7 +373,7 @@ func (util *rbdUtil) AttachDisk(b rbdMounter) (string, error) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	globalPDPath := util.MakeGlobalPDName(*b.rbd)
 | 
						globalPDPath := util.MakeGlobalPDName(*b.rbd)
 | 
				
			||||||
	if pathExists, pathErr := mount.PathExists(globalPDPath); pathErr != nil {
 | 
						if pathExists, pathErr := mount.PathExists(globalPDPath); pathErr != nil {
 | 
				
			||||||
		return "", fmt.Errorf("Error checking if path exists: %v", pathErr)
 | 
							return "", fmt.Errorf("error checking if path exists: %v", pathErr)
 | 
				
			||||||
	} else if !pathExists {
 | 
						} else if !pathExists {
 | 
				
			||||||
		if err := os.MkdirAll(globalPDPath, 0750); err != nil {
 | 
							if err := os.MkdirAll(globalPDPath, 0750); err != nil {
 | 
				
			||||||
			return "", err
 | 
								return "", err
 | 
				
			||||||
@@ -459,7 +459,7 @@ func (util *rbdUtil) AttachDisk(b rbdMounter) (string, error) {
 | 
				
			|||||||
			devicePath, mapped = waitForPath(b.Pool, b.Image, 10 /*maxRetries*/, false /*useNbdDriver*/)
 | 
								devicePath, mapped = waitForPath(b.Pool, b.Image, 10 /*maxRetries*/, false /*useNbdDriver*/)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if !mapped {
 | 
							if !mapped {
 | 
				
			||||||
			return "", fmt.Errorf("Could not map image %s/%s, Timeout after 10s", b.Pool, b.Image)
 | 
								return "", fmt.Errorf("could not map image %s/%s, Timeout after 10s", b.Pool, b.Image)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return devicePath, nil
 | 
						return devicePath, nil
 | 
				
			||||||
@@ -515,7 +515,7 @@ func (util *rbdUtil) DetachDisk(plugin *rbdPlugin, deviceMountPath string, devic
 | 
				
			|||||||
func (util *rbdUtil) DetachBlockDisk(disk rbdDiskUnmapper, mapPath string) error {
 | 
					func (util *rbdUtil) DetachBlockDisk(disk rbdDiskUnmapper, mapPath string) error {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if pathExists, pathErr := mount.PathExists(mapPath); pathErr != nil {
 | 
						if pathExists, pathErr := mount.PathExists(mapPath); pathErr != nil {
 | 
				
			||||||
		return fmt.Errorf("Error checking if path exists: %v", pathErr)
 | 
							return fmt.Errorf("error checking if path exists: %v", pathErr)
 | 
				
			||||||
	} else if !pathExists {
 | 
						} else if !pathExists {
 | 
				
			||||||
		klog.Warningf("Warning: Unmap skipped because path does not exist: %v", mapPath)
 | 
							klog.Warningf("Warning: Unmap skipped because path does not exist: %v", mapPath)
 | 
				
			||||||
		return nil
 | 
							return nil
 | 
				
			||||||
@@ -803,7 +803,7 @@ func (util *rbdUtil) rbdStatus(b *rbdMounter) (bool, string, error) {
 | 
				
			|||||||
func getRbdImageInfo(deviceMountPath string) (*rbdImageInfo, error) {
 | 
					func getRbdImageInfo(deviceMountPath string) (*rbdImageInfo, error) {
 | 
				
			||||||
	deviceMountedPathSeps := strings.Split(filepath.Base(deviceMountPath), "-image-")
 | 
						deviceMountedPathSeps := strings.Split(filepath.Base(deviceMountPath), "-image-")
 | 
				
			||||||
	if len(deviceMountedPathSeps) != 2 {
 | 
						if len(deviceMountedPathSeps) != 2 {
 | 
				
			||||||
		return nil, fmt.Errorf("Can't found devicePath for %s ", deviceMountPath)
 | 
							return nil, fmt.Errorf("can't found devicePath for %s ", deviceMountPath)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return &rbdImageInfo{
 | 
						return &rbdImageInfo{
 | 
				
			||||||
		pool: deviceMountedPathSeps[0],
 | 
							pool: deviceMountedPathSeps[0],
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user