Skip to content

Commit

Permalink
Clarify log and return empty from helper functions
Browse files Browse the repository at this point in the history
Longhorn 2187

Signed-off-by: Eric Weber <eric.weber@suse.com>
  • Loading branch information
ejweber committed May 13, 2024
1 parent f879631 commit 66fa2e6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pkg/controller/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,8 @@ func tryFreeze(devicePath string, freezePoint string, mounter mount.Interface, e
mounted = true

// We must verify it is still safe to freeze the filesystem. If the source mount was unmounted by someone else
// before we bind mounted, the bind mount could refer to the root filesystem.
// before we bind mounted, the bind mount could refer to the root filesystem. It does not matter if the source
// mount is unmounted AFTER our bind mount, as the bind mount is not affected.
var device string
device, _, err = mount.GetDeviceNameFromMount(mounter, freezePoint)
if err != nil || device != devicePath {
Expand Down
2 changes: 1 addition & 1 deletion pkg/frontend/tgt/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (t *Tgt) Shutdown() error {
// If the engine is shutting down during a snapshot (in the preparation phase, before the snapshot operation obtains
// a lock) we may have left a frozen filesystem. This is a good opportunity to unfreeze it.
if err := util.UnfreezeFilesystemForDevice(t.Endpoint()); err != nil {
logrus.WithError(err).Errorf("Failed to clean up frozen file system during shutdown")
logrus.WithError(err).Errorf("Failed to clean up frozen file system; will continue tgt shutdown")
}

if t.dev != nil {
Expand Down
9 changes: 9 additions & 0 deletions pkg/util/fsfreeze.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,26 @@ const (
// GetFreezePointFromDevicePath returns the absolute path to the canonical location we will try to mount a filesystem to
// before freezeing it.
func GetFreezePointFromDevicePath(devicePath string) string {
if devicePath == "" {
return ""
}
return GetFreezePointFromVolumeName(filepath.Base(devicePath))
}

// GetFreezePointFromVolumeName returns the absolute path to the canonical location we will try to mount a filesystem to
// before freezeing it.
func GetFreezePointFromVolumeName(volumeName string) string {
if volumeName == "" {
return ""
}
return filepath.Join(freezePointDirectory, volumeName)
}

// GetDevicePathFromVolumeName mirrors longhorndev.getDev. It returns the device path that go-iscsi-helper will use.
func GetDevicePathFromVolumeName(volumeName string) string {
if volumeName == "" {
return ""
}
return filepath.Join(longhorndev.DevPath, volumeName)
}

Expand Down

0 comments on commit 66fa2e6

Please sign in to comment.