Skip to content

Commit

Permalink
Simplify logging and function names for iscsi self-healing enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
jwebster7 authored May 6, 2024
1 parent 0475aea commit 1055df2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
19 changes: 8 additions & 11 deletions frontend/csi/node_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2014,7 +2014,7 @@ func (p *Plugin) selfHealingRectifySession(ctx context.Context, portal string, a
// Login is successful, fallthrough to perform scan
fallthrough
case utils.Scan:
if p.outdatedAccessControlInUse(ctx) {
if p.deprecatedIgroupInUse(ctx) {
Logc(ctx).WithField("lunID", lunID).Debug("Initiating SCSI scan for exact LUN.")

if err := utils.InitiateScanForLun(ctx, int(lunID), targetIQN); err != nil {
Expand All @@ -2038,24 +2038,21 @@ func (p *Plugin) selfHealingRectifySession(ctx context.Context, portal string, a
return nil
}

// outdatedAccessControlInUse looks for older access control mechanisms (like backend-scoped initiator groups)
// and reports if any are in use on this host.
func (p *Plugin) outdatedAccessControlInUse(ctx context.Context) bool {
Logc(ctx).Debug("Determining if outdated access control schemas are in use.")

// deprecatedIgroupInUse looks through the tracking files for deprecated igroups and reports if any are in use.
func (p *Plugin) deprecatedIgroupInUse(ctx context.Context) bool {
volumeTrackingInfo, _ := p.nodeHelper.ListVolumeTrackingInfo(ctx)
for id, info := range volumeTrackingInfo {
if !utils.IsPerNodeIgroup(info.IscsiIgroup) {
Logc(ctx).WithFields(LogFields{
"volumeID": id,
"lunID": info.IscsiLunNumber,
"initiatorGroup": info.IscsiIgroup,
}).Debug("Detected an outdated access control schema is in use.")
"volumeID": id,
"lunID": info.IscsiLunNumber,
"igroup": info.IscsiIgroup,
}).Debug("Detected a deprecated igroup.")
return true
}
}

Logc(ctx).Debug("No outdated access control schema detected.")
Logc(ctx).Debug("No deprecated igroups detected.")
return false
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/csi/node_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,7 @@ func TestOutdatedAccessControlInUse(t *testing.T) {
mockHelper.EXPECT().ListVolumeTrackingInfo(ctx).Return(data.tracking, nil).Times(1)

p := Plugin{nodeHelper: mockHelper}
assert.Equal(t, data.expected, p.outdatedAccessControlInUse(ctx))
assert.Equal(t, data.expected, p.deprecatedIgroupInUse(ctx))
})
}
}

0 comments on commit 1055df2

Please sign in to comment.