-
Notifications
You must be signed in to change notification settings - Fork 164
Add support for Immutable Storage on container #1144
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
Add support for Immutable Storage on container #1144
Conversation
de707a0
to
3c3a3d8
Compare
@ninjarobot do you have any remarks? |
You want to write at least one test confirmation the JSON that is emitted in the generate ARM template is correct i.e. checking fields etc. |
From an API design, what happens if you don't want to set any policies - do you need to provide a policy regardless (bear in mind computation expressions don't allow optional arguments AFAIK, and overloads must all have the same number of arguments)? I think perhaps creating a dedicated
would be a better way to go. |
Also can you make an issue first which clearly outlines what this PR is designed to solve - normally we create issues, get them approved, and then create a PR to resolve them (in that order :-)) |
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.
Looks great, thanks for adding this support for newer storage account functionality. I made a few minor suggestions you can take or leave as applicable.
DefaultToOAuthAuthentication = this.DefaultToOAuthAuthentication | ||
DnsZoneType = this.DnsZoneType | ||
EnableHierarchicalNamespace = this.EnableDataLake | ||
ImmutableStorageWithVersioning = None // TODO: Implement |
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.
This looks implemented, so can remove the TODO, right?
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.
@ninjarobot I mean here that there is not such operation in the builder. That is what needs to be implemented
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's use GitHub issues rather than TODO comments to track possible enhancements. Would you mind creating one @xperiandri?
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.
Before merging, we need to modify the API - the use of a CE in this regard isn't going to work, from what I can see, from a usability perspective.
@isaacabraham, actually it works fine as all the tests pass. I verified that it works both ways and allow that optional parameter to be specified and omitted |
That's good :-) Nonetheless, I think moving to a dedicated This PR still needs tests for the new code that's been created as well as the other points mentioned (including an issue / issues that reflect the actual changes that are being made here - it's not so much about upgrading the versions but about immutable blobs etc.). Happy to talk through with you the API choices and anything else that's needed. |
I thought about that but considered immutable policy as not so big change to introduce container CE. |
ae28dca
to
1949e2f
Compare
I've implemented tests. Let me know if I miss something |
@isaacabraham my idea was to add now and preserve in the future ability to specify immutability policy |
I think so, yes. If you look elsewhere in the Farmer API, you won't really much in the way of CEs being supplied as secondary arguments to a custom keyword, and I really would like to retain the pattern that we have. You can repurpose the CE you've already built to actually be the container one - just add in the extra name parameter. You can then add that as an overload for the top-level CE What do you think? Thanks for adding the tests. |
Microsoft.Storage/storageAccounts
to 2023-05-01
6a01d5e
to
21088d9
Compare
@isaacabraham I've implemented |
a7a767f
to
6c60511
Compare
@xperiandri I've looked at the parts where you had TODOs in more depth based on
I have a few questions:
|
Not required, just to mark they exist but not implemented
I can if you prefer
I only implemented the piece I need and the scope defined by the PR name |
So you're using it directly on the |
type BlobContainerImmutabilityPoliciesBuilder() = | ||
member _.Yield _ = | ||
BlobContainerImmutabilityPoliciesConfig.Empty | ||
|
||
member _.Run state : BlobContainerImmutabilityPoliciesConfig = state | ||
|
||
/// Sets the AllowProtectedAppendWrites property. | ||
[<CustomOperation "allow_protected_append_writes">] | ||
member _.AllowProtectedAppendWrites(state: BlobContainerImmutabilityPoliciesConfig, value) = { | ||
state with | ||
AllowProtectedAppendWrites = Some value | ||
} | ||
|
||
/// Sets the ImmutabilityPeriodSinceCreation property. | ||
[<CustomOperation "immutability_period_since_creation">] | ||
member _.ImmutabilityPeriodSinceCreation(state: BlobContainerImmutabilityPoliciesConfig, value) = { | ||
state with | ||
ImmutabilityPeriodSinceCreation = Some value | ||
} |
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.
So you're using it directly on the Farmer.Arm.Storage.StorageAccount type rather than via the computation expression?
@mattgallagher92 no, here is the builder
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.
That affects Farmer.Arm.Storage.BlobContainers.ImmutabilityPolicies
. I'm referring to Farmer.Arm.Storage.StorageAccount
.
farmer/src/Farmer/Arm/Storage.fs
Lines 127 to 136 in e9678e5
ImmutableStorageWithVersioning: | |
{| | |
Enable: bool option | |
ImmutabilityPolicy: | |
{| | |
AllowProtectedAppendWrites: bool option | |
ImmutabilityPeriodSinceCreation: int<Days> option | |
State: ImmutabilityPolicyState option | |
|} option | |
|} option |
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 still have not got what your question is about.
Isaac asked to create a container CE.
I need immutability policies, so I also created CE for them.
So now we have blob container and blob container immutability policies CEs, and corresponding properties for them within the StorageAccount
record.
Could you describe again what inconsistency you have found?
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.
Sure 🙂 Thanks for your patience and sorry that this is dragging on so long. I don't have a lot of time available to review this (and unfortunately I'm going to be unavailable over the next few weeks).
When I search for references to the ImmutableStorageWithVersioning
property on Farmer.Arm.Storage.StorageAccount
, I see that it's used in 4 places. 3 of those places set it to None
, and the remaining place uses it via Option.map
, which will therefore also always return None
. As far as I can see, there doesn't seem to be any means of setting it to anything other than None
via a builder, so it seems to be that the Option.map
code is not being tested and is perhaps even redundant.
Given it doesn't seem to be possible to set it via builder, I wondered whether you were setting the field directly on the record somehow, or whether this is something that you don't need.
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.
@mattgallagher92 fixed, please review again
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.
@xperiandri I see a commit labelled Implemented storage account level immutability policy setting and builder
, but I don't actually see the implementation in the diff?
de818e5
to
e9678e5
Compare
Fixed parsing version number on non-English cultures
303d80b
to
8110a9b
Compare
@xperiandri I've re-reviewed. The unresolved conversations are the things that have not been addressed. Note for other maintainers: I'm leaving Compositional IT, so I'm not going to be able to re-review this. There are a few unresolved conversations, but I think that this is good enough to go in as it is. Hopefully Andrii can easily add the missing builder implementation that is mentioned in the latest commit message (e0e6cea), but not actually present in the diff. Once that's done, the other changes are minor ones that maintainers can make before merging. If preferred for whatever reason, I think that it would be reasonable to merge the code as is and make the outstanding tweaks later - the code is good enough. |
I thought I have finally implemented all the builders |
Implemented:
ImmutableStorageWithVersioning
RequireInfrastructureEncryption
This PR closes #I have read the contributing guidelines and have completed the following:
If I haven't completed any of the tasks above, I include the reasons why here:
Which test would you recommend to modify or implement?
Below is a minimal example configuration that includes the new features, which can be used to deploy to Azure: