diff --git a/internal/cephfs/controllerserver.go b/internal/cephfs/controllerserver.go index db34aa69d..30c41a301 100644 --- a/internal/cephfs/controllerserver.go +++ b/internal/cephfs/controllerserver.go @@ -61,7 +61,7 @@ func (cs *ControllerServer) createBackingVolume( var err error if sID != nil { if err = cs.OperationLocks.GetRestoreLock(sID.SnapshotID); err != nil { - klog.Error(util.Log(ctx, err.Error())) + util.ErrorLog(util.Log(ctx, err.Error())) return status.Error(codes.Aborted, err.Error()) } defer cs.OperationLocks.ReleaseRestoreLock(sID.SnapshotID) diff --git a/internal/util/cephcmds.go b/internal/util/cephcmds.go index 099b2ff7c..87cd9de3a 100644 --- a/internal/util/cephcmds.go +++ b/internal/util/cephcmds.go @@ -146,7 +146,7 @@ func CreateObject(ctx context.Context, monitors string, cr *Credentials, poolNam if errors.Is(err, rados.ErrObjectExists) { return JoinErrors(ErrObjectExists, err) } else if err != nil { - ErrorLog(Log(ctx, "failed creating omap (%s) in pool (%s): (%v)"), objectName, poolName, err) + ErrorLogMsg(Log(ctx, "failed creating omap (%s) in pool (%s): (%v)"), objectName, poolName, err) return err } @@ -180,7 +180,7 @@ func RemoveObject(ctx context.Context, monitors string, cr *Credentials, poolNam if errors.Is(err, rados.ErrNotFound) { return JoinErrors(ErrObjectNotFound, err) } else if err != nil { - ErrorLog(Log(ctx, "failed removing omap (%s) in pool (%s): (%v)"), oMapName, poolName, err) + ErrorLogMsg(Log(ctx, "failed removing omap (%s) in pool (%s): (%v)"), oMapName, poolName, err) return err } diff --git a/internal/util/crypto.go b/internal/util/crypto.go index fa2b2c2c2..39323143c 100644 --- a/internal/util/crypto.go +++ b/internal/util/crypto.go @@ -158,7 +158,7 @@ func GetCryptoPassphrase(ctx context.Context, volumeID string, kms EncryptionKMS } return passphrase, nil } - ErrorLog(Log(ctx, "failed to get encryption passphrase for %s: %s"), volumeID, err) + ErrorLogMsg(Log(ctx, "failed to get encryption passphrase for %s: %s"), volumeID, err) return "", err } diff --git a/internal/util/idlocker.go b/internal/util/idlocker.go index 1ca2cc31b..adf8486cc 100644 --- a/internal/util/idlocker.go +++ b/internal/util/idlocker.go @@ -253,6 +253,6 @@ func (ol *OperationLock) release(op operation, volumeID string) { } } default: - ErrorLog("%v operation not supported", op) + ErrorLogMsg("%v operation not supported", op) } } diff --git a/internal/util/log.go b/internal/util/log.go index 97b79a0d2..4b5e28be3 100644 --- a/internal/util/log.go +++ b/internal/util/log.go @@ -58,8 +58,8 @@ func FatalLog(message string, args ...interface{}) { klog.FatalDepth(1, logMessage) } -// ErrorLog helps in logging errors. -func ErrorLog(message string, args ...interface{}) { +// ErrorLogMsg helps in logging errors with message. +func ErrorLogMsg(message string, args ...interface{}) { logMessage := fmt.Sprintf(message, args...) klog.ErrorDepth(1, logMessage) } diff --git a/internal/util/util.go b/internal/util/util.go index b04565999..99c455107 100644 --- a/internal/util/util.go +++ b/internal/util/util.go @@ -173,12 +173,12 @@ func CheckKernelSupport(release string, supportedVersions []KernelVersion) bool vers := strings.Split(strings.SplitN(release, "-", 2)[0], ".") version, err := strconv.Atoi(vers[0]) if err != nil { - ErrorLog("failed to parse version from %s: %v", release, err) + ErrorLogMsg("failed to parse version from %s: %v", release, err) return false } patchlevel, err := strconv.Atoi(vers[1]) if err != nil { - ErrorLog("failed to parse patchlevel from %s: %v", release, err) + ErrorLogMsg("failed to parse patchlevel from %s: %v", release, err) return false } sublevel := 0 @@ -186,7 +186,7 @@ func CheckKernelSupport(release string, supportedVersions []KernelVersion) bool if len(vers) >= minLenForSublvl { sublevel, err = strconv.Atoi(vers[2]) if err != nil { - ErrorLog("failed to parse sublevel from %s: %v", release, err) + ErrorLogMsg("failed to parse sublevel from %s: %v", release, err) return false } } @@ -223,7 +223,7 @@ func CheckKernelSupport(release string, supportedVersions []KernelVersion) bool } } } - ErrorLog("kernel %s does not support required features", release) + ErrorLogMsg("kernel %s does not support required features", release) return false }