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

[Issue #6152] Error while executing policy flow-logs-enabled #7200

Closed
wants to merge 1 commit into from

Conversation

alexandrupopafc
Copy link

@alexandrupopafc alexandrupopafc commented Apr 8, 2022

Vpc flow log destination comes back empty resulting in a KeyError.

Screenshot 2022-04-08 at 11 03 02

2022-04-08 10:53:31,343: custodian.output:ERROR Error while executing policy
Traceback (most recent call last):
  File "/Users/Alexandru.Popa/dev/tmp/custodian/lib/python3.9/site-packages/c7n/policy.py", line 285, in run
    resources = self.policy.resource_manager.resources()
  File "/Users/Alexandru.Popa/dev/tmp/custodian/lib/python3.9/site-packages/c7n/query.py", line 523, in resources
    resources = self.filter_resources(resources)
  File "/Users/Alexandru.Popa/dev/tmp/custodian/lib/python3.9/site-packages/c7n/manager.py", line 111, in filter_resources
    resources = f.process(resources, event)
  File "/Users/Alexandru.Popa/dev/tmp/custodian/lib/python3.9/site-packages/c7n/filters/core.py", line 340, in process
    return self.process_set(resources, event)
  File "/Users/Alexandru.Popa/dev/tmp/custodian/lib/python3.9/site-packages/c7n/filters/core.py", line 359, in process_set
    resources = f.process(resources, event)
  File "/Users/Alexandru.Popa/dev/tmp/custodian/lib/python3.9/site-packages/c7n/resources/vpc.py", line 139, in process
    fl['LogDestination'], destination)
KeyError: 'LogDestination'
Custodian:   0.9.11
Python:      3.9.10 (main, Jan 15 2022, 11:48:04) 
             [Clang 13.0.0 (clang-1300.0.29.3)]
Platform:    posix.uname_result(sysname='Darwin', nodename='C02FN00MML88.local', release='21.4.0', version='Darwin Kernel Version 21.4.0: Mon Feb 21 20:34:37 PST 2022; root:xnu-8020.101.4~2/RELEASE_X86_64', machine='x86_64')
Using venv:  True
Docker: False
Installed: 

argcomplete==1.12.2
attrs==20.3.0
boto3==1.17.33
botocore==1.20.33
importlib-metadata==3.7.3
jmespath==0.10.0
jsonpickle==1.3
jsonschema==3.2.0
pyrsistent==0.17.3
python-dateutil==2.8.1
pyyaml==5.4.1
s3transfer==0.3.6
setuptools==56.0.0
six==1.15.0
tabulate==0.8.9
typing-extensions==3.7.4.3
urllib3==1.26.4
zipp==3.4.1

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Apr 8, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: alexandrupopafc / name: Alexandru Popa (f849470)

@alexandrupopafc alexandrupopafc changed the title Fix for Issue #6152 [Issue #6152] Error while executing policy flow-logs-enabled Apr 8, 2022
@@ -134,7 +134,7 @@ def process(self, resources, event=None):
for fl in flogs:
dest_type_match = (destination_type is None) or op(
fl['LogDestinationType'], destination_type)
dest_match = (destination is None) or op(
dest_match = (destination is None) or (not hasattr(fl, 'LogDestination')) or op(
Copy link
Collaborator

Choose a reason for hiding this comment

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

hasattr is intended for objects, for dictionaries, a key check is typically done via if key in dict or dict.get(key)

@kapilt
Copy link
Collaborator

kapilt commented Jul 20, 2022

thanks for the pr, we went with the fix in #7569 for this.

@kapilt kapilt closed this Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants