Skip to content
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

azure - parent filter for child resources & bugfix #4611

Merged
merged 10 commits into from Aug 16, 2019

Conversation

logachev
Copy link
Collaborator

@logachev logachev commented Aug 16, 2019

  • Fix bug with QueryResourceManager not handling cache at all
  • Add generic parent filter for child resources. Allows you to apply any parent filter to the child parent.

Example of use: filter Key Vault keys only from specific Key Vaults (tags, names etc) or CosmosDB collections from specific CosmosDBs.

closes #4390

self.parent_manager)

def process(self, resources, event=None):
parent_resources = self.parent_filter.process(self.parent_manager.resources())
Copy link
Collaborator

Choose a reason for hiding this comment

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

it would be much more efficient to use get_resources() with the unique parent ids then fetching all, unless its expected they are already cached.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So for non-event based executions we had to fully enumerate the parents already to get the children, so in that case that is OK as long as we add the cache read in to the def resources (I know it was missing since I created the resource manager years ago :( )

But for event based we'd certainly need some special handling to call get_resources with the right ID(s). If we don't have any children that support events right now we can punt on it (but I think we do?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point on events.. I will take a look

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Created a work item to ensure child resources work properly with event mode. I think today both ARM\non-arm children have issues.

#4617

filters:
- type: parent
filter:
"tag:owner": ProjectA
Copy link
Collaborator

Choose a reason for hiding this comment

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

Might not be good to use the special case as the example here, as it still isn't clear how to use a normal filter. Presumably I'd put a -type: filtername under filter - but for 99.99% of people this will be the first time they have seen this tag syntax and they'll have no idea what is going on.

Or just have two examples, a value filter is fine, or any thing that works on kv/cosmos/sql

cache_key = self.get_cache_key(query)

resources = None
if self._cache.load():
Copy link
Collaborator

Choose a reason for hiding this comment

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

Cool yeah we needed to fix this, but I admit I am a little worried about what new issues we'll discover now, as none of us have ever used the caching in Azure.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed default cache for Azure to memory because of the way Azure SDK works..

15 minute old cache can introduce regressions in the resources if they were change after cache was saved (via the portal e.g.)

Copy link
Collaborator

@stefangordon stefangordon left a comment

Choose a reason for hiding this comment

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

Just looking to understand if we need to do something for event based lookups of parents efficiently - otherwise looks great.

@logachev logachev merged commit 232bc13 into cloud-custodian:master Aug 16, 2019
stefangordon pushed a commit to stefangordon/cloud-custodian that referenced this pull request Aug 21, 2019
fidelito pushed a commit to fidelito/cloud-custodian that referenced this pull request May 29, 2020
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.

azure - filter CosmosDB collections based on parent properties
3 participants