Skip to content

Commit

Permalink
Adjust log messages' levels
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Su <derek.su@suse.com>
  • Loading branch information
derekbit authored and David Ko committed Jul 3, 2023
1 parent 4a57a72 commit b582f9e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
12 changes: 6 additions & 6 deletions csi/crypto/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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")
Expand Down
14 changes: 7 additions & 7 deletions csi/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,17 +244,17 @@ 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)
}

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
}
}
Expand Down Expand Up @@ -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
}

Expand All @@ -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)
}

Expand Down
4 changes: 2 additions & 2 deletions engineapi/backups.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down
16 changes: 8 additions & 8 deletions manager/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@ 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
}

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
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b582f9e

Please sign in to comment.