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

Error when getting Memory Utilsation on Azure VM #9507

Open
AnnaMohan opened this issue May 15, 2024 · 0 comments
Open

Error when getting Memory Utilsation on Azure VM #9507

AnnaMohan opened this issue May 15, 2024 · 0 comments
Labels

Comments

@AnnaMohan
Copy link

Describe the bug

Resources are not being filtered though the resources met the conditions given.

What did you expect to happen?

Resources need to get filtered based on the memory utilisation

Cloud Provider

Microsoft Azure

Cloud Custodian version and dependency information

Custodian:   0.9.36
Python:      3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]
Platform:    posix.uname_result(sysname='Linux', nodename='IN-848K1N3', release='5.10.102.1-microsoft-standard-WSL2', version='#1 SMP Wed Mar 2 00:30:59 UTC 2022', machine='x86_64')
Using venv:  False
Docker: False
Installed:

PyJWT==2.8.0
adal==1.2.7
applicationinsights==0.11.10
apscheduler==3.10.4
argcomplete==3.3.0
attrs==23.2.0
azure-common==1.1.28
azure-core==1.30.1
azure-cosmos==3.2.0
azure-cosmosdb-nspkg==2.0.2
azure-cosmosdb-table==1.0.6
azure-functions==1.19.0
azure-graphrbac==0.61.1
azure-identity==1.16.0
azure-keyvault==4.2.0
azure-keyvault-certificates==4.8.0
azure-keyvault-keys==4.9.0
azure-keyvault-secrets==4.8.0
azure-mgmt-advisor==9.0.0
azure-mgmt-apimanagement==1.0.0
azure-mgmt-appconfiguration==0.7.0
azure-mgmt-applicationinsights==1.0.0
azure-mgmt-appplatform==8.0.0
azure-mgmt-authorization==1.0.0
azure-mgmt-automation==0.1.1
azure-mgmt-batch==15.0.0
azure-mgmt-cdn==12.0.0
azure-mgmt-cognitiveservices==11.0.0
azure-mgmt-compute==19.0.0
azure-mgmt-containerinstance==7.0.0
azure-mgmt-containerregistry==8.0.0b1
azure-mgmt-containerservice==15.1.0
azure-mgmt-core==1.4.0
azure-mgmt-cosmosdb==6.4.0
azure-mgmt-costmanagement==1.0.0
azure-mgmt-databricks==1.0.0b1
azure-mgmt-datafactory==1.1.0
azure-mgmt-datalake-analytics==0.5.0
azure-mgmt-datalake-nspkg==3.0.1
azure-mgmt-datalake-store==0.5.0
azure-mgmt-desktopvirtualization==1.1.0
azure-mgmt-dns==8.0.0b1
azure-mgmt-eventgrid==8.0.0
azure-mgmt-eventhub==11.0.0
azure-mgmt-frontdoor==1.2.0
azure-mgmt-hdinsight==7.0.0
azure-mgmt-iothub==1.0.0
azure-mgmt-keyvault==8.0.0
azure-mgmt-kusto==2.2.0
azure-mgmt-logic==9.0.0
azure-mgmt-machinelearningservices==1.0.0
azure-mgmt-managementgroups==1.0.0b1
azure-mgmt-monitor==2.0.0
azure-mgmt-msi==1.0.0
azure-mgmt-network==17.1.0
azure-mgmt-nspkg==3.0.2
azure-mgmt-policyinsights==1.0.0
azure-mgmt-rdbms==10.1.0
azure-mgmt-recoveryservices==2.5.0
azure-mgmt-recoveryservicesbackup==7.0.0
azure-mgmt-redhatopenshift==1.4.0
azure-mgmt-redis==12.0.0
azure-mgmt-resource==16.1.0
azure-mgmt-resourcegraph==7.0.0
azure-mgmt-search==8.0.0
azure-mgmt-security==1.0.0
azure-mgmt-servicebus==8.2.0
azure-mgmt-servicefabric==1.0.0
azure-mgmt-signalr==0.4.0
azure-mgmt-sql==1.0.0
azure-mgmt-storage==17.1.0
azure-mgmt-streamanalytics==1.0.0
azure-mgmt-subscription==1.0.0
azure-mgmt-synapse==2.0.0
azure-mgmt-trafficmanager==0.51.0
azure-mgmt-web==2.0.0
azure-nspkg==3.0.2
azure-storage-blob==12.19.1
azure-storage-common==2.1.0
azure-storage-file==2.1.0
azure-storage-file-share==12.15.0
azure-storage-queue==12.9.0
boto3==1.34.92
botocore==1.34.92
c7n==0.9.36
certifi==2024.2.2
cffi==1.16.0
charset-normalizer==3.3.2
click==8.1.7
colorama==0.4.4
cryptography==42.0.5
distlib==0.3.8
docutils==0.18.1
idna==3.7
importlib-metadata==6.11.0
importlib-resources==6.1.1
isodate==0.6.1
jmespath==1.0.1
jsonschema==4.21.1
jsonschema-specifications==2023.12.1
msal==1.28.0
msal-extensions==1.1.0
msrest==0.7.1
msrestazure==0.6.4.post1
netaddr==0.7.20
oauthlib==3.2.2
packaging==24.0
portalocker==2.8.2
pycparser==2.22
pyjwt==2.8.0
python-dateutil==2.9.0.post0
pytz==2024.1
pyyaml==6.0.1
referencing==0.31.1
requests==2.31.0
requests-oauthlib==2.0.0
rpds-py==0.18.0
s3transfer==0.10.1
six==1.16.0
tabulate==0.9.0
typing-extensions==4.11.0
tzlocal==5.2
urllib3==1.26.18
zipp==3.18.1

Policy

policies:
  - name: filter-vms-low-memory-utilization
    resource: azure.vm
    filters:
      - type: metric
        metric: AveragePercentageMemoryUsed
        op: less-than
        aggregation: average
        threshold: 50
        timeframe: 30

Relevant log/traceback output

2024-05-15 15:57:40,605: custodian.output:ERROR Error while executing policy
Traceback (most recent call last):
  File "/home/krishna/.local/lib/python3.10/site-packages/msrest/serialization.py", line 1436, in _deserialize
    found_value = key_extractor(attr, attr_desc, data)
  File "/home/krishna/.local/lib/python3.10/site-packages/msrest/serialization.py", line 1180, in rest_key_extractor
    return working_data.get(key)
AttributeError: 'str' object has no attribute 'get'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/krishna/.local/lib/python3.10/site-packages/c7n/policy.py", line 330, in run
    resources = self.policy.resource_manager.resources()
  File "/home/krishna/.local/lib/python3.10/site-packages/c7n_azure/query.py", line 294, in resources
    resources = self.filter_resources(resources)
  File "/home/krishna/.local/lib/python3.10/site-packages/c7n/manager.py", line 112, in filter_resources
    resources = f.process(resources, event)
  File "/home/krishna/.local/lib/python3.10/site-packages/c7n_azure/filters.py", line 174, in process
    processed = list(w.map(self.process_resource, resources))
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 621, in result_iterator
    yield _result_or_cancel(fs.pop())
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 319, in _result_or_cancel
    return fut.result(timeout)
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 458, in result
    return self.__get_result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    raise self._exception
  File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/krishna/.local/lib/python3.10/site-packages/c7n_azure/filters.py", line 247, in process_resource
    return resource if self.passes_op_filter(resource) else None
  File "/home/krishna/.local/lib/python3.10/site-packages/c7n_azure/filters.py", line 240, in passes_op_filter
    m_data = self.get_metric_data(resource)
  File "/home/krishna/.local/lib/python3.10/site-packages/c7n_azure/filters.py", line 182, in get_metric_data
    metrics_data = self.client.metrics.list(
  File "/home/krishna/.local/lib/python3.10/site-packages/azure/mgmt/monitor/v2018_01_01/operations/_metrics_operations.py", line 151, in list
    error = self._deserialize(_models.ErrorResponse, response)
  File "/home/krishna/.local/lib/python3.10/site-packages/msrest/serialization.py", line 1376, in __call__
    return self._deserialize(target_obj, data)
  File "/home/krishna/.local/lib/python3.10/site-packages/msrest/serialization.py", line 1454, in _deserialize
    raise_with_traceback(DeserializationError, msg, err)
  File "/home/krishna/.local/lib/python3.10/site-packages/msrest/exceptions.py", line 51, in raise_with_traceback
    raise error.with_traceback(exc_traceback)
  File "/home/krishna/.local/lib/python3.10/site-packages/msrest/serialization.py", line 1436, in _deserialize
    found_value = key_extractor(attr, attr_desc, data)
  File "/home/krishna/.local/lib/python3.10/site-packages/msrest/serialization.py", line 1180, in rest_key_extractor
    return working_data.get(key)
azure.core.exceptions.DeserializationError: ("Unable to deserialize to object: type, AttributeError: 'str' object has no attribute 'get'", AttributeError("'str' object has no attribute 'get'"))
2024-05-15 15:57:40,613: custodian.commands:ERROR Error while executing policy filter-vms-low-memory-utilization, continuing
Traceback (most recent call last):
  File "/home/krishna/.local/lib/python3.10/site-packages/msrest/serialization.py", line 1436, in _deserialize
    found_value = key_extractor(attr, attr_desc, data)
  File "/home/krishna/.local/lib/python3.10/site-packages/msrest/serialization.py", line 1180, in rest_key_extractor
    return working_data.get(key)
AttributeError: 'str' object has no attribute 'get'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/krishna/.local/lib/python3.10/site-packages/c7n/commands.py", line 307, in run
    policy()
  File "/home/krishna/.local/lib/python3.10/site-packages/c7n/policy.py", line 1357, in __call__
    resources = mode.run()
  File "/home/krishna/.local/lib/python3.10/site-packages/c7n/policy.py", line 330, in run
    resources = self.policy.resource_manager.resources()
  File "/home/krishna/.local/lib/python3.10/site-packages/c7n_azure/query.py", line 294, in resources
    resources = self.filter_resources(resources)
  File "/home/krishna/.local/lib/python3.10/site-packages/c7n/manager.py", line 112, in filter_resources
    resources = f.process(resources, event)
  File "/home/krishna/.local/lib/python3.10/site-packages/c7n_azure/filters.py", line 174, in process
    processed = list(w.map(self.process_resource, resources))
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 621, in result_iterator
    yield _result_or_cancel(fs.pop())
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 319, in _result_or_cancel
    return fut.result(timeout)
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 458, in result
    return self.__get_result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    raise self._exception
  File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/krishna/.local/lib/python3.10/site-packages/c7n_azure/filters.py", line 247, in process_resource
    return resource if self.passes_op_filter(resource) else None
  File "/home/krishna/.local/lib/python3.10/site-packages/c7n_azure/filters.py", line 240, in passes_op_filter
    m_data = self.get_metric_data(resource)
  File "/home/krishna/.local/lib/python3.10/site-packages/c7n_azure/filters.py", line 182, in get_metric_data
    metrics_data = self.client.metrics.list(
  File "/home/krishna/.local/lib/python3.10/site-packages/azure/mgmt/monitor/v2018_01_01/operations/_metrics_operations.py", line 151, in list
    error = self._deserialize(_models.ErrorResponse, response)
  File "/home/krishna/.local/lib/python3.10/site-packages/msrest/serialization.py", line 1376, in __call__
    return self._deserialize(target_obj, data)
  File "/home/krishna/.local/lib/python3.10/site-packages/msrest/serialization.py", line 1454, in _deserialize
    raise_with_traceback(DeserializationError, msg, err)
  File "/home/krishna/.local/lib/python3.10/site-packages/msrest/exceptions.py", line 51, in raise_with_traceback
    raise error.with_traceback(exc_traceback)
  File "/home/krishna/.local/lib/python3.10/site-packages/msrest/serialization.py", line 1436, in _deserialize
    found_value = key_extractor(attr, attr_desc, data)
  File "/home/krishna/.local/lib/python3.10/site-packages/msrest/serialization.py", line 1180, in rest_key_extractor
    return working_data.get(key)
azure.core.exceptions.DeserializationError: ("Unable to deserialize to object: type, AttributeError: 'str' object has no attribute 'get'", AttributeError("'str' object has no attribute 'get'"))
2024-05-15 15:57:40,615: custodian.commands:ERROR The following policies had errors while executing
 - filter-vms-low-memory-utilization

Extra information or context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Pending-First
Development

No branches or pull requests

1 participant