From b582f9e64a0c1a6ade99360b36790f28eb8491d4 Mon Sep 17 00:00:00 2001 From: Derek Su Date: Thu, 29 Jun 2023 15:51:54 +0800 Subject: [PATCH] Adjust log messages' levels Signed-off-by: Derek Su --- csi/crypto/crypto.go | 12 ++++++------ csi/util.go | 14 +++++++------- engineapi/backups.go | 4 ++-- manager/volume.go | 16 ++++++++-------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/csi/crypto/crypto.go b/csi/crypto/crypto.go index e825574ed0..68b53f9a7c 100644 --- a/csi/crypto/crypto.go +++ b/csi/crypto/crypto.go @@ -65,7 +65,7 @@ func VolumeMapper(volume string) string { // EncryptVolume encrypts provided device with LUKS. func EncryptVolume(devicePath, passphrase string, cryptoParams *EncryptParams) error { - logrus.Debugf("Encrypting device %s with LUKS", devicePath) + logrus.Infof("Encrypting device %s with LUKS", devicePath) if _, err := luksFormat(devicePath, passphrase, cryptoParams); err != nil { return fmt.Errorf("failed to encrypt device %s with LUKS: %w", devicePath, err) } @@ -75,21 +75,21 @@ func EncryptVolume(devicePath, passphrase string, cryptoParams *EncryptParams) e // OpenVolume opens volume so that it can be used by the client. func OpenVolume(volume, devicePath, passphrase string) error { if isOpen, _ := IsDeviceOpen(VolumeMapper(volume)); isOpen { - logrus.Debugf("device %s is already opened at %s", devicePath, VolumeMapper(volume)) + logrus.Debugf("Device %s is already opened at %s", devicePath, VolumeMapper(volume)) return nil } - logrus.Debugf("Opening device %s with LUKS on %s", devicePath, volume) + logrus.Infof("Opening device %s with LUKS on %s", devicePath, volume) _, err := luksOpen(volume, devicePath, passphrase) if err != nil { - logrus.Warnf("failed to open LUKS device %s: %s", devicePath, err) + logrus.WithError(err).Warnf("Failed to open LUKS device %s", devicePath) } return err } // CloseVolume closes encrypted volume so it can be detached. func CloseVolume(volume string) error { - logrus.Debugf("Closing LUKS device %s", volume) + logrus.Infof("Closing LUKS device %s", volume) _, err := luksClose(volume) return err } @@ -121,7 +121,7 @@ func DeviceEncryptionStatus(devicePath string) (mappedDevice, mapper string, err volume := strings.TrimPrefix(devicePath, mapperFilePathPrefix+"/") stdout, err := luksStatus(volume) if err != nil { - logrus.Debugf("device %s is not an active LUKS device: %v", devicePath, err) + logrus.WithError(err).Debugf("Device %s is not an active LUKS device", devicePath) return devicePath, "", nil } lines := strings.Split(string(stdout), "\n") diff --git a/csi/util.go b/csi/util.go index 1383c45926..5840cff234 100644 --- a/csi/util.go +++ b/csi/util.go @@ -244,7 +244,7 @@ func parseJSONRecurringJobs(jsonRecurringJobs string) ([]longhornclient.Recurrin // in case where the mount point exists but is corrupt, the mount point will be cleaned up and a error is returned // the underlying implementation utilizes mounter.IsLikelyNotMountPoint so it cannot detect bind mounts func ensureMountPoint(targetPath string, mounter mount.Interface) (bool, error) { - logrus.Debugf("trying to ensure mount point %v", targetPath) + logrus.Debugf("Trying to ensure mount point %v", targetPath) notMnt, err := mount.IsNotMountPoint(mounter, targetPath) if os.IsNotExist(err) { return false, os.MkdirAll(targetPath, 0750) @@ -252,9 +252,9 @@ func ensureMountPoint(targetPath string, mounter mount.Interface) (bool, error) IsCorruptedMnt := mount.IsCorruptedMnt(err) if !IsCorruptedMnt { - logrus.Debugf("mount point %v try reading dir to make sure it's healthy", targetPath) + logrus.Debugf("Mount point %v try reading dir to make sure it's healthy", targetPath) if _, err := os.ReadDir(targetPath); err != nil { - logrus.Debugf("mount point %v was identified as corrupt by ReadDir", targetPath) + logrus.Debugf("Mount point %v was identified as corrupt by ReadDir", targetPath) IsCorruptedMnt = true } } @@ -289,7 +289,7 @@ func unmount(targetPath string, mounter mount.Interface) error { if strings.Contains(err.Error(), "not mounted") || strings.Contains(err.Error(), "no mount point specified") { - logrus.Infof("no need for unmount not a mount point %v", targetPath) + logrus.Infof("No need for unmount not a mount point %v", targetPath) return nil } @@ -299,13 +299,13 @@ func unmount(targetPath string, mounter mount.Interface) error { // cleanupMountPoint ensures all mount layers for the targetPath are unmounted and the mount directory is removed func cleanupMountPoint(targetPath string, mounter mount.Interface) error { // we just try to unmount since the path check would get stuck for nfs mounts - logrus.Infof("trying to cleanup mount point %v", targetPath) + logrus.Infof("Trying to cleanup mount point %v", targetPath) if err := unmount(targetPath, mounter); err != nil { - logrus.Debugf("failed to unmount during cleanup error: %v", err) + logrus.WithError(err).Warn("Failed to unmount during cleanup") return err } - logrus.Infof("cleaned up mount point %v", targetPath) + logrus.Infof("Cleaned up mount point %v", targetPath) return mount.CleanupMountPoint(targetPath, mounter, true) } diff --git a/engineapi/backups.go b/engineapi/backups.go index b473d63141..07fba655d2 100644 --- a/engineapi/backups.go +++ b/engineapi/backups.go @@ -359,7 +359,7 @@ func (e *EngineBinary) SnapshotBackup(engine *longhorn.Engine, snapName, backupN return "", "", err } - logrus.Debugf("Backup %v created for volume %v snapshot %v", backupCreateInfo.BackupID, e.Name(), snapName) + logrus.Infof("Backup %v created for volume %v snapshot %v", backupCreateInfo.BackupID, e.Name(), snapName) return backupCreateInfo.BackupID, backupCreateInfo.ReplicaAddress, nil } @@ -426,7 +426,7 @@ func (e *EngineBinary) BackupRestore(engine *longhorn.Engine, backupTarget, back return taskErr } - logrus.Debugf("Backup %v restored for volume %v", backup, e.Name()) + logrus.Infof("Backup %v restored for volume %v", backup, e.Name()) return nil } diff --git a/manager/volume.go b/manager/volume.go index 2130e16a92..87d671de72 100644 --- a/manager/volume.go +++ b/manager/volume.go @@ -185,7 +185,7 @@ func (m *VolumeManager) Create(name string, spec *longhorn.VolumeSpec, recurring if err != nil { return nil, err } - logrus.Debugf("Created volume %v: %+v", v.Name, v.Spec) + logrus.Infof("Created volume %v: %+v", v.Name, v.Spec) return v, nil } @@ -193,7 +193,7 @@ func (m *VolumeManager) Delete(name string) error { if err := m.ds.DeleteVolume(name); err != nil { return err } - logrus.Debugf("Deleted volume %v", name) + logrus.Infof("Deleted volume %v", name) return nil } @@ -233,7 +233,7 @@ func (m *VolumeManager) Attach(name, nodeID string, disableFrontend bool, attach } if v.Spec.MigrationNodeID == node.Name { - logrus.Debugf("Volume %v is already migrating to node %v from node %v", v.Name, node.Name, v.Spec.NodeID) + logrus.Infof("Volume %v is already migrating to node %v from node %v", v.Name, node.Name, v.Spec.NodeID) return v, nil } @@ -390,7 +390,7 @@ func (m *VolumeManager) Salvage(volumeName string, replicaNames []string) (v *lo } } - logrus.Debugf("Salvaged replica %+v for volume %v", replicaNames, v.Name) + logrus.Infof("Salvaged replica %+v for volume %v", replicaNames, v.Name) return v, nil } @@ -433,7 +433,7 @@ func (m *VolumeManager) Activate(volumeName string, frontend string) (v *longhor return nil, err } - logrus.Debugf("Activating volume %v with frontend %v", v.Name, frontend) + logrus.Infof("Activating volume %v with frontend %v", v.Name, frontend) return v, nil } @@ -718,7 +718,7 @@ func (m *VolumeManager) DeleteReplica(volumeName, replicaName string) error { if err := m.ds.DeleteReplica(replicaName); err != nil { return err } - logrus.Debugf("Deleted replica %v of volume %v, there is still at least one available healthy replica %v", replicaName, volumeName, healthyReplica) + logrus.Infof("Deleted replica %v of volume %v, there is still at least one available healthy replica %v", replicaName, volumeName, healthyReplica) return nil } @@ -808,9 +808,9 @@ func (m *VolumeManager) EngineUpgrade(volumeName, image string) (v *longhorn.Vol return nil, err } if image != v.Status.CurrentImage { - logrus.Debugf("Upgrading volume %v engine image from %v to %v", v.Name, oldImage, v.Spec.EngineImage) + logrus.Infof("Upgrading volume %v engine image from %v to %v", v.Name, oldImage, v.Spec.EngineImage) } else { - logrus.Debugf("Rolling back volume %v engine image to %v", v.Name, v.Status.CurrentImage) + logrus.Infof("Rolling back volume %v engine image to %v", v.Name, v.Status.CurrentImage) } return v, nil