Skip to content

Commit a92cb7e

Browse files
authored
Remove adapters
remove utils refactor adapter code
1 parent aa21043 commit a92cb7e

File tree

17 files changed

+1226
-1208
lines changed

17 files changed

+1226
-1208
lines changed

frontend/csi/node_server.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,7 +1625,7 @@ func (p *Plugin) nodeStageISCSIVolume(
16251625
// Update in-mem map used for self-healing; do it after a volume has been staged.
16261626
// Beyond here if there is a problem with the session or there are missing LUNs
16271627
// then self-healing should be able to fix those issues.
1628-
newCtx := context.WithValue(ctx, iscsi.SessionInfoSource, utils.SessionSourceNodeStage)
1628+
newCtx := context.WithValue(ctx, iscsi.SessionInfoSource, iscsi.SessionSourceNodeStage)
16291629
p.iscsi.AddSession(newCtx, &publishedISCSISessions, publishInfo, req.GetVolumeId(), "", models.NotInvalid)
16301630
return nil
16311631
}
@@ -2353,7 +2353,7 @@ func (p *Plugin) performISCSISelfHealing(ctx context.Context) {
23532353
Logc(ctx).WithError(err).Error("Failed to reset remediation value(s) for published iSCSI sessions. ")
23542354
}
23552355

2356-
if err := utils.PopulateCurrentSessions(ctx, &currentISCSISessions); err != nil {
2356+
if err := p.iscsi.PopulateCurrentSessions(ctx, &currentISCSISessions); err != nil {
23572357
Logc(ctx).WithError(err).
23582358
Error("Failed to get current state of iSCSI Sessions LUN mappings; skipping iSCSI self-heal cycle.")
23592359
return
@@ -2374,7 +2374,7 @@ func (p *Plugin) performISCSISelfHealing(ctx context.Context) {
23742374
// to temporary networking issue or logged-out sessions or LUNs that were never scanned for some sessions.
23752375

23762376
// SELF-HEAL STEP 1: Identify all sorted candidate stale portals and sorted candidate non-stale portals.
2377-
staleISCSIPortals, nonStaleISCSIPortals := utils.InspectAllISCSISessions(ctx, &publishedISCSISessions,
2377+
staleISCSIPortals, nonStaleISCSIPortals := p.iscsi.InspectAllISCSISessions(ctx, &publishedISCSISessions,
23782378
&currentISCSISessions, p.iSCSISelfHealingWaitTime)
23792379

23802380
// SELF-HEAL STEP 2: Attempt to fix all the stale portals.

frontend/csi/node_server_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ func getPortals(sessions *models.ISCSISessions, portalActions []PortalAction) []
11021102
portals[idx] = portalAction.Portal
11031103
}
11041104

1105-
utils.SortPortals(portals, sessions)
1105+
iscsi.SortPortals(portals, sessions)
11061106

11071107
return portals
11081108
}

mocks/mock_utils/mock_fcp/mock_fcp_client.go

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mocks/mock_utils/mock_iscsi/mock_iscsi_client.go

Lines changed: 86 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

storage_drivers/common.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,14 +363,15 @@ func RemoveSCSIDeviceByPublishInfo(ctx context.Context, publishInfo *tridentmode
363363
return
364364
}
365365

366-
deviceInfo, err := utils.GetDeviceInfoForLUN(ctx, hostSessionMap, int(publishInfo.IscsiLunNumber), publishInfo.IscsiTargetIQN, false)
366+
deviceInfo, err := utils.IscsiClient.GetDeviceInfoForLUN(ctx, hostSessionMap, int(publishInfo.IscsiLunNumber),
367+
publishInfo.IscsiTargetIQN, false)
367368
if err != nil {
368369
Logc(ctx).WithError(err).WithFields(fields).Error("Error getting device info.")
369370
} else if deviceInfo == nil {
370371
Logc(ctx).WithFields(fields).Error("No device info found.")
371372
} else {
372373
// Inform the host about the device removal
373-
if _, err := utils.PrepareDeviceForRemoval(ctx, deviceInfo, publishInfo, nil, true, false); err != nil {
374+
if _, err := utils.IscsiClient.PrepareDeviceForRemoval(ctx, deviceInfo, publishInfo, nil, true, false); err != nil {
374375
Logc(ctx).WithError(err).WithFields(fields).Error("Error removing device.")
375376
}
376377
}
@@ -382,15 +383,16 @@ func RemoveSCSIDeviceByPublishInfo(ctx context.Context, publishInfo *tridentmode
382383
return
383384
}
384385

385-
deviceInfo, err := utils.GetDeviceInfoForFCPLUN(ctx, hostSessionMap, int(publishInfo.FCPLunNumber),
386+
deviceInfo, err := utils.FcpClient.GetDeviceInfoForFCPLUN(ctx, hostSessionMap, int(publishInfo.FCPLunNumber),
386387
publishInfo.FCTargetWWNN, false)
387388
if err != nil {
388389
Logc(ctx).WithError(err).WithFields(fields).Error("Error getting device info.")
389390
} else if deviceInfo == nil {
390391
Logc(ctx).WithFields(fields).Error("No device info found.")
391392
} else {
392393
// Inform the host about the device removal
393-
if _, err := utils.PrepareDeviceForRemoval(ctx, deviceInfo, publishInfo, nil, true, false); err != nil {
394+
if _, err := utils.IscsiClient.PrepareDeviceForRemoval(ctx, deviceInfo, publishInfo, nil, true,
395+
false); err != nil {
394396
Logc(ctx).WithError(err).WithFields(fields).Error("Error removing device.")
395397
}
396398
}

storage_drivers/ontap/ontap_common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,7 @@ func ValidateSANDriver(
15561556
case tridentconfig.ContextDocker:
15571557
// Make sure this host is logged into the ONTAP iSCSI target
15581558
if config.SANType == sa.ISCSI {
1559-
err := utils.EnsureISCSISessionsWithPortalDiscovery(ctx, ips)
1559+
err := utils.IscsiClient.EnsureISCSISessionsWithPortalDiscovery(ctx, ips)
15601560
if err != nil {
15611561
return fmt.Errorf("error establishing iSCSI session: %v", err)
15621562
}

storage_drivers/solidfire/solidfire_san.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
sa "github.com/netapp/trident/storage_attribute"
2727
drivers "github.com/netapp/trident/storage_drivers"
2828
"github.com/netapp/trident/storage_drivers/solidfire/api"
29-
"github.com/netapp/trident/utils"
3029
"github.com/netapp/trident/utils/errors"
3130
"github.com/netapp/trident/utils/filesystem"
3231
"github.com/netapp/trident/utils/iscsi"
@@ -636,7 +635,7 @@ func (d *SANStorageDriver) validate(ctx context.Context) error {
636635

637636
if d.Config.DriverContext == tridentconfig.ContextDocker {
638637
// Validate the environment
639-
isIscsiSupported := utils.ISCSISupported(ctx)
638+
isIscsiSupported := d.iscsi.Supported(ctx)
640639
if !isIscsiSupported {
641640
Logc(ctx).Error("Host doesn't appear to support iSCSI.")
642641
return errors.New("no iSCSI support on this host")

utils/adaptors.go

Lines changed: 0 additions & 45 deletions
This file was deleted.

utils/devices/devices.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -590,15 +590,6 @@ func (c *Client) RemoveMultipathDeviceMappingWithRetries(ctx context.Context, de
590590
return nil
591591
}
592592

593-
// ------ TODO remove: temporary functions to bridge the gap while we transition to the new iscsi client ------
594-
595-
//func GetDeviceInfoForLUN(
596-
// ctx context.Context, hostSessionMap map[int]int, lunID int, iSCSINodeName string, isDetachCall bool,
597-
//) (*models.ScsiDeviceInfo, error) {
598-
// // TODO: check if we require both isDetachCall and needFSType
599-
// return iscsiClient.GetDeviceInfoForLUN(ctx, hostSessionMap, lunID, iSCSINodeName, isDetachCall)
600-
//}
601-
602593
// FindMultipathDeviceForDevice finds the devicemapper parent of a device name like /dev/sdx.
603594
func (c *Client) FindMultipathDeviceForDevice(ctx context.Context, device string) string {
604595
Logc(ctx).WithField("device", device).Debug(">>>> iscsi.findMultipathDeviceForDevice")

utils/fcp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ import (
1111
var (
1212
command = exec.NewCommand()
1313
FcpUtils = fcp.NewReconcileUtils(osutils.ChrootPathPrefix, osutils.New())
14-
fcpClient = fcp.NewDetailed(osutils.ChrootPathPrefix, command, fcp.DefaultSelfHealingExclusion, osutils.New(),
14+
FcpClient = fcp.NewDetailed(osutils.ChrootPathPrefix, command, fcp.DefaultSelfHealingExclusion, osutils.New(),
1515
devices.New(), filesystem.New(mountClient), mountClient, FcpUtils)
1616
)

0 commit comments

Comments
 (0)