Skip to content

feat: add support for iscsidirect protocol#63

Open
plieven wants to merge 6 commits intokolesa-team:mainfrom
plieven:feat/iscsidirect
Open

feat: add support for iscsidirect protocol#63
plieven wants to merge 6 commits intokolesa-team:mainfrom
plieven:feat/iscsidirect

Conversation

@plieven
Copy link
Copy Markdown
Contributor

@plieven plieven commented Mar 20, 2025

this adds support protocol type iscsidirect which allows to connect to a pure store without the need for open-iscsi or multipathd.

Signed-off-by: Peter Lieven <pl@dlhnet.de>
@plieven plieven requested a review from timansky as a code owner March 20, 2025 13:18
plieven added 3 commits March 20, 2025 14:46
we need this later to get the LUN for a connected volume.
So this introduces the GET method for connections.
Consequently use this also to connect a volume if it is not yet
connected and disconnect it only if it is currently connected.

Signed-off-by: Peter Lieven <pl@dlhnet.de>
this adds support protocol type iscsidirect which allows to connect to a pure
store without the need for open-iscsi or multipathd.

Signed-off-by: Peter Lieven <pl@dlhnet.de>
Signed-off-by: Peter Lieven <pl@dlhnet.de>
@timansky timansky requested a review from amulet1 March 26, 2025 06:38
timansky
timansky previously approved these changes Mar 26, 2025
Copy link
Copy Markdown
Collaborator

@amulet1 amulet1 left a comment

Choose a reason for hiding this comment

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

Overall this is a good addition.

$name = 'create volume connection';
$ignore = 'Connection already exists.';
my $ignore = '';
if ( !defined($mode) ) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could we instead of using undefined $mode for PATCH change it as following:
DELETE if $mode == -1, "PATCHif$mode == 0, 'POST' if $mode == 1`?

I think it would make it "cleaner". But also please see my other comments, as I think the connection check is not really needed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We have DELETE, GET and POST. We can use -1, 0 and +1 for that.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes, I meant to write GET, not PATCH.


my $protocol = $scfg->{ protocol } // $default_protocol;
if ( $protocol eq "iscsidirect" ) {
die "Error :: path: snapshot is not implemented ($snapname)\n" if defined($snapname);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This die should be done for all protocols.

Also, for consistency the whole thing should probably be in filesystem_path(), not in path().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

filesystem_path is no longer called if path is implemented. But you are right, it should be there for all protocols and can be remove from filesystem_path.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Plugin.pm calls filesystem_path() although it looks like this is for filesystem-based storage. Still, since we have it, the path() logic probably should be moved there.

if ( $protocol eq "iscsidirect" ) {
die "Error :: path: snapshot is not implemented ($snapname)\n" if defined($snapname);

my $lun = $class->purestorage_volume_connection( $scfg, $volname );
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why not just always try to connect volume here? Checking if it exists first just adds an extra API call in case if volume is not already connected.

The original purestorage_volume_connection() was ignoring Connection already exists. error for that reason.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here I need the version with GET because only this call returns the LUN id. If the connection already exists the LUN is not returned.


my $serial = $response->{ items }->[0]->{ serial } or die "Error :: Failed to retrieve volume serial";

my $protocol = $scfg->{ protocol } // $default_protocol;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's create and use a supporting function to retrieve protocol value. Something like

sub get_protocol() {
   my ($scfg) = @_;
   return $scfg->{ protocol } // $default_protocol;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok

if (!$lun) {
$class->purestorage_volume_connection( $scfg, $volname, 1 );
}
my $protocol = $scfg->{ protocol } // $default_protocol;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Again, I see no real need to check for existing connection if in the end we just want to make sure the volume is connected.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here it is okay to call POST and DELETE unconditally and ignore the errors if you want to spare the api call.

@plieven
Copy link
Copy Markdown
Contributor Author

plieven commented Mar 26, 2025

@amulet1 I would suggest to send follow up patches to address your comments. If you are happy with the results I send a new PR with clean patches.

plieven added a commit to plieven/pve-purestorage-plugin that referenced this pull request Aug 29, 2025
Signed-off-by: Peter Lieven <pl@dlhnet.de>
Signed-off-by: Peter Lieven <pl@dlhnet.de>
@plieven
Copy link
Copy Markdown
Contributor Author

plieven commented Aug 29, 2025

@timansky @amulet1 also here please review the addressed changes

Signed-off-by: Peter Lieven <pl@dlhnet.de>
@cbka
Copy link
Copy Markdown
Contributor

cbka commented Oct 13, 2025

@timansky any love on this ?

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.

4 participants