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

Fix pagination issue in community.general.github_deploy_key #7375

Conversation

padraic-padraic
Copy link
Contributor

@padraic-padraic padraic-padraic commented Oct 9, 2023

SUMMARY

Fixes #5929.

I also encountered this error, though unrelated to the use of force. The bug is caused by the pagination code in the module. If Deploy Keys exist, but not enough to paginate, the pagination check would raise a KeyError. Setting a default value for the lookup is sufficient to fix the module.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

github_deploy_key

ADDITIONAL INFORMATION

See issue #5929 for a discussion of how to trigger the bug.

Before:

TASK [(Locally) Push the deploy key to jupiler] *****************************************************************************************************************************************************
task path: /Users/padraic/Documents/bitbucket_to_github/migrate_machines/migrate_repos.yaml:62
The full traceback is:
Traceback (most recent call last):
  File "/Users/padraic/.ansible/tmp/ansible-tmp-1696887982.857162-24605-9050136827119/AnsiballZ_my_github_deploy_key.py", line 107, in <module>
    _ansiballz_main()
  File "/Users/padraic/.ansible/tmp/ansible-tmp-1696887982.857162-24605-9050136827119/AnsiballZ_my_github_deploy_key.py", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/Users/padraic/.ansible/tmp/ansible-tmp-1696887982.857162-24605-9050136827119/AnsiballZ_my_github_deploy_key.py", line 47, in invoke_module
    runpy.run_module(mod_name='ansible.modules.my_github_deploy_key', init_globals=dict(_module_fqn='ansible.modules.my_github_deploy_key', _modlib_path=modlib_path),
  File "<frozen runpy>", line 226, in run_module
  File "<frozen runpy>", line 98, in _run_module_code
  File "<frozen runpy>", line 88, in _run_code
  File "/var/folders/ps/dwlk96k15fl7_csnxt2q57dc0000gn/T/ansible_my_github_deploy_key_payload_oim22357/ansible_my_github_deploy_key_payload.zip/ansible/modules/my_github_deploy_key.py", line 340, in <module>
  File "/var/folders/ps/dwlk96k15fl7_csnxt2q57dc0000gn/T/ansible_my_github_deploy_key_payload_oim22357/ansible_my_github_deploy_key_payload.zip/ansible/modules/my_github_deploy_key.py", line 328, in main
  File "/var/folders/ps/dwlk96k15fl7_csnxt2q57dc0000gn/T/ansible_my_github_deploy_key_payload_oim22357/ansible_my_github_deploy_key_payload.zip/ansible/modules/my_github_deploy_key.py", line 231, in get_existing_key
  File "/var/folders/ps/dwlk96k15fl7_csnxt2q57dc0000gn/T/ansible_my_github_deploy_key_payload_oim22357/ansible_my_github_deploy_key_payload.zip/ansible/modules/my_github_deploy_key.py", line 223, in paginate
KeyError: 'link'
fatal: [***.zensor.be -> 127.0.0.1]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/Users/padraic/.ansible/tmp/ansible-tmp-1696887982.857162-24605-9050136827119/AnsiballZ_my_github_deploy_key.py\", line 107, in <module>\n    _ansiballz_main()\n  File \"/Users/padraic/.ansible/tmp/ansible-tmp-1696887982.857162-24605-9050136827119/AnsiballZ_my_github_deploy_key.py\", line 99, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/Users/padraic/.ansible/tmp/ansible-tmp-1696887982.857162-24605-9050136827119/AnsiballZ_my_github_deploy_key.py\", line 47, in invoke_module\n    runpy.run_module(mod_name='ansible.modules.my_github_deploy_key', init_globals=dict(_module_fqn='ansible.modules.my_github_deploy_key', _modlib_path=modlib_path),\n  File \"<frozen runpy>\", line 226, in run_module\n  File \"<frozen runpy>\", line 98, in _run_module_code\n  File \"<frozen runpy>\", line 88, in _run_code\n  File \"/var/folders/ps/dwlk96k15fl7_csnxt2q57dc0000gn/T/ansible_my_github_deploy_key_payload_oim22357/ansible_my_github_deploy_key_payload.zip/ansible/modules/my_github_deploy_key.py\", line 340, in <module>\n  File \"/var/folders/ps/dwlk96k15fl7_csnxt2q57dc0000gn/T/ansible_my_github_deploy_key_payload_oim22357/ansible_my_github_deploy_key_payload.zip/ansible/modules/my_github_deploy_key.py\", line 328, in main\n  File \"/var/folders/ps/dwlk96k15fl7_csnxt2q57dc0000gn/T/ansible_my_github_deploy_key_payload_oim22357/ansible_my_github_deploy_key_payload.zip/ansible/modules/my_github_deploy_key.py\", line 231, in get_existing_key\n  File \"/var/folders/ps/dwlk96k15fl7_csnxt2q57dc0000gn/T/ansible_my_github_deploy_key_payload_oim22357/ansible_my_github_deploy_key_payload.zip/ansible/modules/my_github_deploy_key.py\", line 223, in paginate\nKeyError: 'link'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

After:

TASK [(Locally) Push the deploy key to jupiler] *****************************************************************************************************************************************************
changed: [**** -> 127.0.0.1]

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module new_contributor Help guide this first time contributor plugins plugin (any type) traceback labels Oct 9, 2023
Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution!

Co-authored-by: Felix Fontein <felix@fontein.de>
@felixfontein
Copy link
Collaborator

If nobody objects, I'll merge this in a few days.

@felixfontein felixfontein merged commit eb4f8d4 into ansible-collections:main Oct 18, 2023
@patchback
Copy link

patchback bot commented Oct 18, 2023

Backport to stable-6: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-6/eb4f8d4301adcf4329e358b216e4696741479221/pr-7375

Backported as #7407

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@felixfontein
Copy link
Collaborator

@padraic-padraic thanks for your contribution!

patchback bot pushed a commit that referenced this pull request Oct 18, 2023
* Fix pagination issue in community.general.github_deploy_key

* Add changelog fragment

* Update changelogs/fragments/7375-fix-github-deploy-key-pagination.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit eb4f8d4)
@patchback
Copy link

patchback bot commented Oct 18, 2023

Backport to stable-7: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-7/eb4f8d4301adcf4329e358b216e4696741479221/pr-7375

Backported as #7408

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Oct 18, 2023
* Fix pagination issue in community.general.github_deploy_key

* Add changelog fragment

* Update changelogs/fragments/7375-fix-github-deploy-key-pagination.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit eb4f8d4)
felixfontein pushed a commit that referenced this pull request Oct 18, 2023
…ity.general.github_deploy_key (#7407)

Fix  pagination issue in community.general.github_deploy_key (#7375)

* Fix pagination issue in community.general.github_deploy_key

* Add changelog fragment

* Update changelogs/fragments/7375-fix-github-deploy-key-pagination.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit eb4f8d4)

Co-authored-by: Padraic Calpin <padraic.calpin93@gmail.com>
felixfontein pushed a commit that referenced this pull request Oct 18, 2023
…ity.general.github_deploy_key (#7408)

Fix  pagination issue in community.general.github_deploy_key (#7375)

* Fix pagination issue in community.general.github_deploy_key

* Add changelog fragment

* Update changelogs/fragments/7375-fix-github-deploy-key-pagination.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit eb4f8d4)

Co-authored-by: Padraic Calpin <padraic.calpin93@gmail.com>
etrombly pushed a commit to etrombly/community.general that referenced this pull request Oct 25, 2023
…collections#7375)

* Fix pagination issue in community.general.github_deploy_key

* Add changelog fragment

* Update changelogs/fragments/7375-fix-github-deploy-key-pagination.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug module module new_contributor Help guide this first time contributor plugins plugin (any type) traceback
Projects
None yet
Development

Successfully merging this pull request may close these issues.

community.general.github_deploy_key fails on force, if no SSH key exists to override
3 participants