mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 06:27:05 +00:00
fix some log typos in csi_mounter.go
cleanup: remove logging duplicated error message fix error msg, include err in new returned errors. Signed-off-by: ethan <guangming.wang@daocloud.io>
This commit is contained in:
parent
030274eba3
commit
ec2c5dff43
@ -19,6 +19,7 @@ package csi
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
@ -103,8 +104,7 @@ func (c *csiMountMgr) SetUpAt(dir string, mounterArgs volume.MounterArgs) error
|
||||
|
||||
mounted, err := isDirMounted(c.plugin, dir)
|
||||
if err != nil {
|
||||
klog.Error(log("mounter.SetUpAt failed while checking mount status for dir [%s]", dir))
|
||||
return err
|
||||
return errors.New(log("mounter.SetUpAt failed while checking mount status for dir [%s]: %v", dir, err))
|
||||
}
|
||||
|
||||
if mounted {
|
||||
@ -114,16 +114,14 @@ func (c *csiMountMgr) SetUpAt(dir string, mounterArgs volume.MounterArgs) error
|
||||
|
||||
csi, err := c.csiClientGetter.Get()
|
||||
if err != nil {
|
||||
klog.Error(log("mounter.SetUpAt failed to get CSI client: %v", err))
|
||||
return err
|
||||
return errors.New(log("mounter.SetUpAt failed to get CSI client: %v", err))
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), csiTimeout)
|
||||
defer cancel()
|
||||
|
||||
volSrc, pvSrc, err := getSourceFromSpec(c.spec)
|
||||
if err != nil {
|
||||
klog.Error(log("mounter.SetupAt failed to get CSI persistent source: %v", err))
|
||||
return err
|
||||
return errors.New(log("mounter.SetupAt failed to get CSI persistent source: %v", err))
|
||||
}
|
||||
|
||||
driverName := c.driverName
|
||||
@ -183,15 +181,13 @@ func (c *csiMountMgr) SetUpAt(dir string, mounterArgs volume.MounterArgs) error
|
||||
// Check for STAGE_UNSTAGE_VOLUME set and populate deviceMountPath if so
|
||||
stageUnstageSet, err := csi.NodeSupportsStageUnstage(ctx)
|
||||
if err != nil {
|
||||
klog.Error(log("mounter.SetUpAt failed to check for STAGE_UNSTAGE_VOLUME capabilty: %v", err))
|
||||
return err
|
||||
return errors.New(log("mounter.SetUpAt failed to check for STAGE_UNSTAGE_VOLUME capability: %v", err))
|
||||
}
|
||||
|
||||
if stageUnstageSet {
|
||||
deviceMountPath, err = makeDeviceMountPath(c.plugin, c.spec)
|
||||
if err != nil {
|
||||
klog.Error(log("mounter.SetUpAt failed to make device mount path: %v", err))
|
||||
return err
|
||||
return errors.New(log("mounter.SetUpAt failed to make device mount path: %v", err))
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,8 +207,7 @@ func (c *csiMountMgr) SetUpAt(dir string, mounterArgs volume.MounterArgs) error
|
||||
|
||||
// create target_dir before call to NodePublish
|
||||
if err := os.MkdirAll(dir, 0750); err != nil {
|
||||
klog.Error(log("mouter.SetUpAt failed to create dir %#v: %v", dir, err))
|
||||
return err
|
||||
return errors.New(log("mounter.SetUpAt failed to create dir %#v: %v", dir, err))
|
||||
}
|
||||
klog.V(4).Info(log("created target path successfully [%s]", dir))
|
||||
|
||||
@ -229,8 +224,7 @@ func (c *csiMountMgr) SetUpAt(dir string, mounterArgs volume.MounterArgs) error
|
||||
// Inject pod information into volume_attributes
|
||||
podAttrs, err := c.podAttributes()
|
||||
if err != nil {
|
||||
klog.Error(log("mouter.SetUpAt failed to assemble volume attributes: %v", err))
|
||||
return err
|
||||
return errors.New(log("mounter.SetUpAt failed to assemble volume attributes: %v", err))
|
||||
}
|
||||
if podAttrs != nil {
|
||||
if volAttribs == nil {
|
||||
@ -257,11 +251,10 @@ func (c *csiMountMgr) SetUpAt(dir string, mounterArgs volume.MounterArgs) error
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
klog.Errorf(log("mounter.SetupAt failed: %v", err))
|
||||
if removeMountDirErr := removeMountDir(c.plugin, dir); removeMountDirErr != nil {
|
||||
klog.Error(log("mounter.SetupAt failed to remove mount dir after a NodePublish() error [%s]: %v", dir, removeMountDirErr))
|
||||
}
|
||||
return err
|
||||
return errors.New(log("mounter.SetupAt failed: %v", err))
|
||||
}
|
||||
|
||||
// apply volume ownership
|
||||
@ -356,22 +349,19 @@ func (c *csiMountMgr) TearDownAt(dir string) error {
|
||||
volID := c.volumeID
|
||||
csi, err := c.csiClientGetter.Get()
|
||||
if err != nil {
|
||||
klog.Error(log("mounter.SetUpAt failed to get CSI client: %v", err))
|
||||
return err
|
||||
return errors.New(log("mounter.SetUpAt failed to get CSI client: %v", err))
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), csiTimeout)
|
||||
defer cancel()
|
||||
|
||||
if err := csi.NodeUnpublishVolume(ctx, volID, dir); err != nil {
|
||||
klog.Errorf(log("mounter.TearDownAt failed: %v", err))
|
||||
return err
|
||||
return errors.New(log("mounter.TearDownAt failed: %v", err))
|
||||
}
|
||||
|
||||
// clean mount point dir
|
||||
if err := removeMountDir(c.plugin, dir); err != nil {
|
||||
klog.Error(log("mounter.TearDownAt failed to clean mount dir [%s]: %v", dir, err))
|
||||
return err
|
||||
return errors.New(log("mounter.TearDownAt failed to clean mount dir [%s]: %v", dir, err))
|
||||
}
|
||||
klog.V(4).Infof(log("mounter.TearDownAt successfully unmounted dir [%s]", dir))
|
||||
|
||||
@ -437,22 +427,19 @@ func removeMountDir(plug *csiPlugin, mountPath string) error {
|
||||
if !mnt {
|
||||
klog.V(4).Info(log("dir not mounted, deleting it [%s]", mountPath))
|
||||
if err := os.Remove(mountPath); err != nil && !os.IsNotExist(err) {
|
||||
klog.Error(log("failed to remove dir [%s]: %v", mountPath, err))
|
||||
return err
|
||||
return errors.New(log("failed to remove dir [%s]: %v", mountPath, err))
|
||||
}
|
||||
// remove volume data file as well
|
||||
volPath := path.Dir(mountPath)
|
||||
dataFile := filepath.Join(volPath, volDataFileName)
|
||||
klog.V(4).Info(log("also deleting volume info data file [%s]", dataFile))
|
||||
if err := os.Remove(dataFile); err != nil && !os.IsNotExist(err) {
|
||||
klog.Error(log("failed to delete volume data file [%s]: %v", dataFile, err))
|
||||
return err
|
||||
return errors.New(log("failed to delete volume data file [%s]: %v", dataFile, err))
|
||||
}
|
||||
// remove volume path
|
||||
klog.V(4).Info(log("deleting volume path [%s]", volPath))
|
||||
if err := os.Remove(volPath); err != nil && !os.IsNotExist(err) {
|
||||
klog.Error(log("failed to delete volume path [%s]: %v", volPath, err))
|
||||
return err
|
||||
return errors.New(log("failed to delete volume path [%s]: %v", volPath, err))
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user