@@ -11,7 +11,6 @@ import (
1111 "fmt"
1212 "os"
1313 "os/exec"
14- "path/filepath"
1514 "regexp"
1615 "strconv"
1716 "strings"
@@ -154,7 +153,7 @@ func New() (*Client, error) {
154153 chrootPathPrefix := osutils .ChrootPathPrefix
155154
156155 osUtils := osutils .New ()
157- reconcileutils := NewReconcileUtils (chrootPathPrefix , osUtils )
156+ reconcileutils := NewReconcileUtils ()
158157 osFs := afero.Afero {Fs : afero .NewOsFs ()}
159158 mountClient , err := mount .New ()
160159 if err != nil {
@@ -170,8 +169,7 @@ func New() (*Client, error) {
170169
171170func NewDetailed (chrootPathPrefix string , command tridentexec.Command , selfHealingExclusion []string , osClient OS ,
172171 devices devices.Devices , fileSystemClient filesystem.Filesystem , mountClient mount.Mount ,
173- iscsiUtils IscsiReconcileUtils ,
174- os afero.Afero , osUtils osutils.Utils ,
172+ iscsiUtils IscsiReconcileUtils , os afero.Afero , osUtils osutils.Utils ,
175173) * Client {
176174 return & Client {
177175 chrootPathPrefix : chrootPathPrefix ,
@@ -1896,7 +1894,7 @@ func (client *Client) SafeToLogOut(ctx context.Context, hostNumber, sessionNumbe
18961894 // See drivers/scsi/scsi_scan.c in Linux
18971895 // We assume the channel/bus and device/controller are always zero for iSCSI
18981896 targetPath := devicePath + fmt .Sprintf ("/session%d/target%d:0:0" , sessionNumber , hostNumber )
1899- dirs , err := os .ReadDir (targetPath )
1897+ dirs , err := client . os .ReadDir (targetPath )
19001898 if err != nil {
19011899 if os .IsNotExist (err ) {
19021900 return true
@@ -1970,7 +1968,7 @@ func (c *Client) GetISCSIDevices(ctx context.Context, getCredentials bool) ([]*m
19701968
19711969 // Start by reading the sessions from /sys/class/iscsi_session
19721970 sysPath := c .chrootPathPrefix + "/sys/class/iscsi_session/"
1973- sessionDirs , err := os .ReadDir (sysPath )
1971+ sessionDirs , err := c . os .ReadDir (sysPath )
19741972 if err != nil {
19751973 Logc (ctx ).WithField ("error" , err ).Errorf ("Could not read %s" , sysPath )
19761974 return nil , err
@@ -2003,7 +2001,7 @@ func (c *Client) GetISCSIDevices(ctx context.Context, getCredentials bool) ([]*m
20032001 sessionValues := make (map [string ]string , len (sessionFiles ))
20042002 for file , value := range sessionFiles {
20052003 path := sessionPath + "/" + file
2006- fileBytes , err := os .ReadFile (path )
2004+ fileBytes , err := c . os .ReadFile (path )
20072005 if err != nil {
20082006 Logc (ctx ).WithFields (LogFields {
20092007 "path" : path ,
@@ -2044,7 +2042,7 @@ func (c *Client) GetISCSIDevices(ctx context.Context, getCredentials bool) ([]*m
20442042
20452043 // Find the one target at /sys/class/iscsi_session/sessionXXX/device/targetHH:BB:DD (host:bus:device)
20462044 sessionDevicePath := sessionPath + "/device/"
2047- targetDirs , err := os .ReadDir (sessionDevicePath )
2045+ targetDirs , err := c . os .ReadDir (sessionDevicePath )
20482046 if err != nil {
20492047 Logc (ctx ).WithField ("error" , err ).Errorf ("Could not read %s" , sessionDevicePath )
20502048 return nil , err
@@ -2076,7 +2074,7 @@ func (c *Client) GetISCSIDevices(ctx context.Context, getCredentials bool) ([]*m
20762074 }).Debug ("Found host/bus/device path." )
20772075
20782076 // Find the devices at /sys/class/iscsi_session/sessionXXX/device/targetHH:BB:DD/HH:BB:DD:LL (host:bus:device:lun)
2079- hostBusDeviceLunDirs , err := os .ReadDir (sessionDeviceHBDPath )
2077+ hostBusDeviceLunDirs , err := c . os .ReadDir (sessionDeviceHBDPath )
20802078 if err != nil {
20812079 Logc (ctx ).WithField ("error" , err ).Errorf ("Could not read %s" , sessionDeviceHBDPath )
20822080 return nil , err
@@ -2110,7 +2108,7 @@ func (c *Client) GetISCSIDevices(ctx context.Context, getCredentials bool) ([]*m
21102108 blockPath := sessionDeviceHBDLPath + "/block/"
21112109
21122110 // Find the block device at /sys/class/iscsi_session/sessionXXX/device/targetHH:BB:DD/HH:BB:DD:LL/block
2113- blockDeviceDirs , err := os .ReadDir (blockPath )
2111+ blockDeviceDirs , err := c . os .ReadDir (blockPath )
21142112 if err != nil {
21152113 Logc (ctx ).WithField ("error" , err ).Errorf ("Could not read %s" , blockPath )
21162114 return nil , err
@@ -2195,7 +2193,7 @@ func (client *Client) GetMountedISCSIDevices(ctx context.Context) ([]*models.Scs
21952193 var mountedDevice string
21962194 // Resolve any symlinks to get the real device
21972195 if hasDevMountSourcePrefix {
2198- device , err := filepath .EvalSymlinks (procMount .MountSource )
2196+ device , err := client . osUtils .EvalSymlinks (procMount .MountSource )
21992197 if err != nil {
22002198 Logc (ctx ).Error (err )
22012199 continue
0 commit comments