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

Deploy error: The error was: AttributeError: module 'time' has no attribute 'clock' #1881

Closed
benzin1984 opened this issue Sep 24, 2020 · 5 comments · Fixed by #14109
Closed

Comments

@benzin1984
Copy link

While deploying to Azure, got this error:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: module 'time' has no attribute 'clock'

fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File "/home/ll/.ansible/tmp/ansible-tmp-1600930951.3805804-16482-30144226544439/AnsiballZ_azure_rm_deployment.py", line 102, in \n _ansiballz_main()\n File "/home/ll/.ansible/tmp/ansible-tmp-1600930951.3805804-16482-30144226544439/AnsiballZ_azure_rm_deployment.py", line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File "/home/ll/.ansible/tmp/ansible-tmp-1600930951.3805804-16482-30144226544439/AnsiballZ_azure_rm_deployment.py", line 40, in invoke_module\n runpy.run_module(mod_name='ansible.modules.cloud.azure.azure_rm_deployment', init_globals=None, run_name='main', alter_sys=True)\n File "/usr/lib/python3.8/runpy.py", line 206, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File "/usr/lib/python3.8/runpy.py", line 96, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File "/usr/lib/python3.8/runpy.py", line 86, in _run_code\n exec(code, run_globals)\n File "/tmp/ansible_azure_rm_deployment_payload_jjehvh8g/ansible_azure_rm_deployment_payload.zip/ansible/modules/cloud/azure/azure_rm_deployment.py", line 702, in \n File "/tmp/ansible_azure_rm_deployment_payload_jjehvh8g/ansible_azure_rm_deployment_payload.zip/ansible/modules/cloud/azure/azure_rm_deployment.py", line 698, in main\n File "/tmp/ansible_azure_rm_deployment_payload_jjehvh8g/ansible_azure_rm_deployment_payload.zip/ansible/modules/cloud/azure/azure_rm_deployment.py", line 469, in init\n File "/tmp/ansible_azure_rm_deployment_payload_jjehvh8g/ansible_azure_rm_deployment_payload.zip/ansible/module_utils/azure_rm_common.py", line 341, in init\n File "/tmp/ansible_azure_rm_deployment_payload_jjehvh8g/ansible_azure_rm_deployment_payload.zip/ansible/module_utils/azure_rm_common.py", line 1145, in init\n File "/tmp/ansible_azure_rm_deployment_payload_jjehvh8g/ansible_azure_rm_deployment_payload.zip/ansible/module_utils/azure_rm_common.py", line 1378, in _get_credentials\n File "/tmp/ansible_azure_rm_deployment_payload_jjehvh8g/ansible_azure_rm_deployment_payload.zip/ansible/module_utils/azure_rm_common.py", line 1289, in _get_azure_cli_credentials\n File "/home/ll/algo/.env/lib/python3.8/site-packages/azure/common/credentials.py", line 46, in get_azure_cli_credentials\n profile = get_cli_profile()\n File "/home/ll/algo/.env/lib/python3.8/site-packages/azure/common/credentials.py", line 29, in get_cli_profile\n return Profile(storage=ACCOUNT)\n File "/home/ll/algo/.env/lib/python3.8/site-packages/azure/cli/core/_profile.py", line 125, in init\n self.cli_ctx = cli_ctx or get_default_cli()\n File "/home/ll/algo/.env/lib/python3.8/site-packages/azure/cli/core/init.py", line 485, in get_default_cli\n return AzCli(cli_name='az',\n File "/home/ll/algo/.env/lib/python3.8/site-packages/azure/cli/core/init.py", line 52, in init\n SESSION.load(os.path.join(azure_folder, 'az.sess'), max_age=3600)\n File "/home/ll/algo/.env/lib/python3.8/site-packages/azure/cli/core/_session.py", line 37, in load\n if st.st_mtime + max_age < time.clock():\nAttributeError: module 'time' has no attribute 'clock'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

The deployment env is Win10 running Ubuntu WSL2.

It looks like the python 3.8 may be using a depricated library for key generation. This here may describe the issue:
https://stackoverflow.com/questions/58569361/attributeerror-module-time-has-no-attribute-clock-in-python-3-8

I tried to install PyCryptoDome and remove Cryptography, but Cryptography gets re-installed at runtime of ./algo.

Thanks guys!

@benzin1984
Copy link
Author

I think the problem is in this file:

algo/roles/cloud-azure/tasks/venv.yml

The version of azure-cli-core is too old. So this line has to change:
- azure-cli-core==2.0.35

I've changed it to this, and the deploy worked:
- azure-cli-core==2.12.0

Hope this helps... I could do a pull request I guess?

chadduffey added a commit to chadduffey/algo that referenced this issue Dec 20, 2020
…esolve errors

trailofbits#1881 

I needed the update to azure-cli-core as suggested by @benzin1984 but the new version didn't work for me without an update to msrestazure as well. 

Dependency changes:
msrestazure==0.6.4
azure-cli-core==2.16.0
@bsiegel
Copy link

bsiegel commented Dec 30, 2020

This should probably mirror the official Ansible collection for azure, rather than just trying to update random modules until it works: https://github.com/ansible-collections/azure/blob/dev/requirements-azure.txt

(It seems likely this is where the list came from in the first place)

EDIT: Tested this, and unfortunately the update to azure-mgmt-resource breaks the ansible module, so that change should probably not be added. But at least aligning to azure-cli-core==2.11.1 probably makes sense.

@argium
Copy link

argium commented May 14, 2021

Still hitting this issue today. Has this not been addressed in master yet? I'll try the tip above in the meantime.

Algo running on: macOS 11.3.1
Created from git clone. Last commit: 70f9f91 Fix typo (#14145)
Python 3.9.5

if st.st_mtime + max_age < time.clock():\nAttributeError: module 'time' has no attribute 'clock

TASK [cloud-azure : Create AlgoVPN Server] ************************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: module 'time' has no attribute 'clock'
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/Users/richard/.ansible/tmp/ansible-tmp-1620961120.1692932-3393-220555533807102/AnsiballZ_azure_rm_deployment.py\", line 102, in <module>\n    _ansiballz_main()\n  File \"/Users/richard/.ansible/tmp/ansible-tmp-1620961120.1692932-3393-220555533807102/AnsiballZ_azure_rm_deployment.py\", line 94, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/Users/richard/.ansible/tmp/ansible-tmp-1620961120.1692932-3393-220555533807102/AnsiballZ_azure_rm_deployment.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible.modules.cloud.azure.azure_rm_deployment', init_globals=None, run_name='__main__', alter_sys=True)\n  File \"/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py\", line 210, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/var/folders/pc/4y2zx02j1zj46t88bzy3z1cw0000gn/T/ansible_azure_rm_deployment_payload_qri8b97z/ansible_azure_rm_deployment_payload.zip/ansible/modules/cloud/azure/azure_rm_deployment.py\", line 702, in <module>\n  File \"/var/folders/pc/4y2zx02j1zj46t88bzy3z1cw0000gn/T/ansible_azure_rm_deployment_payload_qri8b97z/ansible_azure_rm_deployment_payload.zip/ansible/modules/cloud/azure/azure_rm_deployment.py\", line 698, in main\n  File \"/var/folders/pc/4y2zx02j1zj46t88bzy3z1cw0000gn/T/ansible_azure_rm_deployment_payload_qri8b97z/ansible_azure_rm_deployment_payload.zip/ansible/modules/cloud/azure/azure_rm_deployment.py\", line 469, in __init__\n  File \"/var/folders/pc/4y2zx02j1zj46t88bzy3z1cw0000gn/T/ansible_azure_rm_deployment_payload_qri8b97z/ansible_azure_rm_deployment_payload.zip/ansible/module_utils/azure_rm_common.py\", line 341, in __init__\n  File \"/var/folders/pc/4y2zx02j1zj46t88bzy3z1cw0000gn/T/ansible_azure_rm_deployment_payload_qri8b97z/ansible_azure_rm_deployment_payload.zip/ansible/module_utils/azure_rm_common.py\", line 1145, in __init__\n  File \"/var/folders/pc/4y2zx02j1zj46t88bzy3z1cw0000gn/T/ansible_azure_rm_deployment_payload_qri8b97z/ansible_azure_rm_deployment_payload.zip/ansible/module_utils/azure_rm_common.py\", line 1378, in _get_credentials\n  File \"/var/folders/pc/4y2zx02j1zj46t88bzy3z1cw0000gn/T/ansible_azure_rm_deployment_payload_qri8b97z/ansible_azure_rm_deployment_payload.zip/ansible/module_utils/azure_rm_common.py\", line 1289, in _get_azure_cli_credentials\n  File \"/Users/richard/Sources/algo/.env/lib/python3.9/site-packages/azure/common/credentials.py\", line 46, in get_azure_cli_credentials\n    profile = get_cli_profile()\n  File \"/Users/richard/Sources/algo/.env/lib/python3.9/site-packages/azure/common/credentials.py\", line 29, in get_cli_profile\n    return Profile(storage=ACCOUNT)\n  File \"/Users/richard/Sources/algo/.env/lib/python3.9/site-packages/azure/cli/core/_profile.py\", line 125, in __init__\n    self.cli_ctx = cli_ctx or get_default_cli()\n  File \"/Users/richard/Sources/algo/.env/lib/python3.9/site-packages/azure/cli/core/__init__.py\", line 485, in get_default_cli\n    return AzCli(cli_name='az',\n  File \"/Users/richard/Sources/algo/.env/lib/python3.9/site-packages/azure/cli/core/__init__.py\", line 52, in __init__\n    SESSION.load(os.path.join(azure_folder, 'az.sess'), max_age=3600)\n  File \"/Users/richard/Sources/algo/.env/lib/python3.9/site-packages/azure/cli/core/_session.py\", line 37, in load\n    if st.st_mtime + max_age < time.clock():\nAttributeError: module 'time' has no attribute 'clock'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

@Ilanad
Copy link

Ilanad commented Jun 9, 2021

This issue still persists running Python 3.8.2 trying to connect to Azure. Neither changing azure-cli-core to 2.12.0 or 2.11.1 works.
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: module 'time' has no attribute 'clock' fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"/Users/ilanadler/.ansible/tmp/ansible-tmp-1623265469.885673-15470-277740876584404/AnsiballZ_azure_rm_deployment.py\", line 102, in <module>\n _ansiballz_main()\n File \"/Users/ilanadler/.ansible/tmp/ansible-tmp-1623265469.885673-15470-277740876584404/AnsiballZ_azure_rm_deployment.py\", line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/Users/ilanadler/.ansible/tmp/ansible-tmp-1623265469.885673-15470-277740876584404/AnsiballZ_azure_rm_deployment.py\", line 40, in invoke_module\n runpy.run_module(mod_name='ansible.modules.cloud.azure.azure_rm_deployment', init_globals=None, run_name='__main__', alter_sys=True)\n File \"/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/runpy.py\", line 206, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/runpy.py\", line 96, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File \"/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/runpy.py\", line 86, in _run_code\n exec(code, run_globals)\n File \"/var/folders/pt/m27fsvp955d8wmcxsh_xh4tr0000gn/T/ansible_azure_rm_deployment_payload_eb3wxpla/ansible_azure_rm_deployment_payload.zip/ansible/modules/cloud/azure/azure_rm_deployment.py\", line 702, in <module>\n File \"/var/folders/pt/m27fsvp955d8wmcxsh_xh4tr0000gn/T/ansible_azure_rm_deployment_payload_eb3wxpla/ansible_azure_rm_deployment_payload.zip/ansible/modules/cloud/azure/azure_rm_deployment.py\", line 698, in main\n File \"/var/folders/pt/m27fsvp955d8wmcxsh_xh4tr0000gn/T/ansible_azure_rm_deployment_payload_eb3wxpla/ansible_azure_rm_deployment_payload.zip/ansible/modules/cloud/azure/azure_rm_deployment.py\", line 469, in __init__\n File \"/var/folders/pt/m27fsvp955d8wmcxsh_xh4tr0000gn/T/ansible_azure_rm_deployment_payload_eb3wxpla/ansible_azure_rm_deployment_payload.zip/ansible/module_utils/azure_rm_common.py\", line 341, in __init__\n File \"/var/folders/pt/m27fsvp955d8wmcxsh_xh4tr0000gn/T/ansible_azure_rm_deployment_payload_eb3wxpla/ansible_azure_rm_deployment_payload.zip/ansible/module_utils/azure_rm_common.py\", line 1145, in __init__\n File \"/var/folders/pt/m27fsvp955d8wmcxsh_xh4tr0000gn/T/ansible_azure_rm_deployment_payload_eb3wxpla/ansible_azure_rm_deployment_payload.zip/ansible/module_utils/azure_rm_common.py\", line 1378, in _get_credentials\n File \"/var/folders/pt/m27fsvp955d8wmcxsh_xh4tr0000gn/T/ansible_azure_rm_deployment_payload_eb3wxpla/ansible_azure_rm_deployment_payload.zip/ansible/module_utils/azure_rm_common.py\", line 1289, in _get_azure_cli_credentials\n File \"/Users/ilanadler/algo-master/.env/lib/python3.8/site-packages/azure/common/credentials.py\", line 46, in get_azure_cli_credentials\n profile = get_cli_profile()\n File \"/Users/ilanadler/algo-master/.env/lib/python3.8/site-packages/azure/common/credentials.py\", line 29, in get_cli_profile\n return Profile(storage=ACCOUNT)\n File \"/Users/ilanadler/algo-master/.env/lib/python3.8/site-packages/azure/cli/core/_profile.py\", line 125, in __init__\n self.cli_ctx = cli_ctx or get_default_cli()\n File \"/Users/ilanadler/algo-master/.env/lib/python3.8/site-packages/azure/cli/core/__init__.py\", line 485, in get_default_cli\n return AzCli(cli_name='az',\n File \"/Users/ilanadler/algo-master/.env/lib/python3.8/site-packages/azure/cli/core/__init__.py\", line 52, in __init__\n SESSION.load(os.path.join(azure_folder, 'az.sess'), max_age=3600)\n File \"/Users/ilanadler/algo-master/.env/lib/python3.8/site-packages/azure/cli/core/_session.py\", line 37, in load\n if st.st_mtime + max_age < time.clock():\nAttributeError: module 'time' has no attribute 'clock'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1} included: /Users/ilanadler/algo-master/playbooks/rescue.yml for localhost

@jyeray
Copy link

jyeray commented Jun 15, 2021

So i updated the algo/roles/cloud-azure/tasks/venv.yml file with the following values:
- azure-cli-core==2.24.2
- msrestazure==0.6.3

I am running az core version 2.24.2, you can check it with az --version.

Also in my case i had to refresh the azure toke running az login. Then i executed the ./algo command and it worked!

jackivanov pushed a commit that referenced this issue Aug 14, 2021
…esolve errors (#14109)

#1881 

I needed the update to azure-cli-core as suggested by @benzin1984 but the new version didn't work for me without an update to msrestazure as well. 

Dependency changes:
msrestazure==0.6.4
azure-cli-core==2.16.0
foodneutrino pushed a commit to foodneutrino/algo that referenced this issue Sep 19, 2021
…esolve errors (trailofbits#14109)

trailofbits#1881 

I needed the update to azure-cli-core as suggested by @benzin1984 but the new version didn't work for me without an update to msrestazure as well. 

Dependency changes:
msrestazure==0.6.4
azure-cli-core==2.16.0
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 a pull request may close this issue.

5 participants