mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +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/util/coverage
|
||||||
pkg/volume
|
pkg/volume
|
||||||
pkg/volume/azure_dd
|
pkg/volume/azure_dd
|
||||||
pkg/volume/azure_file
|
|
||||||
pkg/volume/csi
|
pkg/volume/csi
|
||||||
pkg/volume/flexvolume
|
pkg/volume/flexvolume
|
||||||
pkg/volume/iscsi
|
pkg/volume/iscsi
|
||||||
@ -29,7 +28,6 @@ pkg/volume/storageos
|
|||||||
pkg/volume/util
|
pkg/volume/util
|
||||||
pkg/volume/util/fsquota
|
pkg/volume/util/fsquota
|
||||||
pkg/volume/util/fsquota/common
|
pkg/volume/util/fsquota/common
|
||||||
pkg/volume/util/operationexecutor
|
|
||||||
pkg/volume/util/subpath
|
pkg/volume/util/subpath
|
||||||
test/e2e/apps
|
test/e2e/apps
|
||||||
test/e2e/autoscaling
|
test/e2e/autoscaling
|
||||||
|
@ -114,6 +114,11 @@ func (plugin *azureFilePlugin) newMounterInternal(spec *volume.Spec, pod *v1.Pod
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
secretName, secretNamespace, err := getSecretNameAndNamespace(spec, pod.Namespace)
|
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{
|
return &azureFileMounter{
|
||||||
azureFile: &azureFile{
|
azureFile: &azureFile{
|
||||||
volName: spec.Name(),
|
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)
|
klog.Errorf("azureFile - Unmount directory %s failed with %v", dir, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
notMnt = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var accountKey, accountName string
|
var accountKey, accountName string
|
||||||
@ -265,7 +269,7 @@ func (b *azureFileMounter) SetUpAt(dir string, mounterArgs volume.MounterArgs) e
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
mountOptions := []string{}
|
var mountOptions []string
|
||||||
source := ""
|
source := ""
|
||||||
osSeparator := string(os.PathSeparator)
|
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)
|
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
|
// 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 {
|
if err != nil {
|
||||||
// don't fail if we can't set startup mode, but log warning so there is a clue
|
// 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)
|
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 {
|
if len(locker) > 0 {
|
||||||
args := []string{"lock", "remove", b.Image, lock_id, locker, "--pool", b.Pool, "--id", b.Id, "-m", mon}
|
args := []string{"lock", "remove", b.Image, lock_id, locker, "--pool", b.Pool, "--id", b.Id, "-m", mon}
|
||||||
args = append(args, secret_opt...)
|
args = append(args, secret_opt...)
|
||||||
cmd, err = b.exec.Command("rbd", args...).CombinedOutput()
|
_, err = b.exec.Command("rbd", args...).CombinedOutput()
|
||||||
if err == nil {
|
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)
|
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 {
|
} else {
|
||||||
|
@ -89,7 +89,7 @@ func openAndLockProjectFiles() (*os.File, *os.File, error) {
|
|||||||
fProjid, err := os.OpenFile(projidFile, os.O_RDONLY|os.O_CREATE, 0644)
|
fProjid, err := os.OpenFile(projidFile, os.O_RDONLY|os.O_CREATE, 0644)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// Check once more, to ensure nothing got changed out from under us
|
// 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)
|
err = lockFile(fProjects)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = lockFile(fProjid)
|
err = lockFile(fProjid)
|
||||||
@ -324,7 +324,7 @@ func createProjectID(path string, ID common.QuotaID) (common.QuotaID, error) {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
defer closeProjectFiles(fProjects, fProjid)
|
defer closeProjectFiles(fProjects, fProjid)
|
||||||
list := readProjectFiles(fProjects, fProjid)
|
list := readProjectFiles(fProjects, fProjid)
|
||||||
writeProjid := true
|
var writeProjid bool
|
||||||
ID, writeProjid, err = addDirToProject(path, ID, &list)
|
ID, writeProjid, err = addDirToProject(path, ID, &list)
|
||||||
if err == nil && ID != common.BadQuotaID {
|
if err == nil && ID != common.BadQuotaID {
|
||||||
if err = writeProjectFiles(fProjects, fProjid, writeProjid, list); err == nil {
|
if err = writeProjectFiles(fProjects, fProjid, writeProjid, list); err == nil {
|
||||||
@ -345,7 +345,7 @@ func removeProjectID(path string, ID common.QuotaID) error {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
defer closeProjectFiles(fProjects, fProjid)
|
defer closeProjectFiles(fProjects, fProjid)
|
||||||
list := readProjectFiles(fProjects, fProjid)
|
list := readProjectFiles(fProjects, fProjid)
|
||||||
writeProjid := true
|
var writeProjid bool
|
||||||
writeProjid, err = removeDirFromProject(path, ID, &list)
|
writeProjid, err = removeDirFromProject(path, ID, &list)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if err = writeProjectFiles(fProjects, fProjid, writeProjid, list); 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.
|
// we explicitly have to check in this case.
|
||||||
klog.V(4).Infof("clearQuotaOnDir %s", path)
|
klog.V(4).Infof("clearQuotaOnDir %s", path)
|
||||||
supportsQuotas, err := SupportsQuotas(m, 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 {
|
if !supportsQuotas {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -409,8 +414,12 @@ func ClearQuota(m mount.Interface, path string) error {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("ClearQuota: No quota available for %s", path)
|
return fmt.Errorf("ClearQuota: No quota available for %s", path)
|
||||||
}
|
}
|
||||||
var err error
|
|
||||||
projid, err := getQuotaOnDir(m, path)
|
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] {
|
if projid != dirQuotaMap[path] {
|
||||||
return fmt.Errorf("Expected quota ID %v on dir %s does not match actual %v", dirQuotaMap[path], path, projid)
|
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.
|
// - Volume does not support DeviceMounter interface.
|
||||||
// - In case of CSI the volume does not have node stage_unstage capability.
|
// - In case of CSI the volume does not have node stage_unstage capability.
|
||||||
if !resizeDone {
|
if !resizeDone {
|
||||||
resizeDone, resizeError = og.nodeExpandVolume(volumeToMount, resizeOptions)
|
_, resizeError = og.nodeExpandVolume(volumeToMount, resizeOptions)
|
||||||
if resizeError != nil {
|
if resizeError != nil {
|
||||||
klog.Errorf("MountVolume.NodeExpandVolume failed with %v", resizeError)
|
klog.Errorf("MountVolume.NodeExpandVolume failed with %v", resizeError)
|
||||||
return volumeToMount.GenerateError("MountVolume.Setup failed while expanding volume", 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))
|
dirs := strings.Split(rel, string(filepath.Separator))
|
||||||
|
|
||||||
parent := base
|
var parent string
|
||||||
currentPath := base
|
currentPath := base
|
||||||
for i, dir := range dirs {
|
for i, dir := range dirs {
|
||||||
parent = currentPath
|
parent = currentPath
|
||||||
|
Loading…
Reference in New Issue
Block a user