-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 snapshots filter to azure.disk #9414
base: main
Are you sure you want to change the base?
Add snapshots filter to azure.disk #9414
Conversation
@kapilt, hello, could you please tell whether the policy in example would work as the name suggests? Because i'm not sure whether the |
def process(self, resources, event=None): | ||
self._snapshots = tuple( | ||
item.serialize(True) | ||
for item in self.manager.get_client().snapshots.list() |
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 feels like it should use the resource manager for snapshots to take advantage of the catch. alternatively if the cardinality on resources is small, it might be something to fetch per volume. additionally rather than iterating over the snapshot list for each volume (n*m) using a map that keys off the uniqueId would greatly reduce iterations
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.
Thank you for feedback!
-
Not sure what
use the resource manager for snapshots to take advantage of the catch
means. Does it mean i should create a separate resource type called smt likeazure.snapshot
and somehow utilize it for this filter? Or should i keep the result ofclient.snapshots.list()
in a class attribute in order not to make this request each timeprocess()
is called? -
as far as i investigated we cannot fetch snapshots for a specific volume. We can only retrieve all snapshots within a subscription/resource-group and then filter out those that belong to a specific disk (https://learn.microsoft.com/en-us/python/api/azure-mgmt-compute/azure.mgmt.compute.v2020_12_01.operations.snapshotsoperations?view=azure-python)
-
using map - ok, i'll do that
Example: