Skip to content

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

Merged
merged 2 commits into from
Oct 30, 2017
Merged

Add File Share Snapshot Support #4832

merged 2 commits into from
Oct 30, 2017

Conversation

blueww
Copy link
Member

@blueww blueww commented Oct 23, 2017

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

  • [ Y] Title of the pull request is clear and informative.
  • [Y ] There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.
  • [ Y] The pull request does not introduce breaking changes (unless a major version change occurs in the assembly and module).

Testing Guidelines

  • [Y ] Pull request includes test coverage for the included changes.
  • [Y ] PowerShell scripts used in tests should do any necessary setup as part of the test or suite setup, and should not use hard-coded values for locations or existing resources.

Cmdlet Signature Guidelines

  • New cmdlets that make changes or have side effects should implement ShouldProcess and have SupportShouldProcess=true specified in the cmdlet attribute. You can find more information on ShouldProcess here.
  • Cmdlet specifies OutputType attribute if any output is produced - if the cmdlet produces no output, it should implement a PassThru parameter.

Cmdlet Parameter Guidelines

  • [ Y] Parameter types should not expose types from the management library - complex parameter types should be defined in the module.
  • [ Y] Complex parameter types are discouraged - a parameter type should be simple types as often as possible. If complex types are used, they should be shallow and easily creatable from a constructor or another cmdlet.
  • [Y ] Cmdlet parameter sets should be mutually exclusive - each parameter set must have at least one mandatory parameter not in other parameter sets.

@blueww
Copy link
Member Author

blueww commented Oct 23, 2017

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.

@maddieclayton
Copy link
Contributor

Hi Wei Wei- Could you fill out a design review template for these changes and send it to our review alias (azdevxpsdr)? Thanks.

@blueww
Copy link
Member Author

blueww commented Oct 24, 2017

The design is reviewed and signed off by OneSDK team (Mark) long ago.
Anyway, I have resend it in mail.

Copy link
Contributor

@maddieclayton maddieclayton left a 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?

@@ -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
Copy link
Contributor

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.

Copy link
Member Author

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.")]
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix spacing

Copy link
Member Author

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;
Copy link
Contributor

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?

Copy link
Member Author

@blueww blueww Oct 25, 2017

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))
Copy link
Contributor

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?

Copy link
Member Author

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
Copy link
Contributor

Choose a reason for hiding this comment

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

IncludeAllSnapshot

Copy link
Member Author

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.

@blueww
Copy link
Member Author

blueww commented Oct 25, 2017

@maddieclayton

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))
Copy link
Contributor

@maddieclayton maddieclayton Oct 26, 2017

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.

Copy link
Member Author

@blueww blueww Oct 27, 2017

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.

Copy link
Contributor

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))
Copy link
Contributor

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.

Copy link
Member Author

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);
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 "The remove operation of share '{0}' has been cancelled" makes more sense. Also remove extra whitespace.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated.

Copy link
Member

@cormacpayne cormacpayne left a 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" />
Copy link
Member

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

Copy link
Member Author

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.")]
Copy link
Member

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.")]
Copy link
Member

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"

Copy link
Member Author

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" />
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

removed

@cormacpayne cormacpayne removed their assignment Oct 26, 2017
@blueww blueww force-pushed the fsh branch 2 times, most recently from 09c87b7 to 26034d4 Compare October 27, 2017 01:41
@cormacpayne
Copy link
Member

@maddieclayton
Copy link
Contributor

@markcowl markcowl merged commit a6f2ca0 into Azure:preview Oct 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants