ansible-collections / azure

Development area for Azure Collections
https://galaxy.ansible.com/azure/azcollection
GNU General Public License v3.0
246 stars 332 forks source link

azure_rm_dnsrecordset throws 'Cloud' object has no attribute 'decode' #1385

Closed shk3bq4d closed 10 months ago

shk3bq4d commented 10 months ago

used to work on 1.18.1, fails on 2.0.0 and 2.1.0, I haven't tested on 2.1.1 since I am stuck on ansible 2.13

its close to https://github.com/Azure/azure-sdk-for-python/issues/3009 and #1343

  module_stderr: |-
    Traceback (most recent call last):
      File "/home/myself/.ansible/tmp/ansible-tmp-1703662571.578979-3116803-188280136704527/AnsiballZ_azure_rm_dnsrecordset.py", line 107, in <module>
        _ansiballz_main()
      File "/home/myself/.ansible/tmp/ansible-tmp-1703662571.578979-3116803-188280136704527/AnsiballZ_azure_rm_dnsrecordset.py", line 99, in _ansiballz_main
        invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
      File "/home/myself/.ansible/tmp/ansible-tmp-1703662571.578979-3116803-188280136704527/AnsiballZ_azure_rm_dnsrecordset.py", line 47, in invoke_module
        runpy.run_module(mod_name='ansible_collections.azure.azcollection.plugins.modules.azure_rm_dnsrecordset', init_globals=dict(_module_fqn='ansible_collections.azure.azcollection.plugins.modules.azure_rm_dnsrecordset', _modlib_path=modlib_path),
      File "/usr/lib/python3.10/runpy.py", line 224, in run_module
        return _run_module_code(code, init_globals, run_name, mod_spec)
      File "/usr/lib/python3.10/runpy.py", line 96, in _run_module_code
        _run_code(code, mod_globals, init_globals,
      File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
        exec(code, run_globals)
      File "/tmp/ansible_azure.azcollection.azure_rm_dnsrecordset_payload_rlruvfqj/ansible_azure.azcollection.azure_rm_dnsrecordset_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_dnsrecordset.py", line 549, in <module>
      File "/tmp/ansible_azure.azcollection.azure_rm_dnsrecordset_payload_rlruvfqj/ansible_azure.azcollection.azure_rm_dnsrecordset_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_dnsrecordset.py", line 545, in main
      File "/tmp/ansible_azure.azcollection.azure_rm_dnsrecordset_payload_rlruvfqj/ansible_azure.azcollection.azure_rm_dnsrecordset_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_dnsrecordset.py", line 381, in __init__
      File "/tmp/ansible_azure.azcollection.azure_rm_dnsrecordset_payload_rlruvfqj/ansible_azure.azcollection.azure_rm_dnsrecordset_payload.zip/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py", line 439, in __init__
      File "/tmp/ansible_azure.azcollection.azure_rm_dnsrecordset_payload_rlruvfqj/ansible_azure.azcollection.azure_rm_dnsrecordset_payload.zip/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py", line 1440, in __init__
      File "/usr/lib/python3.10/urllib/parse.py", line 399, in urlparse
        url, scheme, _coerce_result = _coerce_args(url, scheme)
      File "/usr/lib/python3.10/urllib/parse.py", line 136, in _coerce_args
        return _decode_args(args) + (_encode_result,)
      File "/usr/lib/python3.10/urllib/parse.py", line 120, in _decode_args
        return tuple(x.decode(encoding, errors) if x else '' for x in args)
      File "/usr/lib/python3.10/urllib/parse.py", line 120, in <genexpr>
        return tuple(x.decode(encoding, errors) if x else '' for x in args)
    AttributeError: 'Cloud' object has no attribute 'decode'
  module_stdout: ''
  msg: |-
    MODULE FAILURE
    See stdout/stderr for the exact error
  rc: 1
Fred-sun commented 10 months ago

@shk3bq4d What kind of authorization are you using? 'az login', 'credentials_files’ or env. I checked the code again locally and did not encounter the problem you submitted?


 Print raw_cloud_env:
{'endpoints': {'active_directory': 'https://login.microsoftonline.com',
               'active_directory_data_lake_resource_id': 'https://datalake.azure.net/',
               'active_directory_graph_resource_id': 'https://graph.windows.net/',
               'active_directory_resource_id': 'https://management.core.windows.net/',
               'app_insights_resource_id': 'https://api.applicationinsights.io',
               'app_insights_telemetry_channel_resource_id': 'https://dc.applicationinsights.azure.com/v2/track',
               'attestation_resource_id': 'https://attest.azure.net',
               'azmirror_storage_account_resource_id': None,
               'batch_resource_id': 'https://batch.core.windows.net/',
               'gallery': 'https://gallery.azure.com/',
               'log_analytics_resource_id': 'https://api.loganalytics.io',
               'management': 'https://management.core.windows.net/',
               'media_resource_id': 'https://rest.media.azure.net',
               'microsoft_graph_resource_id': 'https://graph.microsoft.com/',
               'ossrdbms_resource_id': 'https://ossrdbms-aad.database.windows.net',
               'portal': 'https://portal.azure.com',
               'resource_manager': 'https://management.azure.com/',
               'sql_management': 'https://management.core.windows.net:8443/',
               'synapse_analytics_resource_id': 'https://dev.azuresynapse.net',
               'vm_image_alias_doc': 'https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/arm-compute/quickstart-templates/aliases.json'},
 'is_active': True,
 'name': 'AzureCloud',
 'profile': 'latest',
 'suffixes': {'acr_login_server_endpoint': '.azurecr.io',
              'attestation_endpoint': '.attest.azure.net',
              'azure_datalake_analytics_catalog_and_job_endpoint': 'azuredatalakeanalytics.net',
              'azure_datalake_store_file_system_endpoint': 'azuredatalakestore.net',
              'keyvault_dns': '.vault.azure.net',
              'mariadb_server_endpoint': '.mariadb.database.azure.com',
              'mhsm_dns': '.managedhsm.azure.net',
              'mysql_server_endpoint': '.mysql.database.azure.com',
              'postgresql_server_endpoint': '.postgres.database.azure.com',
              'sql_server_hostname': '.database.windows.net',
              'storage_endpoint': 'core.windows.net',
              'storage_sync_endpoint': 'afs.azure.net',
              'synapse_analytics_endpoint': '.dev.azuresynapse.net'}}
shk3bq4d commented 10 months ago

Hello @Fred-sun and thank you for following up,

As a side remark, I am back on 1.18.1 and it works.

As for my authentification mechanism, I am not very familiar on the various mechanisms, but if I delete ~/.azure/msal_token_cache.json, then my ansible playbook no longer works, so I would say az login, but I hope you can figure out.

Best regards,

Fred-sun commented 10 months ago

@shk3bq4d I'm sorry to reply you so late. Previously, delete track1 process lead this error. , which was fixed in PR#1340. Please updated to v2.1.0, try again. Thank you very much!

shk3bq4d commented 10 months ago

Hello,

The issue is no longer present with version v2.1.0.

I am a bit confused as to why as it is one of the two versions I reported to be initially incorrect. A comparison of pip list may have been useful.

Anyhow, thank you @Fred-sun and I'll mark this issue as closed

Fred-sun commented 10 months ago

@shk3bq4d Thank you for your feedback, you are welcome to submit your problems!