Skip to content

Conversation

@seanmcc-msft
Copy link
Member

No description provided.

@ghost ghost added the Storage Storage Service (Queues, Blobs, Files) label Oct 13, 2020
else if ((includeSnapshots == null || includeSnapshots == true) && shareSnapshotsDeleteOption == null)
{
deleteSnapshotsOption = includeSnapshots ? DeleteSnapshotsOptionType.Include : (DeleteSnapshotsOptionType?)null;
shareSnapshotsDeleteOption = ShareSnapshotsDeleteOption.IncludeLeased;
Copy link
Member Author

Choose a reason for hiding this comment

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

Previously, we defaulted to deleting Snapshots with the Share, unless the user specified otherwise. If a share had snapshots, the call would fail if x-ms-delete-snapshots wasn't set to "include".

Now, it's possible to take a lease on a Share Snapshot. The delete call will fail if a Share has a Snapshot with a lease, unless x-ms-delete-snapshots = "include-leased"

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm. is leasing snapshot introduced in the same service release or earlier ?

Copy link
Member Author

Choose a reason for hiding this comment

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

It was introduced in the newest service release.

Copy link
Contributor

Choose a reason for hiding this comment

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

so what happens today with leased share snapshots on default parameters? does it fail?

taking that aside, I think that taking lease on snapshot means "please don't touch it" so if someone else is attempting to delete it they should get a warning and if they still want to break/override lease that should be explicit action on their side (i.e. they should specify explicit option to do that.).

Copy link
Member Author

Choose a reason for hiding this comment

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

Previously, you couldn't lease shares or share snapshots. If you attempted to delete a share that had snapshots, the request would fail with a 400. The previous behavior in the SDK was to delete snapshots by default.

Today, the previous behavior stands, but has been extended. Now, you can take a lease on a share snapshot. If you don't specify "IncludeLeased", the request will fail with a 400. To keep the previous SDK behavior, I think we need to switch to sending "IncludeLeased" by default. Passing "Include" by default would also make sense.

Copy link
Member Author

Choose a reason for hiding this comment

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

Passing "Include" by default as we previously did might be the best option.

Copy link
Contributor

Choose a reason for hiding this comment

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

So people who never took lease on snapshot won't tell a difference between default "Include" and "IncludeLeased.
But if we default to "IncludeLeased" we might get some unhappy users who's data got deleted unintentionally.
Afaik for other API/use cases where lease is involved user is required to call some specific action/parameter to break the lease - I think that's more important than making sure that this api never throws 400 on defaults.

I'd default to "Include"

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 that's more important than making sure that this api never throws 400 on defaults.

The one downside of defaulting to "include" is we will throw a 400 with defaults if there are any leased share snapshots associated with the share.

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 that's desired. Otherwise why someone would take lease?

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed back to "include"

Comment on lines 12016 to 12030
/// <summary>
/// Specifies the option include to delete the base share and all of its snapshots.
/// </summary>
public enum ShareSnapshotsDeleteOption
{
/// <summary>
/// include
/// </summary>
Include,

/// <summary>
/// include-leased
/// </summary>
IncludeLeased
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is "IncludeLeased" a super set of "Include" and "Leased" or is it just leased. I.e. should I say IncludeLeased or Include | IncludeLeased to delete everything? I find this naming little bit confusing, at least we should explain in the doc string what does it do.

Copy link
Member Author

Choose a reason for hiding this comment

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

IncludeLeased is a super set, see the new unit test.

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe IncludeWithLeased then or something like that.

Copy link
Member Author

Choose a reason for hiding this comment

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

We will have to create a hand-written enum of we want to change this value.

Copy link
Contributor

Choose a reason for hiding this comment

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

If we can add verbose docs strings without creating hand-written type then let's leave it. Otherwise (if adding docs would force type creation) let's rename.

Copy link
Member Author

Choose a reason for hiding this comment

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

We can't update the xml comments for the individual values, but I am able to change the xml comment for the enum itself. Would that work?

Copy link
Contributor

@kasobol-msft kasobol-msft Oct 13, 2020

Choose a reason for hiding this comment

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

:/ I'd go with hand crafted type in that case. So that we can provide experience like this:
image

We can also file feature request for generator to be able to customize enum docs.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

}
else
// This is for backwards compatibility. Perviously, ShareClient.Delete() took a bool includSnapshots parameter.s
else if ((includeSnapshots == null || includeSnapshots == true) && shareSnapshotsDeleteOption == null)
Copy link
Member

Choose a reason for hiding this comment

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

Should we throw if both boolean and enum are provided?

Copy link
Member

Choose a reason for hiding this comment

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

nvm I guess this is not possible

@seanmcc-msft seanmcc-msft merged commit 3c52d27 into Azure:master Oct 14, 2020
annelo-msft pushed a commit to annelo-msft/azure-sdk-for-net that referenced this pull request Feb 17, 2021
@seanmcc-msft seanmcc-msft deleted the feature/storage/shareDeleteIncludeLeasedShapshots branch August 17, 2021 19:54
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