Skip to content

Ticket 109 - Add allowMultipleSessions StorageClass Parameter for iSCSI Volumes#127

Open
smurfless1 wants to merge 2 commits into
SynologyOpenSource:mainfrom
smurfless1:ticket109
Open

Ticket 109 - Add allowMultipleSessions StorageClass Parameter for iSCSI Volumes#127
smurfless1 wants to merge 2 commits into
SynologyOpenSource:mainfrom
smurfless1:ticket109

Conversation

@smurfless1

Copy link
Copy Markdown

Summary

  • Adds a new allowMultipleSessions StorageClass parameter that enables multiple iSCSI sessions to a target from one or more initiators
  • This is required for PVC remount after node restarts in certain scenarios

Changes

New Feature:

  • pkg/driver/controllerserver.go: Parse and handle the new allowMultipleSessions parameter for iSCSI targets
  • README.md: Document the new parameter in the StorageClass parameters table
  • pkg/driver/controllerserver_test.go: Add comprehensive unit tests for the new parameter (324 lines)

Bug Fixes:

  • pkg/driver/multipath.go:76: Fix format specifier (%s → %d) for integer exit status
  • pkg/driver/nodeserver.go:182: Fix missing dsmIp argument in log statement

Code Quality:

  • pkg/dsm/webapi/iscsi.go:132: Use keyed struct literal for IscsiDefaultError
  • pkg/dsm/webapi/share.go:106: Use keyed struct literal for ShareDefaultError

Test Updates:

  • test/sanity/sanity_test.go: Update sanity test to use iSCSI protocol with the new parameter

smurfless1 and others added 2 commits January 27, 2026 22:46
Adds a new StorageClass parameter 'allowMultipleSessions' that enables
multiple iSCSI sessions to a target, allowing PVCs to remount after node
or pod restarts without requiring ReadWriteMany access mode.

This resolves issues where ReadWriteOnce PVCs fail to remount after node
restarts because Synology DSM blocks multiple sessions by default.

Changes:
- Add allowMultipleSessions parameter parsing in controllerserver.go
- Enable multi-session when parameter is true, regardless of access mode
- Add comprehensive unit tests for parameter behavior
- Update README.md with parameter documentation
- Update sanity tests to use iSCSI with allowMultipleSessions

Bug fixes:
- Fix format string mismatch in multipath.go (use %d for integer)
- Fix missing dsmIp argument in nodeserver.go log statement
- Fix unkeyed struct literals in iscsi.go and share.go

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@@ -0,0 +1,324 @@
/*
Copyright 2021 Synology Inc.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's a few years between friends?

Comment thread pkg/driver/multipath.go
if ee, ok := err.(utilexec.ExitError); ok {
log.Errorf("Non-zero exit code: %s", err)
err = fmt.Errorf("%s", ee.ExitStatus())
err = fmt.Errorf("%d", ee.ExitStatus())

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These other fixes were simply because my linter would not let it go.

log.Infof("Volume [%s]: allowMultipleSessions parameter ignored for protocol [%s]", volName, protocol)
} else if allowMultipleSessions && !multiSession {
log.Infof("Enabling multi-session for volume [%s] via allowMultipleSessions parameter", volName)
multiSession = true

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was mentioned in the discussion of ticket 109. I simply had Claude help me through implementing it in a clear way.
I'm actually running this version on my NAS and have had k3s and microk8s quite happy with it for a week and change, so I'm happy so far.

}
}

func TestCreateVolume_AllowMultipleSessions(t *testing.T) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was particularly stern with Claude that we must have tests for the new functionality. They mostly center on configuration, but as really the change is mostly about configuration, I shouldn't be surprised.

@smurfless1

Copy link
Copy Markdown
Author

Issue link with really good root cause discussion:
#109

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant