mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Merge pull request #87711 from alena1108/jan30volume
Ineffassign fixes for pkg/volume
This commit is contained in:
commit
3e3a3599ca
@ -18,7 +18,6 @@ pkg/registry/core/service/storage
|
||||
pkg/util/coverage
|
||||
pkg/volume
|
||||
pkg/volume/azure_dd
|
||||
pkg/volume/azure_file
|
||||
pkg/volume/csi
|
||||
pkg/volume/flexvolume
|
||||
pkg/volume/iscsi
|
||||
@ -29,7 +28,6 @@ pkg/volume/storageos
|
||||
pkg/volume/util
|
||||
pkg/volume/util/fsquota
|
||||
pkg/volume/util/fsquota/common
|
||||
pkg/volume/util/operationexecutor
|
||||
pkg/volume/util/subpath
|
||||
test/e2e/apps
|
||||
test/e2e/autoscaling
|
||||
|
@ -114,6 +114,11 @@ func (plugin *azureFilePlugin) newMounterInternal(spec *volume.Spec, pod *v1.Pod
|
||||
return nil, err
|
||||
}
|
||||
secretName, secretNamespace, err := getSecretNameAndNamespace(spec, pod.Namespace)
|
||||
if err != nil {
|
||||
// Log-and-continue instead of returning an error for now
|
||||
// due to unspecified backwards compatibility concerns (a subject to revise)
|
||||
klog.Errorf("get secret name and namespace from pod(%s) return with error: %v", pod.Name, err)
|
||||
}
|
||||
return &azureFileMounter{
|
||||
azureFile: &azureFile{
|
||||
volName: spec.Name(),
|
||||
@ -257,7 +262,6 @@ func (b *azureFileMounter) SetUpAt(dir string, mounterArgs volume.MounterArgs) e
|
||||
klog.Errorf("azureFile - Unmount directory %s failed with %v", dir, err)
|
||||
return err
|
||||
}
|
||||
notMnt = true
|
||||
}
|
||||
|
||||
var accountKey, accountName string
|
||||
@ -265,7 +269,7 @@ func (b *azureFileMounter) SetUpAt(dir string, mounterArgs volume.MounterArgs) e
|
||||
return err
|
||||
}
|
||||
|
||||
mountOptions := []string{}
|
||||
var mountOptions []string
|
||||
source := ""
|
||||
osSeparator := string(os.PathSeparator)
|
||||
source = fmt.Sprintf("%s%s%s.file.%s%s%s", osSeparator, osSeparator, accountName, getStorageEndpointSuffix(b.plugin.host.GetCloudProvider()), osSeparator, b.shareName)
|
||||
|
@ -362,7 +362,7 @@ func (util *ISCSIUtil) AttachDisk(b iscsiDiskMounter) (string, error) {
|
||||
}
|
||||
|
||||
// in case of node failure/restart, explicitly set to manual login so it doesn't hang on boot
|
||||
out, err = execWithLog(b, "iscsiadm", "-m", "node", "-p", tp, "-T", b.Iqn, "-o", "update", "-n", "node.startup", "-v", "manual")
|
||||
_, err = execWithLog(b, "iscsiadm", "-m", "node", "-p", tp, "-T", b.Iqn, "-o", "update", "-n", "node.startup", "-v", "manual")
|
||||
if err != nil {
|
||||
// don't fail if we can't set startup mode, but log warning so there is a clue
|
||||
klog.Warningf("Warning: Failed to set iSCSI login mode to manual. Error: %v", err)
|
||||
|
@ -355,7 +355,7 @@ func (util *RBDUtil) rbdUnlock(b rbdMounter) error {
|
||||
if len(locker) > 0 {
|
||||
args := []string{"lock", "remove", b.Image, lock_id, locker, "--pool", b.Pool, "--id", b.Id, "-m", mon}
|
||||
args = append(args, secret_opt...)
|
||||
cmd, err = b.exec.Command("rbd", args...).CombinedOutput()
|
||||
_, err = b.exec.Command("rbd", args...).CombinedOutput()
|
||||
if err == nil {
|
||||
klog.V(4).Infof("rbd: successfully remove lock (locker_id: %s) on image: %s/%s with id %s mon %s", lock_id, b.Pool, b.Image, b.Id, mon)
|
||||
} else {
|
||||
|
@ -89,7 +89,7 @@ func openAndLockProjectFiles() (*os.File, *os.File, error) {
|
||||
fProjid, err := os.OpenFile(projidFile, os.O_RDONLY|os.O_CREATE, 0644)
|
||||
if err == nil {
|
||||
// Check once more, to ensure nothing got changed out from under us
|
||||
if err := projFilesAreOK(); err == nil {
|
||||
if err = projFilesAreOK(); err == nil {
|
||||
err = lockFile(fProjects)
|
||||
if err == nil {
|
||||
err = lockFile(fProjid)
|
||||
@ -324,7 +324,7 @@ func createProjectID(path string, ID common.QuotaID) (common.QuotaID, error) {
|
||||
if err == nil {
|
||||
defer closeProjectFiles(fProjects, fProjid)
|
||||
list := readProjectFiles(fProjects, fProjid)
|
||||
writeProjid := true
|
||||
var writeProjid bool
|
||||
ID, writeProjid, err = addDirToProject(path, ID, &list)
|
||||
if err == nil && ID != common.BadQuotaID {
|
||||
if err = writeProjectFiles(fProjects, fProjid, writeProjid, list); err == nil {
|
||||
@ -345,7 +345,7 @@ func removeProjectID(path string, ID common.QuotaID) error {
|
||||
if err == nil {
|
||||
defer closeProjectFiles(fProjects, fProjid)
|
||||
list := readProjectFiles(fProjects, fProjid)
|
||||
writeProjid := true
|
||||
var writeProjid bool
|
||||
writeProjid, err = removeDirFromProject(path, ID, &list)
|
||||
if err == nil {
|
||||
if err = writeProjectFiles(fProjects, fProjid, writeProjid, list); err == nil {
|
||||
|
@ -226,6 +226,11 @@ func clearQuotaOnDir(m mount.Interface, path string) error {
|
||||
// we explicitly have to check in this case.
|
||||
klog.V(4).Infof("clearQuotaOnDir %s", path)
|
||||
supportsQuotas, err := SupportsQuotas(m, path)
|
||||
if err != nil {
|
||||
// Log-and-continue instead of returning an error for now
|
||||
// due to unspecified backwards compatibility concerns (a subject to revise)
|
||||
klog.V(3).Infof("Attempt to check for quota support failed: %v", err)
|
||||
}
|
||||
if !supportsQuotas {
|
||||
return nil
|
||||
}
|
||||
@ -409,8 +414,12 @@ func ClearQuota(m mount.Interface, path string) error {
|
||||
if !ok {
|
||||
return fmt.Errorf("ClearQuota: No quota available for %s", path)
|
||||
}
|
||||
var err error
|
||||
projid, err := getQuotaOnDir(m, path)
|
||||
if err != nil {
|
||||
// Log-and-continue instead of returning an error for now
|
||||
// due to unspecified backwards compatibility concerns (a subject to revise)
|
||||
klog.V(3).Infof("Attempt to check quota ID %v on dir %s failed: %v", dirQuotaMap[path], path, err)
|
||||
}
|
||||
if projid != dirQuotaMap[path] {
|
||||
return fmt.Errorf("Expected quota ID %v on dir %s does not match actual %v", dirQuotaMap[path], path, projid)
|
||||
}
|
||||
|
@ -656,7 +656,7 @@ func (og *operationGenerator) GenerateMountVolumeFunc(
|
||||
// - Volume does not support DeviceMounter interface.
|
||||
// - In case of CSI the volume does not have node stage_unstage capability.
|
||||
if !resizeDone {
|
||||
resizeDone, resizeError = og.nodeExpandVolume(volumeToMount, resizeOptions)
|
||||
_, resizeError = og.nodeExpandVolume(volumeToMount, resizeOptions)
|
||||
if resizeError != nil {
|
||||
klog.Errorf("MountVolume.NodeExpandVolume failed with %v", resizeError)
|
||||
return volumeToMount.GenerateError("MountVolume.Setup failed while expanding volume", resizeError)
|
||||
|
@ -267,7 +267,7 @@ func findExistingPrefix(base, pathname string) (string, []string, error) {
|
||||
|
||||
dirs := strings.Split(rel, string(filepath.Separator))
|
||||
|
||||
parent := base
|
||||
var parent string
|
||||
currentPath := base
|
||||
for i, dir := range dirs {
|
||||
parent = currentPath
|
||||
|
Loading…
Reference in New Issue
Block a user