-
Notifications
You must be signed in to change notification settings - Fork 4k
Add File Share Snapshot Support #4832
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
Conversation
on demand: https://azuresdkci.westus2.cloudapp.azure.com/job/powershell-demand/33 I have rerun the on-demand with code change from comments, but seems it failed since some on-demand system issue. |
Hi Wei Wei- Could you fill out a design review template for these changes and send it to our review alias (azdevxpsdr)? Thanks. |
The design is reviewed and signed off by OneSDK team (Mark) long ago. |
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.
Some initial comments. I also don't see any tests for these changes - can you add tests to cover these changes to this PR?
src/Storage/ChangeLog.md
Outdated
@@ -18,7 +18,11 @@ | |||
- Additional information about change #1 | |||
--> | |||
## Current Release | |||
|
|||
* Upgrade to Azure Storage Client Library 8.5.0 and Azure Storage DataMovement Library 0.6.3 | |||
* Add File Share Snapshot Support |
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.
Can you add a little more information here? See example here.
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.
Change it to:
Current Release
- Upgrade to Azure Storage Client Library 8.5.0 and Azure Storage DataMovement Library 0.6.3
- Add File Share Snapshot Support Feature
- Add 'SnapshotTime' parameter to Get-AzureStorageShare
- Add 'IncludeAllSnapshot' parameter to Remove-AzureStorageShare
Position = 1, | ||
Mandatory = false, | ||
ParameterSetName = Constants.SpecificParameterSetName, | ||
HelpMessage = "Snapshot Time of the file share snapshot to be gotten.")] |
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.
Fix spacing
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.
Change to: "SnapshotTime of the file share snapshot to be gotten."
if (e.IsConflictException() && retryDeleteSnapshot) | ||
{ | ||
//If x-ms-delete-snapshots is not specified on the request and the share has associated snapshots, the File service returns status code 409 (Conflict). | ||
retryDeleteSnapshot = true; |
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 don't understand this if statement. If the retryDeleteSnapshot variable is true, it will set retryDeleteSnapshot to true?
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.
Actually, here mean when the exception is ConflictException and need retry, we won't throw the exception, else throw the exception. (If share has snapshot and no "IncludeSnapshots" flag, will report ConflictException in delete share, in this case will retry.)
Change the code to make it more straightforward.
|
||
if (retryDeleteSnapshot) | ||
{ | ||
if (force || await OutputStream.ConfirmAsync(string.Format("This share might has snapshots, Remove the share and all snapshots?: {0}", share.Name)).ConfigureAwait(false)) |
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 is the difference in behavior between -IncludeAllSnapshots and -Force?
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.
-Force means no prompt, we will try our best to delete the share without prompt.
-IncludeAllSnapshot, just means will add "IncludeSnapshots" flag when delete the share. So delete the share with snapshot won't fail since has snapshot. (Anyway, it still can fail for other reason like server timeout)
@@ -37,6 +38,13 @@ PS C:\>Remove-AzureStorageShare -Name "ContosoShare06" | |||
|
|||
This command removes the file share named ContosoShare06. | |||
|
|||
### Example 2: Remove a file share and all its snapshots | |||
``` | |||
PS C:\>Remove-AzureStorageShare -Name "ContosoShare06" -IncludeSnapshot |
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.
IncludeAllSnapshot
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.
Good catch! The help has rebuild after change the parameter name from "IncludeSnapshot" to "IncludeAllSnaspshot" (agreed by feature team and OneSDK team), but the sample is missed.
I have checked all other help change, no missing now.
The Data Plan storage cmdlet are based on XSCL, which can't be record by Unit test. So we get agreed will test the scenario in Storage Team functional test. And the test already passed. |
catch (StorageException e) | ||
{ | ||
//If x-ms-delete-snapshots is not specified on the request and the share has associated snapshots, the File service returns status code 409 (Conflict). | ||
if (!(e.IsConflictException() && retryDeleteSnapshot)) |
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.
Is there ever a case where DeleteShareAsync will throw a conflictexception when the deleteShareSnapshotsOption is set to IncludeSnapshots? I'm just curious about whether you need to check if retryDeleteSnapshot is true.
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.
There are cases to throw 419 (conflict) error when the share is being deleted, and try to delete again.
So we need to check the retryDeleteSnapshot is set and the error is 419 error (try to delete a share with snapshot without IncludSnapshot flag will get 419 error). This the best we can do.
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.
Okay, sounds good.
|
||
if (retryDeleteSnapshot) | ||
{ | ||
if (force || await OutputStream.ConfirmAsync(string.Format("This share might has snapshots, Remove the share and all snapshots?: {0}", share.Name)).ConfigureAwait(false)) |
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 be: "might have snapshots" and "remove" should not be capitalized.
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.
Thanks for the catch!
Modified.
} | ||
else | ||
{ | ||
string result = string.Format("The remove operation of share '{0}' is cancelled.", share.Name); |
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 "The remove operation of share '{0}' has been cancelled" makes more sense. Also remove extra whitespace.
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.
Updated.
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.
@blueww some minor additional changes
</Reference> | ||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL" /> |
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.
@blueww please remove this reference to Newtonsoft.Json
- it is already referenced in the Common.Dependencies.targets
file that this .csproj file references at the bottom of this file
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.
removed.
@@ -28,7 +29,7 @@ public class GetAzureStorageShare : AzureStorageFileCmdletBase | |||
Position = 0, | |||
Mandatory = true, | |||
ParameterSetName = Constants.SpecificParameterSetName, | |||
HelpMessage = "Name of the file share to be listed.")] | |||
HelpMessage = "Name of the file share to be gotten.")] |
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.
@blueww I think we should change this to "Name of the file share to be received"
Position = 1, | ||
Mandatory = false, | ||
ParameterSetName = Constants.SpecificParameterSetName, | ||
HelpMessage = "SnapshotTime of the file share snapshot to be gotten.")] |
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.
@blueww same comment about changing "gotten" to "received"
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.
Updated
<package id="Microsoft.Data.Edm" version="5.8.2" targetFramework="net452" /> | ||
<package id="Microsoft.Data.OData" version="5.8.2" targetFramework="net452" /> | ||
<package id="Microsoft.Data.Services.Client" version="5.8.2" targetFramework="net452" /> | ||
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="1.8.0.0" targetFramework="net452" /> | ||
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net452" /> |
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.
@blueww similar comment to the .csproj file: remove this reference to Newtonsoft.Json
as it can be found in the packages.config
file of the Commands.ResourceManager.Common
project.
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.
removed
09c87b7
to
26034d4
Compare
Description
Support Azure File Share Snapshot in Powershell.
The design doc is reviewed and signed off by OneSDK team.
We also change the File/Dir/Share Uri to SnapshotQuanlifiedUri, in other storage File Cmdlets, to handle Share Snapshot.
The change already pass the storage regression.
This checklist is used to make sure that common guidelines for a pull request are followed. You can find a more complete discussion of PowerShell cmdlet best practices here.
General Guidelines
Testing Guidelines
Cmdlet Signature Guidelines
ShouldProcess
and haveSupportShouldProcess=true
specified in the cmdlet attribute. You can find more information onShouldProcess
here.OutputType
attribute if any output is produced - if the cmdlet produces no output, it should implement aPassThru
parameter.Cmdlet Parameter Guidelines